if_ether.c (109996) | if_ether.c (110308) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)if_ether.c 8.1 (Berkeley) 6/10/93 | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)if_ether.c 8.1 (Berkeley) 6/10/93 |
34 * $FreeBSD: head/sys/netinet/if_ether.c 109996 2003-01-28 20:22:19Z hsu $ | 34 * $FreeBSD: head/sys/netinet/if_ether.c 110308 2003-02-04 05:28:08Z orion $ |
35 */ 36 37/* 38 * Ethernet address resolution protocol. 39 * TODO: 40 * add "inuse/lock" bit (or ref. count) along with valid bit 41 */ 42 --- 48 unchanged lines hidden (view full) --- 91SYSCTL_INT(_net_link_ether_inet, OID_AUTO, host_down_time, CTLFLAG_RW, 92 &arpt_down, 0, ""); 93 94#define rt_expire rt_rmx.rmx_expire 95 96struct llinfo_arp { 97 LIST_ENTRY(llinfo_arp) la_le; 98 struct rtentry *la_rt; | 35 */ 36 37/* 38 * Ethernet address resolution protocol. 39 * TODO: 40 * add "inuse/lock" bit (or ref. count) along with valid bit 41 */ 42 --- 48 unchanged lines hidden (view full) --- 91SYSCTL_INT(_net_link_ether_inet, OID_AUTO, host_down_time, CTLFLAG_RW, 92 &arpt_down, 0, ""); 93 94#define rt_expire rt_rmx.rmx_expire 95 96struct llinfo_arp { 97 LIST_ENTRY(llinfo_arp) la_le; 98 struct rtentry *la_rt; |
99 struct mbuf *la_hold; /* last packet until resolved/timeout */ 100 long la_asked; /* last time we QUERIED for this addr */ | 99 struct mbuf *la_hold; /* last packet until resolved/timeout */ 100 u_short la_preempt; /* #times we QUERIED before entry expiration */ 101 u_short la_asked; /* #times we QUERIED following expiration */ |
101#define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */ 102}; 103 104static LIST_HEAD(, llinfo_arp) llinfo_arp; 105 106struct ifqueue arpintrq; 107static int arp_inuse, arp_allocated, arpinit_done; 108 --- 327 unchanged lines hidden (view full) --- 436 if ((rt->rt_expire == 0 || rt->rt_expire > time_second) && 437 sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { 438 /* 439 * If entry has an expiry time and it is approaching, 440 * see if we need to send an ARP request within this 441 * arpt_down interval. 442 */ 443 if ((rt->rt_expire != 0) && | 102#define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */ 103}; 104 105static LIST_HEAD(, llinfo_arp) llinfo_arp; 106 107struct ifqueue arpintrq; 108static int arp_inuse, arp_allocated, arpinit_done; 109 --- 327 unchanged lines hidden (view full) --- 437 if ((rt->rt_expire == 0 || rt->rt_expire > time_second) && 438 sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { 439 /* 440 * If entry has an expiry time and it is approaching, 441 * see if we need to send an ARP request within this 442 * arpt_down interval. 443 */ 444 if ((rt->rt_expire != 0) && |
444 (time_second + (arp_maxtries - la->la_asked) * arpt_down > 445 rt->rt_expire)) { | 445 (time_second + (arp_maxtries - la->la_preempt) * arpt_down 446 > rt->rt_expire)) { |
446 arprequest(ifp, 447 &SIN(rt->rt_ifa->ifa_addr)->sin_addr, 448 &SIN(dst)->sin_addr, 449 IF_LLADDR(ifp)); | 447 arprequest(ifp, 448 &SIN(rt->rt_ifa->ifa_addr)->sin_addr, 449 &SIN(dst)->sin_addr, 450 IF_LLADDR(ifp)); |
450 la->la_asked++; | 451 la->la_preempt++; |
451 } 452 453 bcopy(LLADDR(sdl), desten, sdl->sdl_alen); 454 return 1; 455 } 456 /* 457 * If ARP is disabled on this interface, stop. 458 * XXX --- 11 unchanged lines hidden (view full) --- 470 */ 471 if (la->la_hold) 472 m_freem(la->la_hold); 473 la->la_hold = m; 474 if (rt->rt_expire) { 475 rt->rt_flags &= ~RTF_REJECT; 476 if (la->la_asked == 0 || rt->rt_expire != time_second) { 477 rt->rt_expire = time_second; | 452 } 453 454 bcopy(LLADDR(sdl), desten, sdl->sdl_alen); 455 return 1; 456 } 457 /* 458 * If ARP is disabled on this interface, stop. 459 * XXX --- 11 unchanged lines hidden (view full) --- 471 */ 472 if (la->la_hold) 473 m_freem(la->la_hold); 474 la->la_hold = m; 475 if (rt->rt_expire) { 476 rt->rt_flags &= ~RTF_REJECT; 477 if (la->la_asked == 0 || rt->rt_expire != time_second) { 478 rt->rt_expire = time_second; |
478 if (la->la_asked++ < arp_maxtries) 479 arprequest(ifp, 480 &SIN(rt->rt_ifa->ifa_addr)->sin_addr, 481 &SIN(dst)->sin_addr, 482 IF_LLADDR(ifp)); 483 else { | 479 if (la->la_asked++ < arp_maxtries) { 480 arprequest(ifp, 481 &SIN(rt->rt_ifa->ifa_addr)->sin_addr, 482 &SIN(dst)->sin_addr, 483 IF_LLADDR(ifp)); 484 } else { |
484 rt->rt_flags |= RTF_REJECT; 485 rt->rt_expire += arpt_down; | 485 rt->rt_flags |= RTF_REJECT; 486 rt->rt_expire += arpt_down; |
486 la->la_asked = 0; | 487 la->la_preempt = la->la_asked = 0; |
487 } 488 489 } 490 } 491 return (0); 492} 493 494/* --- 244 unchanged lines hidden (view full) --- 739 m->m_data -= 8; 740 m->m_len += 8; 741 m->m_pkthdr.len += 8; 742 th->rcf = trld->trld_rcf; 743 } 744 if (rt->rt_expire) 745 rt->rt_expire = time_second + arpt_keep; 746 rt->rt_flags &= ~RTF_REJECT; | 488 } 489 490 } 491 } 492 return (0); 493} 494 495/* --- 244 unchanged lines hidden (view full) --- 740 m->m_data -= 8; 741 m->m_len += 8; 742 m->m_pkthdr.len += 8; 743 th->rcf = trld->trld_rcf; 744 } 745 if (rt->rt_expire) 746 rt->rt_expire = time_second + arpt_keep; 747 rt->rt_flags &= ~RTF_REJECT; |
747 la->la_asked = 0; | 748 la->la_preempt = la->la_asked = 0; |
748 if (la->la_hold) { 749 (*ifp->if_output)(ifp, la->la_hold, 750 rt_key(rt), rt); 751 la->la_hold = 0; 752 } 753 } 754reply: 755 if (op != ARPOP_REQUEST) { --- 133 unchanged lines hidden (view full) --- 889{ 890 register struct rtentry *rt = la->la_rt; 891 register struct sockaddr_dl *sdl; 892 if (rt == 0) 893 panic("arptfree"); 894 if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) && 895 sdl->sdl_family == AF_LINK) { 896 sdl->sdl_alen = 0; | 749 if (la->la_hold) { 750 (*ifp->if_output)(ifp, la->la_hold, 751 rt_key(rt), rt); 752 la->la_hold = 0; 753 } 754 } 755reply: 756 if (op != ARPOP_REQUEST) { --- 133 unchanged lines hidden (view full) --- 890{ 891 register struct rtentry *rt = la->la_rt; 892 register struct sockaddr_dl *sdl; 893 if (rt == 0) 894 panic("arptfree"); 895 if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) && 896 sdl->sdl_family == AF_LINK) { 897 sdl->sdl_alen = 0; |
897 la->la_asked = 0; | 898 la->la_preempt = la->la_asked = 0; |
898 rt->rt_flags &= ~RTF_REJECT; 899 return; 900 } 901 rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt), 902 0, (struct rtentry **)0); 903} 904/* 905 * Lookup or enter a new address in arptab. --- 57 unchanged lines hidden --- | 899 rt->rt_flags &= ~RTF_REJECT; 900 return; 901 } 902 rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt), 903 0, (struct rtentry **)0); 904} 905/* 906 * Lookup or enter a new address in arptab. --- 57 unchanged lines hidden --- |