in_rmx.c (122708) | in_rmx.c (122921) |
---|---|
1/* 2 * Copyright 1994, 1995 Massachusetts Institute of Technology 3 * 4 * Permission to use, copy, modify, and distribute this software and 5 * its documentation for any purpose and without fee is hereby 6 * granted, provided that both the above copyright notice and this 7 * permission notice appear in all copies, that both the above 8 * copyright notice and this permission notice appear in all --- 12 unchanged lines hidden (view full) --- 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/* 2 * Copyright 1994, 1995 Massachusetts Institute of Technology 3 * 4 * Permission to use, copy, modify, and distribute this software and 5 * its documentation for any purpose and without fee is hereby 6 * granted, provided that both the above copyright notice and this 7 * permission notice appear in all copies, that both the above 8 * copyright notice and this permission notice appear in all --- 12 unchanged lines hidden (view full) --- 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/netinet/in_rmx.c 122708 2003-11-14 21:48:57Z andre $ | 29 * $FreeBSD: head/sys/netinet/in_rmx.c 122921 2003-11-20 19:47:31Z andre $ |
30 */ 31 32/* 33 * This code does two things necessary for the enhanced TCP metrics to 34 * function in a useful manner: 35 * 1) It marks all non-host routes as `cloning', thus ensuring that 36 * every actual reference to such a route actually gets turned 37 * into a reference to a host route to the specific destination --- 30 unchanged lines hidden (view full) --- 68in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, 69 struct radix_node *treenodes) 70{ 71 struct rtentry *rt = (struct rtentry *)treenodes; 72 struct sockaddr_in *sin = (struct sockaddr_in *)rt_key(rt); 73 struct radix_node *ret; 74 75 /* | 30 */ 31 32/* 33 * This code does two things necessary for the enhanced TCP metrics to 34 * function in a useful manner: 35 * 1) It marks all non-host routes as `cloning', thus ensuring that 36 * every actual reference to such a route actually gets turned 37 * into a reference to a host route to the specific destination --- 30 unchanged lines hidden (view full) --- 68in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, 69 struct radix_node *treenodes) 70{ 71 struct rtentry *rt = (struct rtentry *)treenodes; 72 struct sockaddr_in *sin = (struct sockaddr_in *)rt_key(rt); 73 struct radix_node *ret; 74 75 /* |
76 * For IP, all unicast non-host routes are automatically cloning. 77 */ 78 if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 79 rt->rt_flags |= RTF_MULTICAST; 80 81 if (!(rt->rt_flags & (RTF_HOST | RTF_CLONING | RTF_MULTICAST))) 82 rt->rt_flags |= RTF_PRCLONING; 83 84 /* | |
85 * A little bit of help for both IP output and input: 86 * For host routes, we make sure that RTF_BROADCAST 87 * is set for anything that looks like a broadcast address. 88 * This way, we can avoid an expensive call to in_broadcast() 89 * in ip_output() most of the time (because the route passed 90 * to ip_output() is almost always a host route). 91 * 92 * We also do the same for local addresses, with the thought 93 * that this might one day be used to speed up ip_input(). 94 * 95 * We also mark routes to multicast addresses as such, because 96 * it's easy to do and might be useful (but this is much more | 76 * A little bit of help for both IP output and input: 77 * For host routes, we make sure that RTF_BROADCAST 78 * is set for anything that looks like a broadcast address. 79 * This way, we can avoid an expensive call to in_broadcast() 80 * in ip_output() most of the time (because the route passed 81 * to ip_output() is almost always a host route). 82 * 83 * We also do the same for local addresses, with the thought 84 * that this might one day be used to speed up ip_input(). 85 * 86 * We also mark routes to multicast addresses as such, because 87 * it's easy to do and might be useful (but this is much more |
97 * dubious since it's so easy to inspect the address). (This 98 * is done above.) | 88 * dubious since it's so easy to inspect the address). |
99 */ 100 if (rt->rt_flags & RTF_HOST) { 101 if (in_broadcast(sin->sin_addr, rt->rt_ifp)) { 102 rt->rt_flags |= RTF_BROADCAST; 103 } else if (satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr == 104 sin->sin_addr.s_addr) { 105 rt->rt_flags |= RTF_LOCAL; 106 } 107 } | 89 */ 90 if (rt->rt_flags & RTF_HOST) { 91 if (in_broadcast(sin->sin_addr, rt->rt_ifp)) { 92 rt->rt_flags |= RTF_BROADCAST; 93 } else if (satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr == 94 sin->sin_addr.s_addr) { 95 rt->rt_flags |= RTF_LOCAL; 96 } 97 } |
98 if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 99 rt->rt_flags |= RTF_MULTICAST; |
|
108 109 if (!rt->rt_rmx.rmx_mtu && !(rt->rt_rmx.rmx_locks & RTV_MTU) && 110 rt->rt_ifp) 111 rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; 112 113 ret = rn_addroute(v_arg, n_arg, head, treenodes); 114 if (ret == NULL && rt->rt_flags & RTF_HOST) { 115 struct rtentry *rt2; 116 /* 117 * We are trying to add a host route, but can't. 118 * Find out if it is because of an 119 * ARP entry and delete it if so. 120 */ | 100 101 if (!rt->rt_rmx.rmx_mtu && !(rt->rt_rmx.rmx_locks & RTV_MTU) && 102 rt->rt_ifp) 103 rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; 104 105 ret = rn_addroute(v_arg, n_arg, head, treenodes); 106 if (ret == NULL && rt->rt_flags & RTF_HOST) { 107 struct rtentry *rt2; 108 /* 109 * We are trying to add a host route, but can't. 110 * Find out if it is because of an 111 * ARP entry and delete it if so. 112 */ |
121 rt2 = rtalloc1((struct sockaddr *)sin, 0, 122 RTF_CLONING | RTF_PRCLONING); | 113 rt2 = rtalloc1((struct sockaddr *)sin, 0, RTF_CLONING); |
123 if (rt2) { 124 if (rt2->rt_flags & RTF_LLINFO && 125 rt2->rt_flags & RTF_HOST && 126 rt2->rt_gateway && 127 rt2->rt_gateway->sa_family == AF_LINK) { 128 rtexpunge(rt2); 129 RTFREE_LOCKED(rt2); 130 ret = rn_addroute(v_arg, n_arg, head, --- 243 unchanged lines hidden (view full) --- 374 /* 375 * We need to disable the automatic prune that happens 376 * in this case in rtrequest() because it will blow 377 * away the pointers that rn_walktree() needs in order 378 * continue our descent. We will end up deleting all 379 * the routes that rtrequest() would have in any case, 380 * so that behavior is not needed there. 381 */ | 114 if (rt2) { 115 if (rt2->rt_flags & RTF_LLINFO && 116 rt2->rt_flags & RTF_HOST && 117 rt2->rt_gateway && 118 rt2->rt_gateway->sa_family == AF_LINK) { 119 rtexpunge(rt2); 120 RTFREE_LOCKED(rt2); 121 ret = rn_addroute(v_arg, n_arg, head, --- 243 unchanged lines hidden (view full) --- 365 /* 366 * We need to disable the automatic prune that happens 367 * in this case in rtrequest() because it will blow 368 * away the pointers that rn_walktree() needs in order 369 * continue our descent. We will end up deleting all 370 * the routes that rtrequest() would have in any case, 371 * so that behavior is not needed there. 372 */ |
382 rt->rt_flags &= ~(RTF_CLONING | RTF_PRCLONING); | 373 rt->rt_flags &= ~RTF_CLONING; |
383 rtexpunge(rt); 384 } 385 RT_UNLOCK(rt); 386 return 0; 387} 388 389int 390in_ifadown(struct ifaddr *ifa, int delete) --- 16 unchanged lines hidden --- | 374 rtexpunge(rt); 375 } 376 RT_UNLOCK(rt); 377 return 0; 378} 379 380int 381in_ifadown(struct ifaddr *ifa, int delete) --- 16 unchanged lines hidden --- |