in6.c (227460) | in6.c (228571) |
---|---|
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 227460 2011-11-11 23:22:38Z qingli $"); | 64__FBSDID("$FreeBSD: head/sys/netinet6/in6.c 228571 2011-12-16 12:16:56Z glebius $"); |
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> --- 17 unchanged lines hidden (view full) --- 90 91#include <netinet/in.h> 92#include <netinet/in_var.h> 93#include <net/if_llatbl.h> 94#include <netinet/if_ether.h> 95#include <netinet/in_systm.h> 96#include <netinet/ip.h> 97#include <netinet/in_pcb.h> | 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> --- 17 unchanged lines hidden (view full) --- 90 91#include <netinet/in.h> 92#include <netinet/in_var.h> 93#include <net/if_llatbl.h> 94#include <netinet/if_ether.h> 95#include <netinet/in_systm.h> 96#include <netinet/ip.h> 97#include <netinet/in_pcb.h> |
98#include <netinet/ip_carp.h> |
|
98 99#include <netinet/ip6.h> 100#include <netinet6/ip6_var.h> 101#include <netinet6/nd6.h> 102#include <netinet6/mld6_var.h> 103#include <netinet6/ip6_mroute.h> 104#include <netinet6/in6_ifattach.h> 105#include <netinet6/scope6_var.h> --- 161 unchanged lines hidden (view full) --- 267int 268in6_control(struct socket *so, u_long cmd, caddr_t data, 269 struct ifnet *ifp, struct thread *td) 270{ 271 struct in6_ifreq *ifr = (struct in6_ifreq *)data; 272 struct in6_ifaddr *ia = NULL; 273 struct in6_aliasreq *ifra = (struct in6_aliasreq *)data; 274 struct sockaddr_in6 *sa6; | 99 100#include <netinet/ip6.h> 101#include <netinet6/ip6_var.h> 102#include <netinet6/nd6.h> 103#include <netinet6/mld6_var.h> 104#include <netinet6/ip6_mroute.h> 105#include <netinet6/in6_ifattach.h> 106#include <netinet6/scope6_var.h> --- 161 unchanged lines hidden (view full) --- 268int 269in6_control(struct socket *so, u_long cmd, caddr_t data, 270 struct ifnet *ifp, struct thread *td) 271{ 272 struct in6_ifreq *ifr = (struct in6_ifreq *)data; 273 struct in6_ifaddr *ia = NULL; 274 struct in6_aliasreq *ifra = (struct in6_aliasreq *)data; 275 struct sockaddr_in6 *sa6; |
276 int carp_attached = 0; |
|
275 int error; 276 277 switch (cmd) { 278 case SIOCGETSGCNT_IN6: 279 case SIOCGETMIFCNT_IN6: 280 return (mrt6_ioctl ? mrt6_ioctl(cmd, data) : EOPNOTSUPP); 281 } 282 --- 364 unchanged lines hidden (view full) --- 647 == NULL) { 648 /* 649 * this can happen when the user specify the 0 valid 650 * lifetime. 651 */ 652 break; 653 } 654 | 277 int error; 278 279 switch (cmd) { 280 case SIOCGETSGCNT_IN6: 281 case SIOCGETMIFCNT_IN6: 282 return (mrt6_ioctl ? mrt6_ioctl(cmd, data) : EOPNOTSUPP); 283 } 284 --- 364 unchanged lines hidden (view full) --- 649 == NULL) { 650 /* 651 * this can happen when the user specify the 0 valid 652 * lifetime. 653 */ 654 break; 655 } 656 |
657 if (ifra->ifra_vhid > 0) { 658 if (carp_attach_p != NULL) 659 error = (*carp_attach_p)(&ia->ia_ifa, 660 ifra->ifra_vhid); 661 else 662 error = EPROTONOSUPPORT; 663 if (error) 664 goto out; 665 else 666 carp_attached = 1; 667 } 668 |
|
655 /* 656 * then, make the prefix on-link on the interface. 657 * XXX: we'd rather create the prefix before the address, but 658 * we need at least one address to install the corresponding 659 * interface route, so we configure the address first. 660 */ 661 662 /* --- 27 unchanged lines hidden (view full) --- 690 pr0.ndpr_pltime = ifra->ifra_lifetime.ia6t_pltime; 691 692 /* add the prefix if not yet. */ 693 if ((pr = nd6_prefix_lookup(&pr0)) == NULL) { 694 /* 695 * nd6_prelist_add will install the corresponding 696 * interface route. 697 */ | 669 /* 670 * then, make the prefix on-link on the interface. 671 * XXX: we'd rather create the prefix before the address, but 672 * we need at least one address to install the corresponding 673 * interface route, so we configure the address first. 674 */ 675 676 /* --- 27 unchanged lines hidden (view full) --- 704 pr0.ndpr_pltime = ifra->ifra_lifetime.ia6t_pltime; 705 706 /* add the prefix if not yet. */ 707 if ((pr = nd6_prefix_lookup(&pr0)) == NULL) { 708 /* 709 * nd6_prelist_add will install the corresponding 710 * interface route. 711 */ |
698 if ((error = nd6_prelist_add(&pr0, NULL, &pr)) != 0) | 712 if ((error = nd6_prelist_add(&pr0, NULL, &pr)) != 0) { 713 if (carp_attached) 714 (*carp_detach_p)(&ia->ia_ifa); |
699 goto out; | 715 goto out; |
716 } |
|
700 if (pr == NULL) { | 717 if (pr == NULL) { |
718 if (carp_attached) 719 (*carp_detach_p)(&ia->ia_ifa); |
|
701 log(LOG_ERR, "nd6_prelist_add succeeded but " 702 "no prefix\n"); 703 error = EINVAL; 704 goto out; 705 } 706 } 707 708 /* relate the address to the prefix */ --- 587 unchanged lines hidden (view full) --- 1296 struct ifnet *ifp = ifa->ifa_ifp; 1297 struct in6_ifaddr *ia = (struct in6_ifaddr *) ifa; 1298 struct in6_multi_mship *imm; 1299 struct sockaddr_in6 mltaddr, mltmask; 1300 int plen, error; 1301 struct rtentry *rt; 1302 struct ifaddr *ifa0, *nifa; 1303 | 720 log(LOG_ERR, "nd6_prelist_add succeeded but " 721 "no prefix\n"); 722 error = EINVAL; 723 goto out; 724 } 725 } 726 727 /* relate the address to the prefix */ --- 587 unchanged lines hidden (view full) --- 1315 struct ifnet *ifp = ifa->ifa_ifp; 1316 struct in6_ifaddr *ia = (struct in6_ifaddr *) ifa; 1317 struct in6_multi_mship *imm; 1318 struct sockaddr_in6 mltaddr, mltmask; 1319 int plen, error; 1320 struct rtentry *rt; 1321 struct ifaddr *ifa0, *nifa; 1322 |
1323 if (ifa->ifa_carp) 1324 (*carp_detach_p)(ifa); 1325 |
|
1304 /* 1305 * find another IPv6 address as the gateway for the 1306 * link-local and node-local all-nodes multicast 1307 * address routes 1308 */ 1309 IF_ADDR_LOCK(ifp); 1310 TAILQ_FOREACH_SAFE(ifa0, &ifp->if_addrhead, ifa_link, nifa) { 1311 if ((ifa0->ifa_addr->sa_family != AF_INET6) || --- 1452 unchanged lines hidden --- | 1326 /* 1327 * find another IPv6 address as the gateway for the 1328 * link-local and node-local all-nodes multicast 1329 * address routes 1330 */ 1331 IF_ADDR_LOCK(ifp); 1332 TAILQ_FOREACH_SAFE(ifa0, &ifp->if_addrhead, ifa_link, nifa) { 1333 if ((ifa0->ifa_addr->sa_family != AF_INET6) || --- 1452 unchanged lines hidden --- |