nd6_rtr.c (196649) | nd6_rtr.c (197138) |
---|---|
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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $KAME: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $ 30 */ 31 32#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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $KAME: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $ 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/netinet6/nd6_rtr.c 196649 2009-08-30 02:07:23Z qingli $"); | 33__FBSDID("$FreeBSD: head/sys/netinet6/nd6_rtr.c 197138 2009-09-12 22:08:20Z hrs $"); |
34 35#include "opt_inet.h" 36#include "opt_inet6.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/malloc.h> 41#include <sys/mbuf.h> --- 79 unchanged lines hidden (view full) --- 121 struct nd_router_solicit *nd_rs; 122 struct in6_addr saddr6 = ip6->ip6_src; 123 char *lladdr = NULL; 124 int lladdrlen = 0; 125 union nd_opts ndopts; 126 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; 127 128 /* If I'm not a router, ignore it. */ | 34 35#include "opt_inet.h" 36#include "opt_inet6.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/malloc.h> 41#include <sys/mbuf.h> --- 79 unchanged lines hidden (view full) --- 121 struct nd_router_solicit *nd_rs; 122 struct in6_addr saddr6 = ip6->ip6_src; 123 char *lladdr = NULL; 124 int lladdrlen = 0; 125 union nd_opts ndopts; 126 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; 127 128 /* If I'm not a router, ignore it. */ |
129 if (V_ip6_accept_rtadv != 0 || V_ip6_forwarding != 1) | 129 if (!V_ip6_forwarding) |
130 goto freeit; 131 132 /* Sanity checks */ 133 if (ip6->ip6_hlim != 255) { 134 nd6log((LOG_ERR, 135 "nd6_rs_input: invalid hlim (%d) from %s to %s on %s\n", 136 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src), 137 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp))); --- 69 unchanged lines hidden (view full) --- 207 struct in6_addr saddr6 = ip6->ip6_src; 208 int mcast = 0; 209 union nd_opts ndopts; 210 struct nd_defrouter *dr; 211 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; 212 213 /* 214 * We only accept RAs only when | 130 goto freeit; 131 132 /* Sanity checks */ 133 if (ip6->ip6_hlim != 255) { 134 nd6log((LOG_ERR, 135 "nd6_rs_input: invalid hlim (%d) from %s to %s on %s\n", 136 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src), 137 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp))); --- 69 unchanged lines hidden (view full) --- 207 struct in6_addr saddr6 = ip6->ip6_src; 208 int mcast = 0; 209 union nd_opts ndopts; 210 struct nd_defrouter *dr; 211 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; 212 213 /* 214 * We only accept RAs only when |
215 * the system-wide variable allows the acceptance, and | 215 * the node is not a router and |
216 * per-interface variable allows RAs on the receiving interface. 217 */ | 216 * per-interface variable allows RAs on the receiving interface. 217 */ |
218 if (V_ip6_accept_rtadv == 0) | 218 if (V_ip6_forwarding || !(ndi->flags & ND6_IFF_ACCEPT_RTADV)) |
219 goto freeit; | 219 goto freeit; |
220 if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV)) 221 goto freeit; | |
222 223 if (ip6->ip6_hlim != 255) { 224 nd6log((LOG_ERR, 225 "nd6_ra_input: invalid hlim (%d) from %s to %s on %s\n", 226 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src), 227 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp))); 228 goto bad; 229 } --- 322 unchanged lines hidden (view full) --- 552{ 553 struct nd_defrouter *deldr = NULL; 554 struct nd_prefix *pr; 555 556 /* 557 * Flush all the routing table entries that use the router 558 * as a next hop. 559 */ | 220 221 if (ip6->ip6_hlim != 255) { 222 nd6log((LOG_ERR, 223 "nd6_ra_input: invalid hlim (%d) from %s to %s on %s\n", 224 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src), 225 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp))); 226 goto bad; 227 } --- 322 unchanged lines hidden (view full) --- 550{ 551 struct nd_defrouter *deldr = NULL; 552 struct nd_prefix *pr; 553 554 /* 555 * Flush all the routing table entries that use the router 556 * as a next hop. 557 */ |
560 if (!V_ip6_forwarding && V_ip6_accept_rtadv) /* XXX: better condition? */ | 558 if (!V_ip6_forwarding) |
561 rt6_flush(&dr->rtaddr, dr->ifp); 562 563 if (dr->installed) { 564 deldr = dr; 565 defrouter_delreq(dr); 566 } 567 TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); 568 --- 47 unchanged lines hidden (view full) --- 616 struct llentry *ln = NULL; 617 618 /* 619 * This function should be called only when acting as an autoconfigured 620 * host. Although the remaining part of this function is not effective 621 * if the node is not an autoconfigured host, we explicitly exclude 622 * such cases here for safety. 623 */ | 559 rt6_flush(&dr->rtaddr, dr->ifp); 560 561 if (dr->installed) { 562 deldr = dr; 563 defrouter_delreq(dr); 564 } 565 TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); 566 --- 47 unchanged lines hidden (view full) --- 614 struct llentry *ln = NULL; 615 616 /* 617 * This function should be called only when acting as an autoconfigured 618 * host. Although the remaining part of this function is not effective 619 * if the node is not an autoconfigured host, we explicitly exclude 620 * such cases here for safety. 621 */ |
624 if (V_ip6_forwarding || !V_ip6_accept_rtadv) { | 622 if (V_ip6_forwarding) { |
625 nd6log((LOG_WARNING, | 623 nd6log((LOG_WARNING, |
626 "defrouter_select: called unexpectedly (forwarding=%d, " 627 "accept_rtadv=%d)\n", V_ip6_forwarding, V_ip6_accept_rtadv)); | 624 "defrouter_select: called unexpectedly (forwarding=%d)\n", 625 V_ip6_forwarding)); |
628 splx(s); 629 return; 630 } 631 632 /* 633 * Let's handle easy case (3) first: 634 * If default router list is empty, there's nothing to be done. 635 */ --- 1523 unchanged lines hidden --- | 626 splx(s); 627 return; 628 } 629 630 /* 631 * Let's handle easy case (3) first: 632 * If default router list is empty, there's nothing to be done. 633 */ --- 1523 unchanged lines hidden --- |