if_ether.c revision 128398
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1982, 1986, 1988, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * @(#)if_ether.c 8.1 (Berkeley) 6/10/93 3050477Speter * $FreeBSD: head/sys/netinet/if_ether.c 128398 2004-04-18 11:45:49Z luigi $ 311541Srgrimes */ 321541Srgrimes 331541Srgrimes/* 341541Srgrimes * Ethernet address resolution protocol. 351541Srgrimes * TODO: 361541Srgrimes * add "inuse/lock" bit (or ref. count) along with valid bit 371541Srgrimes */ 381541Srgrimes 3932350Seivind#include "opt_inet.h" 4041793Sluigi#include "opt_bdg.h" 41101090Srwatson#include "opt_mac.h" 4232350Seivind 431541Srgrimes#include <sys/param.h> 4412693Sphk#include <sys/kernel.h> 4544078Sdfr#include <sys/queue.h> 4612693Sphk#include <sys/sysctl.h> 471541Srgrimes#include <sys/systm.h> 48101090Srwatson#include <sys/mac.h> 4912693Sphk#include <sys/mbuf.h> 501541Srgrimes#include <sys/malloc.h> 5118892Sbde#include <sys/socket.h> 521541Srgrimes#include <sys/syslog.h> 531541Srgrimes 541541Srgrimes#include <net/if.h> 551541Srgrimes#include <net/if_dl.h> 5644165Sjulian#include <net/if_types.h> 571541Srgrimes#include <net/route.h> 588426Swollman#include <net/netisr.h> 5958313Slile#include <net/if_llc.h> 6071963Sjulian#ifdef BRIDGE 6171963Sjulian#include <net/ethernet.h> 6271963Sjulian#include <net/bridge.h> 6371963Sjulian#endif 641541Srgrimes 651541Srgrimes#include <netinet/in.h> 661541Srgrimes#include <netinet/in_var.h> 671541Srgrimes#include <netinet/if_ether.h> 681541Srgrimes 6984931Sfjoe#include <net/if_arc.h> 7044627Sjulian#include <net/iso88025.h> 7144627Sjulian 721541Srgrimes#define SIN(s) ((struct sockaddr_in *)s) 731541Srgrimes#define SDL(s) ((struct sockaddr_dl *)s) 741541Srgrimes 7544078SdfrSYSCTL_DECL(_net_link_ether); 7612942SwollmanSYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, ""); 771541Srgrimes 7812693Sphk/* timer values */ 7912942Swollmanstatic int arpt_prune = (5*60*1); /* walk list every 5 minutes */ 8012942Swollmanstatic int arpt_keep = (20*60); /* once resolved, good for 20 more minutes */ 8112942Swollmanstatic int arpt_down = 20; /* once declared down, don't send for 20 sec */ 821541Srgrimes 8312942SwollmanSYSCTL_INT(_net_link_ether_inet, OID_AUTO, prune_intvl, CTLFLAG_RW, 8412942Swollman &arpt_prune, 0, ""); 8512942SwollmanSYSCTL_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW, 8612942Swollman &arpt_keep, 0, ""); 8712942SwollmanSYSCTL_INT(_net_link_ether_inet, OID_AUTO, host_down_time, CTLFLAG_RW, 8812942Swollman &arpt_down, 0, ""); 8912693Sphk 901541Srgrimes#define rt_expire rt_rmx.rmx_expire 911541Srgrimes 9211225Swollmanstruct llinfo_arp { 9360938Sjake LIST_ENTRY(llinfo_arp) la_le; 9411225Swollman struct rtentry *la_rt; 95110308Sorion struct mbuf *la_hold; /* last packet until resolved/timeout */ 96110544Sorion u_short la_preempt; /* countdown for pre-expiry arps */ 97110308Sorion u_short la_asked; /* #times we QUERIED following expiration */ 9811225Swollman#define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */ 9911225Swollman}; 10012693Sphk 10160938Sjakestatic LIST_HEAD(, llinfo_arp) llinfo_arp; 10211225Swollman 103111888Sjlemonstatic struct ifqueue arpintrq; 104120727Ssamstatic int arp_allocated; 105120727Ssamstatic int arpinit_done; 1061541Srgrimes 10712693Sphkstatic int arp_maxtries = 5; 10812942Swollmanstatic int useloopback = 1; /* use loopback interface for local traffic */ 10912942Swollmanstatic int arp_proxyall = 0; 110120727Ssamstatic struct callout arp_callout; 1113282Swollman 11212942SwollmanSYSCTL_INT(_net_link_ether_inet, OID_AUTO, maxtries, CTLFLAG_RW, 11312942Swollman &arp_maxtries, 0, ""); 11412942SwollmanSYSCTL_INT(_net_link_ether_inet, OID_AUTO, useloopback, CTLFLAG_RW, 11512942Swollman &useloopback, 0, ""); 11612942SwollmanSYSCTL_INT(_net_link_ether_inet, OID_AUTO, proxyall, CTLFLAG_RW, 11712942Swollman &arp_proxyall, 0, ""); 11812693Sphk 11992723Salfredstatic void arp_init(void); 12092723Salfredstatic void arp_rtrequest(int, struct rtentry *, struct rt_addrinfo *); 12192723Salfredstatic void arprequest(struct ifnet *, 12292723Salfred struct in_addr *, struct in_addr *, u_char *); 123111888Sjlemonstatic void arpintr(struct mbuf *); 12492723Salfredstatic void arptfree(struct llinfo_arp *); 12592723Salfredstatic void arptimer(void *); 12612693Sphkstatic struct llinfo_arp 12792723Salfred *arplookup(u_long, int, int); 12832350Seivind#ifdef INET 12992723Salfredstatic void in_arpinput(struct mbuf *); 13032350Seivind#endif 13112693Sphk 1321541Srgrimes/* 1331541Srgrimes * Timeout routine. Age arp_tab entries periodically. 1341541Srgrimes */ 1351541Srgrimes/* ARGSUSED */ 1361541Srgrimesstatic void 1371541Srgrimesarptimer(ignored_arg) 1381541Srgrimes void *ignored_arg; 1391541Srgrimes{ 140109409Shsu struct llinfo_arp *la, *ola; 1411541Srgrimes 142109996Shsu RADIX_NODE_HEAD_LOCK(rt_tables[AF_INET]); 143109409Shsu la = LIST_FIRST(&llinfo_arp); 144109409Shsu while (la != NULL) { 145109409Shsu struct rtentry *rt = la->la_rt; 146109409Shsu ola = la; 14771999Sphk la = LIST_NEXT(la, la_le); 14834961Sphk if (rt->rt_expire && rt->rt_expire <= time_second) 149109409Shsu arptfree(ola); /* timer has expired, clear */ 1501541Srgrimes } 151109996Shsu RADIX_NODE_HEAD_UNLOCK(rt_tables[AF_INET]); 152120727Ssam 153120727Ssam callout_reset(&arp_callout, arpt_prune * hz, arptimer, NULL); 1541541Srgrimes} 1551541Srgrimes 1561541Srgrimes/* 1571541Srgrimes * Parallel to llc_rtrequest. 1581541Srgrimes */ 1595196Swollmanstatic void 16085074Sruarp_rtrequest(req, rt, info) 1611541Srgrimes int req; 162126936Smdodd struct rtentry *rt; 16385074Sru struct rt_addrinfo *info; 1641541Srgrimes{ 165126936Smdodd struct sockaddr *gate; 166126936Smdodd struct llinfo_arp *la; 1671541Srgrimes static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; 1681541Srgrimes 169120727Ssam RT_LOCK_ASSERT(rt); 170120727Ssam 1711541Srgrimes if (!arpinit_done) { 1721541Srgrimes arpinit_done = 1; 173120727Ssam callout_reset(&arp_callout, hz, arptimer, NULL); 1741541Srgrimes } 1751541Srgrimes if (rt->rt_flags & RTF_GATEWAY) 1761541Srgrimes return; 177120727Ssam gate = rt->rt_gateway; 178120727Ssam la = (struct llinfo_arp *)rt->rt_llinfo; 1791541Srgrimes switch (req) { 1801541Srgrimes 1811541Srgrimes case RTM_ADD: 1821541Srgrimes /* 1831541Srgrimes * XXX: If this is a manually added route to interface 1841541Srgrimes * such as older version of routed or gated might provide, 1851541Srgrimes * restore cloning bit. 1861541Srgrimes */ 1871541Srgrimes if ((rt->rt_flags & RTF_HOST) == 0 && 1881541Srgrimes SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff) 1891541Srgrimes rt->rt_flags |= RTF_CLONING; 1901541Srgrimes if (rt->rt_flags & RTF_CLONING) { 1911541Srgrimes /* 1921541Srgrimes * Case 1: This route should come from a route to iface. 1931541Srgrimes */ 1941541Srgrimes rt_setgate(rt, rt_key(rt), 1951541Srgrimes (struct sockaddr *)&null_sdl); 1961541Srgrimes gate = rt->rt_gateway; 1971541Srgrimes SDL(gate)->sdl_type = rt->rt_ifp->if_type; 1981541Srgrimes SDL(gate)->sdl_index = rt->rt_ifp->if_index; 19934961Sphk rt->rt_expire = time_second; 2001541Srgrimes break; 2011541Srgrimes } 2021541Srgrimes /* Announce a new entry if requested. */ 2031541Srgrimes if (rt->rt_flags & RTF_ANNOUNCE) 20484931Sfjoe arprequest(rt->rt_ifp, 20536908Sjulian &SIN(rt_key(rt))->sin_addr, 20636908Sjulian &SIN(rt_key(rt))->sin_addr, 2071541Srgrimes (u_char *)LLADDR(SDL(gate))); 2081541Srgrimes /*FALLTHROUGH*/ 2091541Srgrimes case RTM_RESOLVE: 2101541Srgrimes if (gate->sa_family != AF_LINK || 2111541Srgrimes gate->sa_len < sizeof(null_sdl)) { 212120727Ssam log(LOG_DEBUG, "%s: bad gateway %s%s\n", __func__, 213120698Sbms inet_ntoa(SIN(rt_key(rt))->sin_addr), 214120698Sbms (gate->sa_family != AF_LINK) ? 215120699Sbms " (!AF_LINK)": ""); 2161541Srgrimes break; 2171541Srgrimes } 2181541Srgrimes SDL(gate)->sdl_type = rt->rt_ifp->if_type; 2191541Srgrimes SDL(gate)->sdl_index = rt->rt_ifp->if_index; 2201541Srgrimes if (la != 0) 2211541Srgrimes break; /* This happens on a route change */ 2221541Srgrimes /* 2231541Srgrimes * Case 2: This route may come from cloning, or a manual route 2241541Srgrimes * add with a LL address. 2251541Srgrimes */ 226120727Ssam R_Zalloc(la, struct llinfo_arp *, sizeof(*la)); 2271541Srgrimes rt->rt_llinfo = (caddr_t)la; 2281541Srgrimes if (la == 0) { 229120727Ssam log(LOG_DEBUG, "%s: malloc failed\n", __func__); 2301541Srgrimes break; 2311541Srgrimes } 232120727Ssam arp_allocated++; 2331541Srgrimes la->la_rt = rt; 2341541Srgrimes rt->rt_flags |= RTF_LLINFO; 235109996Shsu RADIX_NODE_HEAD_LOCK_ASSERT(rt_tables[AF_INET]); 23611225Swollman LIST_INSERT_HEAD(&llinfo_arp, la, la_le); 23713926Swollman 23832350Seivind#ifdef INET 23913926Swollman /* 24013926Swollman * This keeps the multicast addresses from showing up 24113926Swollman * in `arp -a' listings as unresolved. It's not actually 24213926Swollman * functional. Then the same for broadcast. 24313926Swollman */ 24487776Sjlemon if (IN_MULTICAST(ntohl(SIN(rt_key(rt))->sin_addr.s_addr)) && 24587776Sjlemon rt->rt_ifp->if_type != IFT_ARCNET) { 24613926Swollman ETHER_MAP_IP_MULTICAST(&SIN(rt_key(rt))->sin_addr, 24713926Swollman LLADDR(SDL(gate))); 24813926Swollman SDL(gate)->sdl_alen = 6; 24916576Speter rt->rt_expire = 0; 25013926Swollman } 25113926Swollman if (in_broadcast(SIN(rt_key(rt))->sin_addr, rt->rt_ifp)) { 25284931Sfjoe memcpy(LLADDR(SDL(gate)), rt->rt_ifp->if_broadcastaddr, 25384931Sfjoe rt->rt_ifp->if_addrlen); 25484931Sfjoe SDL(gate)->sdl_alen = rt->rt_ifp->if_addrlen; 25516576Speter rt->rt_expire = 0; 25613926Swollman } 25732350Seivind#endif 25813926Swollman 2591541Srgrimes if (SIN(rt_key(rt))->sin_addr.s_addr == 2601541Srgrimes (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) { 2611541Srgrimes /* 2621541Srgrimes * This test used to be 2631541Srgrimes * if (loif.if_flags & IFF_UP) 2641541Srgrimes * It allowed local traffic to be forced 2651541Srgrimes * through the hardware by configuring the loopback down. 2661541Srgrimes * However, it causes problems during network configuration 2671541Srgrimes * for boards that can't receive packets they send. 2681541Srgrimes * It is now necessary to clear "useloopback" and remove 2691541Srgrimes * the route to force traffic out to the hardware. 2701541Srgrimes */ 2711541Srgrimes rt->rt_expire = 0; 272128398Sluigi bcopy(IF_LLADDR(rt->rt_ifp), LLADDR(SDL(gate)), 27384931Sfjoe SDL(gate)->sdl_alen = rt->rt_ifp->if_addrlen); 2741541Srgrimes if (useloopback) 2758090Spst rt->rt_ifp = loif; 2761541Srgrimes 2771541Srgrimes } 2781541Srgrimes break; 2791541Srgrimes 2801541Srgrimes case RTM_DELETE: 2811541Srgrimes if (la == 0) 2821541Srgrimes break; 283109996Shsu RADIX_NODE_HEAD_LOCK_ASSERT(rt_tables[AF_INET]); 28411225Swollman LIST_REMOVE(la, la_le); 2851541Srgrimes rt->rt_llinfo = 0; 2861541Srgrimes rt->rt_flags &= ~RTF_LLINFO; 2871541Srgrimes if (la->la_hold) 2881541Srgrimes m_freem(la->la_hold); 2891541Srgrimes Free((caddr_t)la); 2901541Srgrimes } 2911541Srgrimes} 2921541Srgrimes 2931541Srgrimes/* 2941541Srgrimes * Broadcast an ARP request. Caller specifies: 2951541Srgrimes * - arp header source ip address 2961541Srgrimes * - arp header target ip address 2971541Srgrimes * - arp header source ethernet address 2981541Srgrimes */ 2991541Srgrimesstatic void 30084931Sfjoearprequest(ifp, sip, tip, enaddr) 301126936Smdodd struct ifnet *ifp; 302126936Smdodd struct in_addr *sip, *tip; 303126936Smdodd u_char *enaddr; 3041541Srgrimes{ 305126936Smdodd struct mbuf *m; 306126936Smdodd struct arphdr *ah; 3071541Srgrimes struct sockaddr sa; 3081541Srgrimes 309111119Simp if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) 3101541Srgrimes return; 311127261Smdodd m->m_len = sizeof(*ah) + 2*sizeof(struct in_addr) + 312127261Smdodd 2*ifp->if_data.ifi_addrlen; 313127277Smdodd m->m_pkthdr.len = m->m_len; 314127277Smdodd MH_ALIGN(m, m->m_len); 315127277Smdodd ah = mtod(m, struct arphdr *); 316127261Smdodd bzero((caddr_t)ah, m->m_len); 317101090Srwatson#ifdef MAC 318101090Srwatson mac_create_mbuf_linklayer(ifp, m); 319101090Srwatson#endif 32084931Sfjoe ah->ar_pro = htons(ETHERTYPE_IP); 32184931Sfjoe ah->ar_hln = ifp->if_addrlen; /* hardware address length */ 32284931Sfjoe ah->ar_pln = sizeof(struct in_addr); /* protocol address length */ 32384931Sfjoe ah->ar_op = htons(ARPOP_REQUEST); 324127261Smdodd bcopy((caddr_t)enaddr, (caddr_t)ar_sha(ah), ah->ar_hln); 325127261Smdodd bcopy((caddr_t)sip, (caddr_t)ar_spa(ah), ah->ar_pln); 326127261Smdodd bcopy((caddr_t)tip, (caddr_t)ar_tpa(ah), ah->ar_pln); 327127261Smdodd sa.sa_family = AF_ARP; 328127261Smdodd sa.sa_len = 2; 329127261Smdodd m->m_flags |= M_BCAST; 330127261Smdodd (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0); 33184931Sfjoe 332127261Smdodd return; 3331541Srgrimes} 3341541Srgrimes 3351541Srgrimes/* 3361541Srgrimes * Resolve an IP address into an ethernet address. If success, 3371541Srgrimes * desten is filled in. If there is no entry in arptab, 3381541Srgrimes * set one up and broadcast a request for the IP address. 3391541Srgrimes * Hold onto this mbuf and resend it once the address 3401541Srgrimes * is finally resolved. A return value of 1 indicates 3411541Srgrimes * that desten has been filled in and the packet should be sent 3421541Srgrimes * normally; a 0 return indicates that the packet has been 3431541Srgrimes * taken over here, either now or for later transmission. 3441541Srgrimes */ 3451541Srgrimesint 346127828Sluigiarpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m, 347127828Sluigi struct sockaddr *dst, u_char *desten) 3481541Srgrimes{ 34978295Sjlemon struct llinfo_arp *la = 0; 3501541Srgrimes struct sockaddr_dl *sdl; 3511541Srgrimes 3521541Srgrimes if (m->m_flags & M_BCAST) { /* broadcast */ 35384931Sfjoe (void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen); 3541541Srgrimes return (1); 3551541Srgrimes } 35684931Sfjoe if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */ 3571541Srgrimes ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten); 3581541Srgrimes return(1); 3591541Srgrimes } 3601541Srgrimes if (rt) 3611541Srgrimes la = (struct llinfo_arp *)rt->rt_llinfo; 36242775Sfenner if (la == 0) { 3633311Sphk la = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0); 3643311Sphk if (la) 3651541Srgrimes rt = la->la_rt; 3661541Srgrimes } 3671541Srgrimes if (la == 0 || rt == 0) { 36836308Sphk log(LOG_DEBUG, "arpresolve: can't allocate llinfo for %s%s%s\n", 36936308Sphk inet_ntoa(SIN(dst)->sin_addr), la ? "la" : "", 37036308Sphk rt ? "rt" : ""); 3711541Srgrimes m_freem(m); 3721541Srgrimes return (0); 3731541Srgrimes } 3741541Srgrimes sdl = SDL(rt->rt_gateway); 3751541Srgrimes /* 3761541Srgrimes * Check the address family and length is valid, the address 3771541Srgrimes * is resolved; otherwise, try to resolve. 3781541Srgrimes */ 37934961Sphk if ((rt->rt_expire == 0 || rt->rt_expire > time_second) && 3801541Srgrimes sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { 38192802Sorion /* 38292802Sorion * If entry has an expiry time and it is approaching, 38392802Sorion * see if we need to send an ARP request within this 38492802Sorion * arpt_down interval. 38592802Sorion */ 38692802Sorion if ((rt->rt_expire != 0) && 387110544Sorion (time_second + la->la_preempt > rt->rt_expire)) { 38892802Sorion arprequest(ifp, 38992802Sorion &SIN(rt->rt_ifa->ifa_addr)->sin_addr, 39092802Sorion &SIN(dst)->sin_addr, 39192802Sorion IF_LLADDR(ifp)); 392110544Sorion la->la_preempt--; 39392802Sorion } 39492802Sorion 39516206Sbde bcopy(LLADDR(sdl), desten, sdl->sdl_alen); 3961541Srgrimes return 1; 3971541Srgrimes } 3981541Srgrimes /* 399120626Sru * If ARP is disabled or static on this interface, stop. 40078295Sjlemon * XXX 40178295Sjlemon * Probably should not allocate empty llinfo struct if we are 40278295Sjlemon * not going to be sending out an arp request. 40378295Sjlemon */ 404120626Sru if (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) { 40587410Sru m_freem(m); 40678295Sjlemon return (0); 40787410Sru } 40878295Sjlemon /* 4091541Srgrimes * There is an arptab entry, but no ethernet address 4101541Srgrimes * response yet. Replace the held mbuf with this 4111541Srgrimes * latest one. 4121541Srgrimes */ 4131541Srgrimes if (la->la_hold) 4141541Srgrimes m_freem(la->la_hold); 4151541Srgrimes la->la_hold = m; 4161541Srgrimes if (rt->rt_expire) { 417120727Ssam RT_LOCK(rt); 4181541Srgrimes rt->rt_flags &= ~RTF_REJECT; 41934961Sphk if (la->la_asked == 0 || rt->rt_expire != time_second) { 42034961Sphk rt->rt_expire = time_second; 421110308Sorion if (la->la_asked++ < arp_maxtries) { 422110308Sorion arprequest(ifp, 423110308Sorion &SIN(rt->rt_ifa->ifa_addr)->sin_addr, 424110308Sorion &SIN(dst)->sin_addr, 425110308Sorion IF_LLADDR(ifp)); 426110308Sorion } else { 4271541Srgrimes rt->rt_flags |= RTF_REJECT; 4281541Srgrimes rt->rt_expire += arpt_down; 429110544Sorion la->la_asked = 0; 430110544Sorion la->la_preempt = arp_maxtries; 4311541Srgrimes } 4321541Srgrimes 4331541Srgrimes } 434120727Ssam RT_UNLOCK(rt); 4351541Srgrimes } 4361541Srgrimes return (0); 4371541Srgrimes} 4381541Srgrimes 4391541Srgrimes/* 4401541Srgrimes * Common length and type checks are done here, 4411541Srgrimes * then the protocol-specific routine is called. 4421541Srgrimes */ 44312693Sphkstatic void 444111888Sjlemonarpintr(struct mbuf *m) 4451541Srgrimes{ 446111888Sjlemon struct arphdr *ar; 4471541Srgrimes 44898459Speter if (!arpinit_done) { 449120727Ssam /* NB: this race should not matter */ 45098459Speter arpinit_done = 1; 451120727Ssam callout_reset(&arp_callout, hz, arptimer, NULL); 45298459Speter } 453111888Sjlemon if (m->m_len < sizeof(struct arphdr) && 454111888Sjlemon ((m = m_pullup(m, sizeof(struct arphdr))) == NULL)) { 455111888Sjlemon log(LOG_ERR, "arp: runt packet -- m_pullup failed\n"); 456111888Sjlemon return; 457111888Sjlemon } 458111888Sjlemon ar = mtod(m, struct arphdr *); 4591541Srgrimes 460111888Sjlemon if (ntohs(ar->ar_hrd) != ARPHRD_ETHER && 461111888Sjlemon ntohs(ar->ar_hrd) != ARPHRD_IEEE802 && 462111888Sjlemon ntohs(ar->ar_hrd) != ARPHRD_ARCNET) { 463111888Sjlemon log(LOG_ERR, "arp: unknown hardware address format (0x%2D)\n", 464111888Sjlemon (unsigned char *)&ar->ar_hrd, ""); 465111888Sjlemon m_freem(m); 466111888Sjlemon return; 467111888Sjlemon } 4681541Srgrimes 469123768Sru if (m->m_len < arphdr_len(ar)) { 470123765Sru if ((m = m_pullup(m, arphdr_len(ar))) == NULL) { 471123765Sru log(LOG_ERR, "arp: runt packet\n"); 472123765Sru m_freem(m); 473123765Sru return; 474123765Sru } 475123765Sru ar = mtod(m, struct arphdr *); 476111888Sjlemon } 47757900Srwatson 478111888Sjlemon switch (ntohs(ar->ar_pro)) { 47932350Seivind#ifdef INET 480111888Sjlemon case ETHERTYPE_IP: 481111888Sjlemon in_arpinput(m); 482111888Sjlemon return; 48332350Seivind#endif 4841541Srgrimes } 485111888Sjlemon m_freem(m); 4861541Srgrimes} 4871541Srgrimes 48832350Seivind#ifdef INET 4891541Srgrimes/* 4901541Srgrimes * ARP for Internet protocols on 10 Mb/s Ethernet. 4911541Srgrimes * Algorithm is that given in RFC 826. 4921541Srgrimes * In addition, a sanity check is performed on the sender 4931541Srgrimes * protocol address, to catch impersonators. 4941541Srgrimes * We no longer handle negotiations for use of trailer protocol: 4951541Srgrimes * Formerly, ARP replied for protocol type ETHERTYPE_TRAIL sent 4961541Srgrimes * along with IP replies if we wanted trailers sent to us, 4971541Srgrimes * and also sent them in response to IP replies. 4981541Srgrimes * This allowed either end to announce the desire to receive 4991541Srgrimes * trailer packets. 5001541Srgrimes * We no longer reply to requests for ETHERTYPE_TRAIL protocol either, 5011541Srgrimes * but formerly didn't normally send requests. 5021541Srgrimes */ 50370699Salfredstatic int log_arp_wrong_iface = 1; 50482893Salfredstatic int log_arp_movements = 1; 50570699Salfred 50670699SalfredSYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_wrong_iface, CTLFLAG_RW, 50770699Salfred &log_arp_wrong_iface, 0, 50870699Salfred "log arp packets arriving on the wrong interface"); 50982893SalfredSYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_movements, CTLFLAG_RW, 51082893Salfred &log_arp_movements, 0, 51182966Salfred "log arp replies from MACs different than the one in the cache"); 51270699Salfred 51382893Salfred 5141541Srgrimesstatic void 5151541Srgrimesin_arpinput(m) 5161541Srgrimes struct mbuf *m; 5171541Srgrimes{ 518126936Smdodd struct arphdr *ah; 519126936Smdodd struct ifnet *ifp = m->m_pkthdr.rcvif; 52044627Sjulian struct iso88025_header *th = (struct iso88025_header *)0; 52196184Skbyanc struct iso88025_sockaddr_dl_data *trld; 522126936Smdodd struct llinfo_arp *la = 0; 523126936Smdodd struct rtentry *rt; 52484102Sjlemon struct ifaddr *ifa; 52584102Sjlemon struct in_ifaddr *ia; 5261541Srgrimes struct sockaddr_dl *sdl; 5271541Srgrimes struct sockaddr sa; 5281541Srgrimes struct in_addr isaddr, itaddr, myaddr; 52958313Slile int op, rif_len; 53084931Sfjoe int req_len; 5311541Srgrimes 53284931Sfjoe req_len = arphdr_len2(ifp->if_addrlen, sizeof(struct in_addr)); 53384931Sfjoe if (m->m_len < req_len && (m = m_pullup(m, req_len)) == NULL) { 53474851Syar log(LOG_ERR, "in_arp: runt packet -- m_pullup failed\n"); 53574851Syar return; 53674851Syar } 53774851Syar 53884931Sfjoe ah = mtod(m, struct arphdr *); 53984931Sfjoe op = ntohs(ah->ar_op); 54084931Sfjoe (void)memcpy(&isaddr, ar_spa(ah), sizeof (isaddr)); 54184931Sfjoe (void)memcpy(&itaddr, ar_tpa(ah), sizeof (itaddr)); 54272056Sjulian#ifdef BRIDGE 54372056Sjulian#define BRIDGE_TEST (do_bridge) 54471963Sjulian#else 54572056Sjulian#define BRIDGE_TEST (0) /* cc will optimise the test away */ 54641793Sluigi#endif 54784102Sjlemon /* 54884102Sjlemon * For a bridge, we want to check the address irrespective 54984102Sjlemon * of the receive interface. (This will change slightly 55084102Sjlemon * when we have clusters of interfaces). 55184102Sjlemon */ 55284102Sjlemon LIST_FOREACH(ia, INADDR_HASH(itaddr.s_addr), ia_hash) 55384931Sfjoe if ((BRIDGE_TEST || (ia->ia_ifp == ifp)) && 55484102Sjlemon itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) 55584102Sjlemon goto match; 55684102Sjlemon LIST_FOREACH(ia, INADDR_HASH(isaddr.s_addr), ia_hash) 55784931Sfjoe if ((BRIDGE_TEST || (ia->ia_ifp == ifp)) && 55884102Sjlemon isaddr.s_addr == ia->ia_addr.sin_addr.s_addr) 55984102Sjlemon goto match; 56084102Sjlemon /* 56185223Sjlemon * No match, use the first inet address on the receive interface 56284102Sjlemon * as a dummy address for the rest of the function. 56384102Sjlemon */ 56485223Sjlemon TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) 56585466Sjlemon if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { 56685466Sjlemon ia = ifatoia(ifa); 56785466Sjlemon goto match; 56885466Sjlemon } 56985466Sjlemon /* 57085466Sjlemon * If bridging, fall back to using any inet address. 57185466Sjlemon */ 57285466Sjlemon if (!BRIDGE_TEST || 57385466Sjlemon (ia = TAILQ_FIRST(&in_ifaddrhead)) == NULL) { 57412693Sphk m_freem(m); 57512693Sphk return; 57612693Sphk } 57784102Sjlemonmatch: 57884102Sjlemon myaddr = ia->ia_addr.sin_addr; 57984931Sfjoe if (!bcmp(ar_sha(ah), IF_LLADDR(ifp), ifp->if_addrlen)) { 58012693Sphk m_freem(m); /* it's from me, ignore it. */ 58112693Sphk return; 58212693Sphk } 58384931Sfjoe if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) { 5841541Srgrimes log(LOG_ERR, 58584931Sfjoe "arp: link address is broadcast for IP address %s!\n", 5867088Swollman inet_ntoa(isaddr)); 58712693Sphk m_freem(m); 58812693Sphk return; 5891541Srgrimes } 5901541Srgrimes if (isaddr.s_addr == myaddr.s_addr) { 5911541Srgrimes log(LOG_ERR, 59284931Sfjoe "arp: %*D is using my IP address %s!\n", 59384931Sfjoe ifp->if_addrlen, (u_char *)ar_sha(ah), ":", 59484931Sfjoe inet_ntoa(isaddr)); 5951541Srgrimes itaddr = myaddr; 5961541Srgrimes goto reply; 5971541Srgrimes } 598120626Sru if (ifp->if_flags & IFF_STATICARP) 599120626Sru goto reply; 6001541Srgrimes la = arplookup(isaddr.s_addr, itaddr.s_addr == myaddr.s_addr, 0); 6011541Srgrimes if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) { 60272270Sluigi /* the following is not an error when doing bridging */ 60384931Sfjoe if (!BRIDGE_TEST && rt->rt_ifp != ifp) { 60472270Sluigi if (log_arp_wrong_iface) 605121816Sbrooks log(LOG_ERR, "arp: %s is on %s but got reply from %*D on %s\n", 60671963Sjulian inet_ntoa(isaddr), 607121816Sbrooks rt->rt_ifp->if_xname, 60884931Sfjoe ifp->if_addrlen, (u_char *)ar_sha(ah), ":", 609121816Sbrooks ifp->if_xname); 61072270Sluigi goto reply; 61139389Sfenner } 6121541Srgrimes if (sdl->sdl_alen && 61384931Sfjoe bcmp(ar_sha(ah), LLADDR(sdl), sdl->sdl_alen)) { 61482893Salfred if (rt->rt_expire) { 61582893Salfred if (log_arp_movements) 616121816Sbrooks log(LOG_INFO, "arp: %s moved from %*D to %*D on %s\n", 61784931Sfjoe inet_ntoa(isaddr), 61884931Sfjoe ifp->if_addrlen, (u_char *)LLADDR(sdl), ":", 61984931Sfjoe ifp->if_addrlen, (u_char *)ar_sha(ah), ":", 620121816Sbrooks ifp->if_xname); 62182893Salfred } else { 62239389Sfenner log(LOG_ERR, 623121816Sbrooks "arp: %*D attempts to modify permanent entry for %s on %s\n", 62484931Sfjoe ifp->if_addrlen, (u_char *)ar_sha(ah), ":", 625121816Sbrooks inet_ntoa(isaddr), ifp->if_xname); 62639389Sfenner goto reply; 62739389Sfenner } 62846568Speter } 62984931Sfjoe /* 63084931Sfjoe * sanity check for the address length. 63184931Sfjoe * XXX this does not work for protocols with variable address 63284931Sfjoe * length. -is 63384931Sfjoe */ 63484931Sfjoe if (sdl->sdl_alen && 63584931Sfjoe sdl->sdl_alen != ah->ar_hln) { 63684931Sfjoe log(LOG_WARNING, 63784931Sfjoe "arp from %*D: new addr len %d, was %d", 63884931Sfjoe ifp->if_addrlen, (u_char *) ar_sha(ah), ":", 63984931Sfjoe ah->ar_hln, sdl->sdl_alen); 64084931Sfjoe } 64184931Sfjoe if (ifp->if_addrlen != ah->ar_hln) { 64284931Sfjoe log(LOG_WARNING, 64384931Sfjoe "arp from %*D: addr len: new %d, i/f %d (ignored)", 64484931Sfjoe ifp->if_addrlen, (u_char *) ar_sha(ah), ":", 64584931Sfjoe ah->ar_hln, ifp->if_addrlen); 64684931Sfjoe goto reply; 64784931Sfjoe } 64884931Sfjoe (void)memcpy(LLADDR(sdl), ar_sha(ah), 64984931Sfjoe sdl->sdl_alen = ah->ar_hln); 65045705Seivind /* 65145705Seivind * If we receive an arp from a token-ring station over 65245705Seivind * a token-ring nic then try to save the source 65345705Seivind * routing info. 65445705Seivind */ 65584931Sfjoe if (ifp->if_type == IFT_ISO88025) { 65644627Sjulian th = (struct iso88025_header *)m->m_pkthdr.header; 65796184Skbyanc trld = SDL_ISO88025(sdl); 65858313Slile rif_len = TR_RCF_RIFLEN(th->rcf); 65958313Slile if ((th->iso88025_shost[0] & TR_RII) && 66058313Slile (rif_len > 2)) { 66196184Skbyanc trld->trld_rcf = th->rcf; 66296184Skbyanc trld->trld_rcf ^= htons(TR_RCF_DIR); 66396184Skbyanc memcpy(trld->trld_route, th->rd, rif_len - 2); 66496184Skbyanc trld->trld_rcf &= ~htons(TR_RCF_BCST_MASK); 66551320Slile /* 66651320Slile * Set up source routing information for 66751320Slile * reply packet (XXX) 66851320Slile */ 66958313Slile m->m_data -= rif_len; 67058313Slile m->m_len += rif_len; 67158313Slile m->m_pkthdr.len += rif_len; 67244627Sjulian } else { 67358313Slile th->iso88025_shost[0] &= ~TR_RII; 67496624Skbyanc trld->trld_rcf = 0; 67544627Sjulian } 67650512Slile m->m_data -= 8; 67750512Slile m->m_len += 8; 67850512Slile m->m_pkthdr.len += 8; 67996184Skbyanc th->rcf = trld->trld_rcf; 68044627Sjulian } 681120727Ssam RT_LOCK(rt); 6821541Srgrimes if (rt->rt_expire) 68334961Sphk rt->rt_expire = time_second + arpt_keep; 6841541Srgrimes rt->rt_flags &= ~RTF_REJECT; 685120727Ssam RT_UNLOCK(rt); 686110544Sorion la->la_asked = 0; 687110544Sorion la->la_preempt = arp_maxtries; 6881541Srgrimes if (la->la_hold) { 689127277Smdodd (*ifp->if_output)(ifp, la->la_hold, rt_key(rt), rt); 6901541Srgrimes la->la_hold = 0; 6911541Srgrimes } 6921541Srgrimes } 6931541Srgrimesreply: 6941541Srgrimes if (op != ARPOP_REQUEST) { 6951541Srgrimes m_freem(m); 6961541Srgrimes return; 6971541Srgrimes } 6981541Srgrimes if (itaddr.s_addr == myaddr.s_addr) { 6991541Srgrimes /* I am the target */ 70084931Sfjoe (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln); 70184931Sfjoe (void)memcpy(ar_sha(ah), IF_LLADDR(ifp), ah->ar_hln); 7021541Srgrimes } else { 7031541Srgrimes la = arplookup(itaddr.s_addr, 0, SIN_PROXY); 7043282Swollman if (la == NULL) { 7053282Swollman struct sockaddr_in sin; 7063282Swollman 70712693Sphk if (!arp_proxyall) { 70812693Sphk m_freem(m); 70912693Sphk return; 71012693Sphk } 7113282Swollman 7123282Swollman bzero(&sin, sizeof sin); 7133282Swollman sin.sin_family = AF_INET; 7143282Swollman sin.sin_len = sizeof sin; 7153282Swollman sin.sin_addr = itaddr; 7163282Swollman 7175101Swollman rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL); 71812693Sphk if (!rt) { 71912693Sphk m_freem(m); 72012693Sphk return; 72112693Sphk } 7223282Swollman /* 7233282Swollman * Don't send proxies for nodes on the same interface 7243282Swollman * as this one came out of, or we'll get into a fight 7253282Swollman * over who claims what Ether address. 7263282Swollman */ 72784931Sfjoe if (rt->rt_ifp == ifp) { 7283282Swollman rtfree(rt); 72912693Sphk m_freem(m); 73012693Sphk return; 7313282Swollman } 73284931Sfjoe (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln); 73384931Sfjoe (void)memcpy(ar_sha(ah), IF_LLADDR(ifp), ah->ar_hln); 7343282Swollman rtfree(rt); 73563080Sdwmalone 73663080Sdwmalone /* 73763080Sdwmalone * Also check that the node which sent the ARP packet 73863080Sdwmalone * is on the the interface we expect it to be on. This 73963080Sdwmalone * avoids ARP chaos if an interface is connected to the 74063080Sdwmalone * wrong network. 74163080Sdwmalone */ 74263080Sdwmalone sin.sin_addr = isaddr; 74363080Sdwmalone 74463080Sdwmalone rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL); 74563080Sdwmalone if (!rt) { 74663080Sdwmalone m_freem(m); 74763080Sdwmalone return; 74863080Sdwmalone } 74984931Sfjoe if (rt->rt_ifp != ifp) { 75063080Sdwmalone log(LOG_INFO, "arp_proxy: ignoring request" 751121816Sbrooks " from %s via %s, expecting %s\n", 752121816Sbrooks inet_ntoa(isaddr), ifp->if_xname, 753121816Sbrooks rt->rt_ifp->if_xname); 75463080Sdwmalone rtfree(rt); 75563080Sdwmalone m_freem(m); 75663080Sdwmalone return; 75763080Sdwmalone } 75863080Sdwmalone rtfree(rt); 75963080Sdwmalone 7604069Swollman#ifdef DEBUG_PROXY 7618876Srgrimes printf("arp: proxying for %s\n", 7627088Swollman inet_ntoa(itaddr)); 7634069Swollman#endif 7643282Swollman } else { 7653282Swollman rt = la->la_rt; 76684931Sfjoe (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln); 7673282Swollman sdl = SDL(rt->rt_gateway); 76884931Sfjoe (void)memcpy(ar_sha(ah), LLADDR(sdl), ah->ar_hln); 7693282Swollman } 7701541Srgrimes } 7711541Srgrimes 77284931Sfjoe (void)memcpy(ar_tpa(ah), ar_spa(ah), ah->ar_pln); 77384931Sfjoe (void)memcpy(ar_spa(ah), &itaddr, ah->ar_pln); 77484931Sfjoe ah->ar_op = htons(ARPOP_REPLY); 77584931Sfjoe ah->ar_pro = htons(ETHERTYPE_IP); /* let's be sure! */ 776127261Smdodd m->m_flags &= ~(M_BCAST|M_MCAST); /* never reply by broadcast */ 777127261Smdodd m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln); 778127261Smdodd m->m_pkthdr.len = m->m_len; 779127261Smdodd sa.sa_family = AF_ARP; 780127261Smdodd sa.sa_len = 2; 78184931Sfjoe (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0); 7821541Srgrimes return; 7831541Srgrimes} 78432350Seivind#endif 7851541Srgrimes 7861541Srgrimes/* 7871541Srgrimes * Free an arp entry. 7881541Srgrimes */ 7891541Srgrimesstatic void 7901541Srgrimesarptfree(la) 791126936Smdodd struct llinfo_arp *la; 7921541Srgrimes{ 793126936Smdodd struct rtentry *rt = la->la_rt; 794126936Smdodd struct sockaddr_dl *sdl; 795120727Ssam 7961541Srgrimes if (rt == 0) 7971541Srgrimes panic("arptfree"); 7981541Srgrimes if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) && 7991541Srgrimes sdl->sdl_family == AF_LINK) { 8001541Srgrimes sdl->sdl_alen = 0; 801110308Sorion la->la_preempt = la->la_asked = 0; 802120727Ssam RT_LOCK(rt); /* XXX needed or move higher? */ 8031541Srgrimes rt->rt_flags &= ~RTF_REJECT; 804120727Ssam RT_UNLOCK(rt); 8051541Srgrimes return; 8061541Srgrimes } 8071541Srgrimes rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt), 8081541Srgrimes 0, (struct rtentry **)0); 8091541Srgrimes} 8101541Srgrimes/* 8111541Srgrimes * Lookup or enter a new address in arptab. 8121541Srgrimes */ 8131541Srgrimesstatic struct llinfo_arp * 8141541Srgrimesarplookup(addr, create, proxy) 8151541Srgrimes u_long addr; 8161541Srgrimes int create, proxy; 8171541Srgrimes{ 818126936Smdodd struct rtentry *rt; 819120727Ssam struct sockaddr_inarp sin; 8204069Swollman const char *why = 0; 8211541Srgrimes 822120727Ssam bzero(&sin, sizeof(sin)); 823120727Ssam sin.sin_len = sizeof(sin); 824120727Ssam sin.sin_family = AF_INET; 8251541Srgrimes sin.sin_addr.s_addr = addr; 826120727Ssam if (proxy) 827120727Ssam sin.sin_other = SIN_PROXY; 8285101Swollman rt = rtalloc1((struct sockaddr *)&sin, create, 0UL); 8291541Srgrimes if (rt == 0) 8301541Srgrimes return (0); 8314069Swollman 83212693Sphk if (rt->rt_flags & RTF_GATEWAY) 8334069Swollman why = "host is not on local network"; 83412693Sphk else if ((rt->rt_flags & RTF_LLINFO) == 0) 8354069Swollman why = "could not allocate llinfo"; 83612693Sphk else if (rt->rt_gateway->sa_family != AF_LINK) 8374069Swollman why = "gateway route is not ours"; 8384069Swollman 839120383Sbms if (why) { 840120727Ssam#define ISDYNCLONE(_rt) \ 841120727Ssam (((_rt)->rt_flags & (RTF_STATIC | RTF_WASCLONED)) == RTF_WASCLONED) 842120727Ssam if (create) 843120383Sbms log(LOG_DEBUG, "arplookup %s failed: %s\n", 844120383Sbms inet_ntoa(sin.sin_addr), why); 845120727Ssam /* 846120727Ssam * If there are no references to this Layer 2 route, 847120727Ssam * and it is a cloned route, and not static, and 848120727Ssam * arplookup() is creating the route, then purge 849120727Ssam * it from the routing table as it is probably bogus. 850120727Ssam */ 851121770Ssam if (rt->rt_refcnt == 1 && ISDYNCLONE(rt)) 852121770Ssam rtexpunge(rt); 853121770Ssam RTFREE_LOCKED(rt); 854120383Sbms return (0); 855120727Ssam#undef ISDYNCLONE 856120727Ssam } else { 857122334Ssam RT_REMREF(rt); 858120727Ssam RT_UNLOCK(rt); 859120727Ssam return ((struct llinfo_arp *)rt->rt_llinfo); 8601541Srgrimes } 8611541Srgrimes} 8621541Srgrimes 8635195Swollmanvoid 86484931Sfjoearp_ifinit(ifp, ifa) 86584931Sfjoe struct ifnet *ifp; 8665195Swollman struct ifaddr *ifa; 8675195Swollman{ 86825822Stegge if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) 86984931Sfjoe arprequest(ifp, &IA_SIN(ifa)->sin_addr, 87084931Sfjoe &IA_SIN(ifa)->sin_addr, IF_LLADDR(ifp)); 8715195Swollman ifa->ifa_rtrequest = arp_rtrequest; 8725195Swollman ifa->ifa_flags |= RTF_CLONING; 8735195Swollman} 87469152Sjlemon 87569152Sjlemonstatic void 87669152Sjlemonarp_init(void) 87769152Sjlemon{ 87869152Sjlemon 87969152Sjlemon arpintrq.ifq_maxlen = 50; 88093818Sjhb mtx_init(&arpintrq.ifq_mtx, "arp_inq", NULL, MTX_DEF); 88198459Speter LIST_INIT(&llinfo_arp); 882120727Ssam callout_init(&arp_callout, CALLOUT_MPSAFE); 883122320Ssam netisr_register(NETISR_ARP, arpintr, &arpintrq, NETISR_MPSAFE); 88469152Sjlemon} 88569152SjlemonSYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0); 886