nd6.c (287789) | nd6.c (287798) |
---|---|
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.c,v 1.144 2001/05/24 07:44:00 itojun 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.c,v 1.144 2001/05/24 07:44:00 itojun Exp $ 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/netinet6/nd6.c 287789 2015-09-14 16:48:19Z melifaro $"); | 33__FBSDID("$FreeBSD: head/sys/netinet6/nd6.c 287798 2015-09-14 19:17:25Z vangyzen $"); |
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/callout.h> 41#include <sys/malloc.h> --- 85 unchanged lines hidden (view full) --- 127int (*send_sendso_input_hook)(struct mbuf *, struct ifnet *, int, int); 128 129static int nd6_is_new_addr_neighbor(struct sockaddr_in6 *, 130 struct ifnet *); 131static void nd6_setmtu0(struct ifnet *, struct nd_ifinfo *); 132static void nd6_slowtimo(void *); 133static int regen_tmpaddr(struct in6_ifaddr *); 134static struct llentry *nd6_free(struct llentry *, int); | 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/callout.h> 41#include <sys/malloc.h> --- 85 unchanged lines hidden (view full) --- 127int (*send_sendso_input_hook)(struct mbuf *, struct ifnet *, int, int); 128 129static int nd6_is_new_addr_neighbor(struct sockaddr_in6 *, 130 struct ifnet *); 131static void nd6_setmtu0(struct ifnet *, struct nd_ifinfo *); 132static void nd6_slowtimo(void *); 133static int regen_tmpaddr(struct in6_ifaddr *); 134static struct llentry *nd6_free(struct llentry *, int); |
135static void nd6_free_redirect(const struct llentry *); |
|
135static void nd6_llinfo_timer(void *); 136static void clear_llinfo_pqueue(struct llentry *); 137static void nd6_rtrequest(int, struct rtentry *, struct rt_addrinfo *); 138static int nd6_output_lle(struct ifnet *, struct ifnet *, struct mbuf *, 139 struct sockaddr_in6 *); 140static int nd6_output_ifp(struct ifnet *, struct ifnet *, struct mbuf *, 141 struct sockaddr_in6 *); 142 --- 1075 unchanged lines hidden (view full) --- 1218 pfxlist_onlink_check(); 1219 1220 /* 1221 * Refresh default router list. 1222 */ 1223 defrouter_select(); 1224 } 1225 | 136static void nd6_llinfo_timer(void *); 137static void clear_llinfo_pqueue(struct llentry *); 138static void nd6_rtrequest(int, struct rtentry *, struct rt_addrinfo *); 139static int nd6_output_lle(struct ifnet *, struct ifnet *, struct mbuf *, 140 struct sockaddr_in6 *); 141static int nd6_output_ifp(struct ifnet *, struct ifnet *, struct mbuf *, 142 struct sockaddr_in6 *); 143 --- 1075 unchanged lines hidden (view full) --- 1219 pfxlist_onlink_check(); 1220 1221 /* 1222 * Refresh default router list. 1223 */ 1224 defrouter_select(); 1225 } 1226 |
1227 /* 1228 * If this entry was added by an on-link redirect, remove the 1229 * corresponding host route. 1230 */ 1231 if (ln->la_flags & LLE_REDIRECT) 1232 nd6_free_redirect(ln); 1233 |
|
1226 if (ln->ln_router || dr) 1227 LLE_WLOCK(ln); 1228 } 1229 1230 /* 1231 * Before deleting the entry, remember the next entry as the 1232 * return value. We need this because pfxlist_onlink_check() above 1233 * might have freed other entries (particularly the old next entry) as --- 17 unchanged lines hidden (view full) --- 1251 LLE_FREE_LOCKED(ln); 1252 1253 IF_AFDATA_UNLOCK(ifp); 1254 1255 return (next); 1256} 1257 1258/* | 1234 if (ln->ln_router || dr) 1235 LLE_WLOCK(ln); 1236 } 1237 1238 /* 1239 * Before deleting the entry, remember the next entry as the 1240 * return value. We need this because pfxlist_onlink_check() above 1241 * might have freed other entries (particularly the old next entry) as --- 17 unchanged lines hidden (view full) --- 1259 LLE_FREE_LOCKED(ln); 1260 1261 IF_AFDATA_UNLOCK(ifp); 1262 1263 return (next); 1264} 1265 1266/* |
1267 * Remove the rtentry for the given llentry, 1268 * both of which were installed by a redirect. 1269 */ 1270static void 1271nd6_free_redirect(const struct llentry *ln) 1272{ 1273 int fibnum; 1274 struct rtentry *rt; 1275 struct radix_node_head *rnh; 1276 struct sockaddr_in6 sin6; 1277 1278 lltable_fill_sa_entry(ln, (struct sockaddr *)&sin6); 1279 for (fibnum = 0; fibnum < rt_numfibs; fibnum++) { 1280 rnh = rt_tables_get_rnh(fibnum, AF_INET6); 1281 if (rnh == NULL) 1282 continue; 1283 1284 RADIX_NODE_HEAD_LOCK(rnh); 1285 rt = in6_rtalloc1((struct sockaddr *)&sin6, 0, 1286 RTF_RNH_LOCKED, fibnum); 1287 if (rt) { 1288 if (rt->rt_flags == (RTF_UP | RTF_HOST | RTF_DYNAMIC)) 1289 rt_expunge(rnh, rt); 1290 RTFREE_LOCKED(rt); 1291 } 1292 RADIX_NODE_HEAD_UNLOCK(rnh); 1293 } 1294} 1295 1296/* |
|
1259 * Upper-layer reachability hint for Neighbor Unreachability Detection. 1260 * 1261 * XXX cost-effective methods? 1262 */ 1263void 1264nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force) 1265{ 1266 struct llentry *ln; --- 474 unchanged lines hidden (view full) --- 1741 case ND_REDIRECT: 1742 /* 1743 * If the icmp is a redirect to a better router, always set the 1744 * is_router flag. Otherwise, if the entry is newly created, 1745 * clear the flag. [RFC 2461, sec 8.3] 1746 */ 1747 if (code == ND_REDIRECT_ROUTER) 1748 ln->ln_router = 1; | 1297 * Upper-layer reachability hint for Neighbor Unreachability Detection. 1298 * 1299 * XXX cost-effective methods? 1300 */ 1301void 1302nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force) 1303{ 1304 struct llentry *ln; --- 474 unchanged lines hidden (view full) --- 1779 case ND_REDIRECT: 1780 /* 1781 * If the icmp is a redirect to a better router, always set the 1782 * is_router flag. Otherwise, if the entry is newly created, 1783 * clear the flag. [RFC 2461, sec 8.3] 1784 */ 1785 if (code == ND_REDIRECT_ROUTER) 1786 ln->ln_router = 1; |
1749 else if (is_newentry) /* (6-7) */ 1750 ln->ln_router = 0; | 1787 else { 1788 if (is_newentry) /* (6-7) */ 1789 ln->ln_router = 0; 1790 ln->la_flags |= LLE_REDIRECT; 1791 } |
1751 break; 1752 case ND_ROUTER_SOLICIT: 1753 /* 1754 * is_router flag must always be cleared. 1755 */ 1756 ln->ln_router = 0; 1757 break; 1758 case ND_ROUTER_ADVERT: --- 696 unchanged lines hidden --- | 1792 break; 1793 case ND_ROUTER_SOLICIT: 1794 /* 1795 * is_router flag must always be cleared. 1796 */ 1797 ln->ln_router = 0; 1798 break; 1799 case ND_ROUTER_ADVERT: --- 696 unchanged lines hidden --- |