in6.c (238990) | in6.c (241686) |
---|---|
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> | 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 238990 2012-08-02 13:57:49Z glebius $"); | 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(). | 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 * XXX: should this be performed under splnet()? | |
999 */ 1000int 1001in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, 1002 struct in6_ifaddr *ia, int flags) 1003{ 1004 int error = 0, hostIsNew = 0, plen = -1; 1005 struct sockaddr_in6 dst6; 1006 struct in6_addrlifetime *lt; --- 510 unchanged lines hidden (view full) --- 1517 } 1518 1519 in6_unlink_ifa(ia, ifp); 1520} 1521 1522static void 1523in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) 1524{ | 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{ |
1525 int s = splnet(); | |
1526 1527 IF_ADDR_WLOCK(ifp); 1528 TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); 1529 IF_ADDR_WUNLOCK(ifp); 1530 ifa_free(&ia->ia_ifa); /* if_addrhead */ 1531 1532 /* 1533 * Defer the release of what might be the last reference to the --- 21 unchanged lines hidden (view full) --- 1555 * Also, if the address being removed is autoconf'ed, call 1556 * pfxlist_onlink_check() since the release might affect the status of 1557 * other (detached) addresses. 1558 */ 1559 if ((ia->ia6_flags & IN6_IFF_AUTOCONF)) { 1560 pfxlist_onlink_check(); 1561 } 1562 ifa_free(&ia->ia_ifa); /* in6_ifaddrhead */ | 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 */ |
1563 splx(s); | |
1564} 1565 1566void 1567in6_purgeif(struct ifnet *ifp) 1568{ 1569 struct ifaddr *ifa, *nifa; 1570 1571 TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, nifa) { --- 279 unchanged lines hidden (view full) --- 1851/* 1852 * Initialize an interface's IPv6 address and routing table entry. 1853 */ 1854static int 1855in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia, 1856 struct sockaddr_in6 *sin6, int newhost) 1857{ 1858 int error = 0, plen, ifacount = 0; | 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; |
1859 int s = splimp(); | |
1860 struct ifaddr *ifa; 1861 1862 /* 1863 * Give the interface a chance to initialize 1864 * if this is its first address, 1865 * and to validate the address if necessary. 1866 */ 1867 IF_ADDR_RLOCK(ifp); 1868 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1869 if (ifa->ifa_addr->sa_family != AF_INET6) 1870 continue; 1871 ifacount++; 1872 } 1873 IF_ADDR_RUNLOCK(ifp); 1874 1875 ia->ia_addr = *sin6; 1876 1877 if (ifacount <= 1 && ifp->if_ioctl) { 1878 error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia); | 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); |
1879 if (error) { 1880 splx(s); | 1875 if (error) |
1881 return (error); | 1876 return (error); |
1882 } | |
1883 } | 1877 } |
1884 splx(s); | |
1885 1886 ia->ia_ifa.ifa_metric = ifp->if_metric; 1887 1888 /* we could do in(6)_socktrim here, but just omit it at this moment. */ 1889 1890 /* 1891 * Special case: 1892 * If a new destination address is specified for a point-to-point --- 915 unchanged lines hidden --- | 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 --- |