1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 47 unchanged lines hidden (view full) ---
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)in.c 8.2 (Berkeley) 11/15/93
61 */
62
63#include <sys/cdefs.h>
64__FBSDID("$FreeBSD: head/sys/netinet6/in6.c 241686 2012-10-18 13:57:24Z andre $");
65
66#include "opt_compat.h"
67#include "opt_inet.h"
68#include "opt_inet6.h"
69
70#include <sys/param.h>
71#include <sys/errno.h>
72#include <sys/jail.h>
--- 917 unchanged lines hidden (view full) ---
990cleanup:
991 return (error);
992}
993
994/*
995 * Update parameters of an IPv6 interface address.
996 * If necessary, a new entry is created and linked into address chains.
997 * This function is separated from in6_control().
998 */
999int
1000in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
1001 struct in6_ifaddr *ia, int flags)
1002{
1003 int error = 0, hostIsNew = 0, plen = -1;
1004 struct sockaddr_in6 dst6;
1005 struct in6_addrlifetime *lt;
--- 510 unchanged lines hidden (view full) ---
1516 }
1517
1518 in6_unlink_ifa(ia, ifp);
1519}
1520
1521static void
1522in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp)
1523{
1524
1525 IF_ADDR_WLOCK(ifp);
1526 TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link);
1527 IF_ADDR_WUNLOCK(ifp);
1528 ifa_free(&ia->ia_ifa); /* if_addrhead */
1529
1530 /*
1531 * Defer the release of what might be the last reference to the
--- 21 unchanged lines hidden (view full) ---
1553 * Also, if the address being removed is autoconf'ed, call
1554 * pfxlist_onlink_check() since the release might affect the status of
1555 * other (detached) addresses.
1556 */
1557 if ((ia->ia6_flags & IN6_IFF_AUTOCONF)) {
1558 pfxlist_onlink_check();
1559 }
1560 ifa_free(&ia->ia_ifa); /* in6_ifaddrhead */
1561}
1562
1563void
1564in6_purgeif(struct ifnet *ifp)
1565{
1566 struct ifaddr *ifa, *nifa;
1567
1568 TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, nifa) {
--- 279 unchanged lines hidden (view full) ---
1848/*
1849 * Initialize an interface's IPv6 address and routing table entry.
1850 */
1851static int
1852in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia,
1853 struct sockaddr_in6 *sin6, int newhost)
1854{
1855 int error = 0, plen, ifacount = 0;
1856 struct ifaddr *ifa;
1857
1858 /*
1859 * Give the interface a chance to initialize
1860 * if this is its first address,
1861 * and to validate the address if necessary.
1862 */
1863 IF_ADDR_RLOCK(ifp);
1864 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
1865 if (ifa->ifa_addr->sa_family != AF_INET6)
1866 continue;
1867 ifacount++;
1868 }
1869 IF_ADDR_RUNLOCK(ifp);
1870
1871 ia->ia_addr = *sin6;
1872
1873 if (ifacount <= 1 && ifp->if_ioctl) {
1874 error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia);
1875 if (error)
1876 return (error);
1877 }
1878
1879 ia->ia_ifa.ifa_metric = ifp->if_metric;
1880
1881 /* we could do in(6)_socktrim here, but just omit it at this moment. */
1882
1883 /*
1884 * Special case:
1885 * If a new destination address is specified for a point-to-point
--- 915 unchanged lines hidden ---
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 47 unchanged lines hidden (view full) ---
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)in.c 8.2 (Berkeley) 11/15/93
61 */
62
63#include <sys/cdefs.h>
64__FBSDID("$FreeBSD: head/sys/netinet6/in6.c 241686 2012-10-18 13:57:24Z andre $");
65
66#include "opt_compat.h"
67#include "opt_inet.h"
68#include "opt_inet6.h"
69
70#include <sys/param.h>
71#include <sys/errno.h>
72#include <sys/jail.h>
--- 917 unchanged lines hidden (view full) ---
990cleanup:
991 return (error);
992}
993
994/*
995 * Update parameters of an IPv6 interface address.
996 * If necessary, a new entry is created and linked into address chains.
997 * This function is separated from in6_control().
998 */
999int
1000in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
1001 struct in6_ifaddr *ia, int flags)
1002{
1003 int error = 0, hostIsNew = 0, plen = -1;
1004 struct sockaddr_in6 dst6;
1005 struct in6_addrlifetime *lt;
--- 510 unchanged lines hidden (view full) ---
1516 }
1517
1518 in6_unlink_ifa(ia, ifp);
1519}
1520
1521static void
1522in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp)
1523{
1524
1525 IF_ADDR_WLOCK(ifp);
1526 TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link);
1527 IF_ADDR_WUNLOCK(ifp);
1528 ifa_free(&ia->ia_ifa); /* if_addrhead */
1529
1530 /*
1531 * Defer the release of what might be the last reference to the
--- 21 unchanged lines hidden (view full) ---
1553 * Also, if the address being removed is autoconf'ed, call
1554 * pfxlist_onlink_check() since the release might affect the status of
1555 * other (detached) addresses.
1556 */
1557 if ((ia->ia6_flags & IN6_IFF_AUTOCONF)) {
1558 pfxlist_onlink_check();
1559 }
1560 ifa_free(&ia->ia_ifa); /* in6_ifaddrhead */
1561}
1562
1563void
1564in6_purgeif(struct ifnet *ifp)
1565{
1566 struct ifaddr *ifa, *nifa;
1567
1568 TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, nifa) {
--- 279 unchanged lines hidden (view full) ---
1848/*
1849 * Initialize an interface's IPv6 address and routing table entry.
1850 */
1851static int
1852in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia,
1853 struct sockaddr_in6 *sin6, int newhost)
1854{
1855 int error = 0, plen, ifacount = 0;
1856 struct ifaddr *ifa;
1857
1858 /*
1859 * Give the interface a chance to initialize
1860 * if this is its first address,
1861 * and to validate the address if necessary.
1862 */
1863 IF_ADDR_RLOCK(ifp);
1864 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
1865 if (ifa->ifa_addr->sa_family != AF_INET6)
1866 continue;
1867 ifacount++;
1868 }
1869 IF_ADDR_RUNLOCK(ifp);
1870
1871 ia->ia_addr = *sin6;
1872
1873 if (ifacount <= 1 && ifp->if_ioctl) {
1874 error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia);
1875 if (error)
1876 return (error);
1877 }
1878
1879 ia->ia_ifa.ifa_metric = ifp->if_metric;
1880
1881 /* we could do in(6)_socktrim here, but just omit it at this moment. */
1882
1883 /*
1884 * Special case:
1885 * If a new destination address is specified for a point-to-point
--- 915 unchanged lines hidden ---