2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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
29 * @(#)if_ether.c 8.1 (Berkeley) 6/10/93
33 * Ethernet address resolution protocol.
35 * add "inuse/lock" bit (or ref. count) along with valid bit
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
45 #include <sys/param.h>
46 #include <sys/kernel.h>
47 #include <sys/queue.h>
48 #include <sys/sysctl.h>
49 #include <sys/systm.h>
51 #include <sys/malloc.h>
53 #include <sys/socket.h>
54 #include <sys/syslog.h>
55 #include <sys/vimage.h>
58 #include <net/if_dl.h>
59 #include <net/if_types.h>
60 #include <net/route.h>
61 #include <net/netisr.h>
62 #include <net/if_llc.h>
63 #include <net/ethernet.h>
66 #include <netinet/in.h>
67 #include <netinet/in_var.h>
68 #include <net/if_llatbl.h>
69 #include <netinet/if_ether.h>
70 #include <netinet/vinet.h>
72 #include <net/if_arc.h>
73 #include <net/iso88025.h>
76 #include <netinet/ip_carp.h>
79 #include <security/mac/mac_framework.h>
81 #define SIN(s) ((struct sockaddr_in *)s)
82 #define SDL(s) ((struct sockaddr_dl *)s)
83 #define LLTABLE(ifp) ((struct lltable *)(ifp)->if_afdata[AF_INET])
85 SYSCTL_DECL(_net_link_ether);
86 SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, "");
90 static int arpt_keep; /* once resolved, good for 20 more minutes */
91 static int arp_maxtries;
92 int useloopback; /* use loopback interface for local traffic */
93 static int arp_proxyall;
96 SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, max_age,
97 CTLFLAG_RW, arpt_keep, 0, "ARP entry lifetime in seconds");
99 static struct ifqueue arpintrq;
101 SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, maxtries,
102 CTLFLAG_RW, arp_maxtries, 0,
103 "ARP resolution attempts before returning error");
104 SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, useloopback,
105 CTLFLAG_RW, useloopback, 0,
106 "Use the loopback interface for local traffic");
107 SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, proxyall,
108 CTLFLAG_RW, arp_proxyall, 0,
109 "Enable proxy ARP for all suitable requests");
111 static void arp_init(void);
112 void arprequest(struct ifnet *,
113 struct in_addr *, struct in_addr *, u_char *);
114 static void arpintr(struct mbuf *);
115 static void arptimer(void *);
117 static void in_arpinput(struct mbuf *);
121 void arp_ifscrub(struct ifnet *ifp, uint32_t addr);
124 * called by in_ifscrub to remove entry from the table when
125 * the interface goes away
128 arp_ifscrub(struct ifnet *ifp, uint32_t addr)
130 struct sockaddr_in addr4;
132 bzero((void *)&addr4, sizeof(addr4));
133 addr4.sin_len = sizeof(addr4);
134 addr4.sin_family = AF_INET;
135 addr4.sin_addr.s_addr = addr;
137 lla_lookup(LLTABLE(ifp), (LLE_DELETE | LLE_IFADDR),
138 (struct sockaddr *)&addr4);
139 IF_AFDATA_UNLOCK(ifp);
144 * Timeout routine. Age arp_tab entries periodically.
150 struct llentry *lle = (struct llentry *)arg;
153 panic("%s: NULL entry!\n", __func__);
156 ifp = lle->lle_tbl->llt_ifp;
159 if (((lle->la_flags & LLE_DELETED)
160 || (time_second >= lle->la_expire))
161 && (!callout_pending(&lle->la_timer) &&
162 callout_active(&lle->la_timer)))
163 (void) llentry_free(lle);
166 * Still valid, just drop our reference
168 LLE_FREE_LOCKED(lle);
170 IF_AFDATA_UNLOCK(ifp);
174 * Broadcast an ARP request. Caller specifies:
175 * - arp header source ip address
176 * - arp header target ip address
177 * - arp header source ethernet address
180 arprequest(struct ifnet *ifp, struct in_addr *sip, struct in_addr *tip,
188 /* XXX don't believe this can happen (or explain why) */
190 * The caller did not supply a source address, try to find
191 * a compatible one among those assigned to this interface.
195 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
196 if (!ifa->ifa_addr ||
197 ifa->ifa_addr->sa_family != AF_INET)
199 sip = &SIN(ifa->ifa_addr)->sin_addr;
200 if (0 == ((sip->s_addr ^ tip->s_addr) &
201 SIN(ifa->ifa_netmask)->sin_addr.s_addr) )
202 break; /* found it. */
205 printf("%s: cannot find matching address\n", __func__);
210 if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL)
212 m->m_len = sizeof(*ah) + 2*sizeof(struct in_addr) +
213 2*ifp->if_data.ifi_addrlen;
214 m->m_pkthdr.len = m->m_len;
215 MH_ALIGN(m, m->m_len);
216 ah = mtod(m, struct arphdr *);
217 bzero((caddr_t)ah, m->m_len);
219 mac_netinet_arp_send(ifp, m);
221 ah->ar_pro = htons(ETHERTYPE_IP);
222 ah->ar_hln = ifp->if_addrlen; /* hardware address length */
223 ah->ar_pln = sizeof(struct in_addr); /* protocol address length */
224 ah->ar_op = htons(ARPOP_REQUEST);
225 bcopy((caddr_t)enaddr, (caddr_t)ar_sha(ah), ah->ar_hln);
226 bcopy((caddr_t)sip, (caddr_t)ar_spa(ah), ah->ar_pln);
227 bcopy((caddr_t)tip, (caddr_t)ar_tpa(ah), ah->ar_pln);
228 sa.sa_family = AF_ARP;
230 m->m_flags |= M_BCAST;
231 (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0);
235 * Resolve an IP address into an ethernet address.
237 * ifp is the interface we use
238 * rt0 is the route to the final destination (possibly useless)
239 * m is the mbuf. May be NULL if we don't have a packet.
240 * dst is the next hop,
241 * desten is where we want the address.
243 * On success, desten is filled in and the function returns 0;
244 * If the packet must be held pending resolution, we return EWOULDBLOCK
245 * On other errors, we return the corresponding error code.
246 * Note that m_freem() handles NULL.
249 arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
250 struct sockaddr *dst, u_char *desten, struct llentry **lle)
252 INIT_VNET_INET(ifp->if_vnet);
253 struct llentry *la = 0;
259 if (m->m_flags & M_BCAST) {
262 ifp->if_broadcastaddr, ifp->if_addrlen);
265 if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {
267 ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten);
274 IF_AFDATA_RLOCK(ifp);
275 la = lla_lookup(LLTABLE(ifp), flags, dst);
276 IF_AFDATA_RUNLOCK(ifp);
277 if ((la == NULL) && ((flags & LLE_EXCLUSIVE) == 0)
278 && ((ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0)) {
279 flags |= (LLE_CREATE | LLE_EXCLUSIVE);
280 IF_AFDATA_WLOCK(ifp);
281 la = lla_lookup(LLTABLE(ifp), flags, dst);
282 IF_AFDATA_WUNLOCK(ifp);
285 if (flags & LLE_CREATE)
287 "arpresolve: can't allocate llinfo for %s\n",
288 inet_ntoa(SIN(dst)->sin_addr));
293 if ((la->la_flags & LLE_VALID) &&
294 ((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) {
295 bcopy(&la->ll_addr, desten, ifp->if_addrlen);
297 * If entry has an expiry time and it is approaching,
298 * see if we need to send an ARP request within this
299 * arpt_down interval.
301 if (!(la->la_flags & LLE_STATIC) &&
302 time_uptime + la->la_preempt > la->la_expire) {
303 arprequest(ifp, NULL,
304 &SIN(dst)->sin_addr, IF_LLADDR(ifp));
314 if (la->la_flags & LLE_STATIC) { /* should not happen! */
315 log(LOG_DEBUG, "arpresolve: ouch, empty static llinfo for %s\n",
316 inet_ntoa(SIN(dst)->sin_addr));
322 renew = (la->la_asked == 0 || la->la_expire != time_uptime);
323 if ((renew || m != NULL) && (flags & LLE_EXCLUSIVE) == 0) {
324 flags |= LLE_EXCLUSIVE;
329 * There is an arptab entry, but no ethernet address
330 * response yet. Replace the held mbuf with this
334 if (la->la_hold != NULL)
335 m_freem(la->la_hold);
337 if (renew == 0 && (flags & LLE_EXCLUSIVE)) {
338 flags &= ~LLE_EXCLUSIVE;
344 * Return EWOULDBLOCK if we have tried less than arp_maxtries. It
345 * will be masked by ether_output(). Return EHOSTDOWN/EHOSTUNREACH
346 * if we have already sent arp_maxtries ARP requests. Retransmit the
347 * ARP request, but not faster than one request per second.
349 if (la->la_asked < V_arp_maxtries)
350 error = EWOULDBLOCK; /* First request. */
353 (rt0->rt_flags & RTF_GATEWAY) ? EHOSTDOWN : EHOSTUNREACH;
357 la->la_expire = time_uptime;
358 callout_reset(&la->la_timer, hz, arptimer, la);
361 arprequest(ifp, NULL, &SIN(dst)->sin_addr,
366 if (flags & LLE_EXCLUSIVE)
374 * Common length and type checks are done here,
375 * then the protocol-specific routine is called.
378 arpintr(struct mbuf *m)
382 if (m->m_len < sizeof(struct arphdr) &&
383 ((m = m_pullup(m, sizeof(struct arphdr))) == NULL)) {
384 log(LOG_ERR, "arp: runt packet -- m_pullup failed\n");
387 ar = mtod(m, struct arphdr *);
389 if (ntohs(ar->ar_hrd) != ARPHRD_ETHER &&
390 ntohs(ar->ar_hrd) != ARPHRD_IEEE802 &&
391 ntohs(ar->ar_hrd) != ARPHRD_ARCNET &&
392 ntohs(ar->ar_hrd) != ARPHRD_IEEE1394) {
393 log(LOG_ERR, "arp: unknown hardware address format (0x%2D)\n",
394 (unsigned char *)&ar->ar_hrd, "");
399 if (m->m_len < arphdr_len(ar)) {
400 if ((m = m_pullup(m, arphdr_len(ar))) == NULL) {
401 log(LOG_ERR, "arp: runt packet\n");
405 ar = mtod(m, struct arphdr *);
408 switch (ntohs(ar->ar_pro)) {
420 * ARP for Internet protocols on 10 Mb/s Ethernet.
421 * Algorithm is that given in RFC 826.
422 * In addition, a sanity check is performed on the sender
423 * protocol address, to catch impersonators.
424 * We no longer handle negotiations for use of trailer protocol:
425 * Formerly, ARP replied for protocol type ETHERTYPE_TRAIL sent
426 * along with IP replies if we wanted trailers sent to us,
427 * and also sent them in response to IP replies.
428 * This allowed either end to announce the desire to receive
430 * We no longer reply to requests for ETHERTYPE_TRAIL protocol either,
431 * but formerly didn't normally send requests.
433 static int log_arp_wrong_iface = 1;
434 static int log_arp_movements = 1;
435 static int log_arp_permanent_modify = 1;
437 SYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_wrong_iface, CTLFLAG_RW,
438 &log_arp_wrong_iface, 0,
439 "log arp packets arriving on the wrong interface");
440 SYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_movements, CTLFLAG_RW,
441 &log_arp_movements, 0,
442 "log arp replies from MACs different than the one in the cache");
443 SYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_permanent_modify, CTLFLAG_RW,
444 &log_arp_permanent_modify, 0,
445 "log arp replies from MACs different than the one in the permanent arp entry");
449 in_arpinput(struct mbuf *m)
452 struct ifnet *ifp = m->m_pkthdr.rcvif;
453 struct llentry *la = NULL;
456 struct in_ifaddr *ia;
458 struct in_addr isaddr, itaddr, myaddr;
459 u_int8_t *enaddr = NULL;
463 int bridged = 0, is_bridge = 0;
467 struct sockaddr_in sin;
468 sin.sin_len = sizeof(struct sockaddr_in);
469 sin.sin_family = AF_INET;
470 sin.sin_addr.s_addr = 0;
471 INIT_VNET_INET(ifp->if_vnet);
475 if (ifp->if_type == IFT_BRIDGE)
478 req_len = arphdr_len2(ifp->if_addrlen, sizeof(struct in_addr));
479 if (m->m_len < req_len && (m = m_pullup(m, req_len)) == NULL) {
480 log(LOG_ERR, "in_arp: runt packet -- m_pullup failed\n");
484 ah = mtod(m, struct arphdr *);
485 op = ntohs(ah->ar_op);
486 (void)memcpy(&isaddr, ar_spa(ah), sizeof (isaddr));
487 (void)memcpy(&itaddr, ar_tpa(ah), sizeof (itaddr));
490 * For a bridge, we want to check the address irrespective
491 * of the receive interface. (This will change slightly
492 * when we have clusters of interfaces).
493 * If the interface does not match, but the recieving interface
494 * is part of carp, we call carp_iamatch to see if this is a
495 * request for the virtual host ip.
496 * XXX: This is really ugly!
498 LIST_FOREACH(ia, INADDR_HASH(itaddr.s_addr), ia_hash) {
499 if (((bridged && ia->ia_ifp->if_bridge != NULL) ||
500 ia->ia_ifp == ifp) &&
501 itaddr.s_addr == ia->ia_addr.sin_addr.s_addr)
504 if (ifp->if_carp != NULL &&
505 carp_iamatch(ifp->if_carp, ia, &isaddr, &enaddr) &&
506 itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) {
512 LIST_FOREACH(ia, INADDR_HASH(isaddr.s_addr), ia_hash)
513 if (((bridged && ia->ia_ifp->if_bridge != NULL) ||
514 ia->ia_ifp == ifp) &&
515 isaddr.s_addr == ia->ia_addr.sin_addr.s_addr)
518 #define BDG_MEMBER_MATCHES_ARP(addr, ifp, ia) \
519 (ia->ia_ifp->if_bridge == ifp->if_softc && \
520 !bcmp(IF_LLADDR(ia->ia_ifp), IF_LLADDR(ifp), ifp->if_addrlen) && \
521 addr == ia->ia_addr.sin_addr.s_addr)
523 * Check the case when bridge shares its MAC address with
524 * some of its children, so packets are claimed by bridge
525 * itself (bridge_input() does it first), but they are really
526 * meant to be destined to the bridge member.
529 LIST_FOREACH(ia, INADDR_HASH(itaddr.s_addr), ia_hash) {
530 if (BDG_MEMBER_MATCHES_ARP(itaddr.s_addr, ifp, ia)) {
536 #undef BDG_MEMBER_MATCHES_ARP
539 * No match, use the first inet address on the receive interface
540 * as a dummy address for the rest of the function.
542 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
543 if (ifa->ifa_addr->sa_family == AF_INET) {
548 * If bridging, fall back to using any inet address.
550 if (!bridged || (ia = TAILQ_FIRST(&V_in_ifaddrhead)) == NULL)
554 enaddr = (u_int8_t *)IF_LLADDR(ifp);
555 myaddr = ia->ia_addr.sin_addr;
556 if (!bcmp(ar_sha(ah), enaddr, ifp->if_addrlen))
557 goto drop; /* it's from me, ignore it. */
558 if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) {
560 "arp: link address is broadcast for IP address %s!\n",
565 * Warn if another host is using the same IP address, but only if the
566 * IP address isn't 0.0.0.0, which is used for DHCP only, in which
567 * case we suppress the warning to avoid false positive complaints of
568 * potential misconfiguration.
570 if (!bridged && isaddr.s_addr == myaddr.s_addr && myaddr.s_addr != 0) {
572 "arp: %*D is using my IP address %s on %s!\n",
573 ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
574 inet_ntoa(isaddr), ifp->if_xname);
578 if (ifp->if_flags & IFF_STATICARP)
581 bzero(&sin, sizeof(sin));
582 sin.sin_len = sizeof(struct sockaddr_in);
583 sin.sin_family = AF_INET;
584 sin.sin_addr = isaddr;
585 flags = (itaddr.s_addr == myaddr.s_addr) ? LLE_CREATE : 0;
586 flags |= LLE_EXCLUSIVE;
588 la = lla_lookup(LLTABLE(ifp), flags, (struct sockaddr *)&sin);
589 IF_AFDATA_UNLOCK(ifp);
591 /* the following is not an error when doing bridging */
592 if (!bridged && la->lle_tbl->llt_ifp != ifp
594 && (ifp->if_type != IFT_CARP || !carp_match)
597 if (log_arp_wrong_iface)
598 log(LOG_ERR, "arp: %s is on %s "
599 "but got reply from %*D on %s\n",
601 la->lle_tbl->llt_ifp->if_xname,
602 ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
606 if ((la->la_flags & LLE_VALID) &&
607 bcmp(ar_sha(ah), &la->ll_addr, ifp->if_addrlen)) {
608 if (la->la_flags & LLE_STATIC) {
610 "arp: %*D attempts to modify permanent "
611 "entry for %s on %s\n",
612 ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
613 inet_ntoa(isaddr), ifp->if_xname);
616 if (log_arp_movements) {
617 log(LOG_INFO, "arp: %s moved from %*D "
621 (u_char *)&la->ll_addr, ":",
622 ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
627 if (ifp->if_addrlen != ah->ar_hln) {
629 "arp from %*D: addr len: new %d, i/f %d (ignored)",
630 ifp->if_addrlen, (u_char *) ar_sha(ah), ":",
631 ah->ar_hln, ifp->if_addrlen);
634 (void)memcpy(&la->ll_addr, ar_sha(ah), ifp->if_addrlen);
635 la->la_flags |= LLE_VALID;
637 if (!(la->la_flags & LLE_STATIC)) {
638 la->la_expire = time_uptime + V_arpt_keep;
639 callout_reset(&la->la_timer, hz * V_arpt_keep,
643 la->la_preempt = V_arp_maxtries;
644 if (la->la_hold != NULL) {
647 memcpy(&sa, L3_ADDR(la), sizeof(sa));
650 (*ifp->if_output)(ifp, m0, &sa, NULL);
655 if (op != ARPOP_REQUEST)
658 if (itaddr.s_addr == myaddr.s_addr) {
659 /* Shortcut.. the receiving interface is the target. */
660 (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln);
661 (void)memcpy(ar_sha(ah), enaddr, ah->ar_hln);
663 struct llentry *lle = NULL;
668 sin.sin_addr = itaddr;
669 /* XXX MRT use table 0 for arp reply */
670 rt = in_rtalloc1((struct sockaddr *)&sin, 0, 0UL, 0);
675 * Don't send proxies for nodes on the same interface
676 * as this one came out of, or we'll get into a fight
677 * over who claims what Ether address.
679 if (!rt->rt_ifp || rt->rt_ifp == ifp) {
683 IF_AFDATA_LOCK(rt->rt_ifp);
684 lle = lla_lookup(LLTABLE(rt->rt_ifp), 0, (struct sockaddr *)&sin);
685 IF_AFDATA_UNLOCK(rt->rt_ifp);
689 (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln);
690 (void)memcpy(ar_sha(ah), &lle->ll_addr, ah->ar_hln);
696 * Also check that the node which sent the ARP packet
697 * is on the the interface we expect it to be on. This
698 * avoids ARP chaos if an interface is connected to the
701 sin.sin_addr = isaddr;
703 /* XXX MRT use table 0 for arp checks */
704 rt = in_rtalloc1((struct sockaddr *)&sin, 0, 0UL, 0);
707 if (rt->rt_ifp != ifp) {
708 log(LOG_INFO, "arp_proxy: ignoring request"
709 " from %s via %s, expecting %s\n",
710 inet_ntoa(isaddr), ifp->if_xname,
711 rt->rt_ifp->if_xname);
718 printf("arp: proxying for %s\n",
725 if (itaddr.s_addr == myaddr.s_addr &&
726 IN_LINKLOCAL(ntohl(itaddr.s_addr))) {
727 /* RFC 3927 link-local IPv4; always reply by broadcast. */
728 #ifdef DEBUG_LINKLOCAL
729 printf("arp: sending reply for link-local addr %s\n",
732 m->m_flags |= M_BCAST;
733 m->m_flags &= ~M_MCAST;
735 /* default behaviour; never reply by broadcast. */
736 m->m_flags &= ~(M_BCAST|M_MCAST);
738 (void)memcpy(ar_tpa(ah), ar_spa(ah), ah->ar_pln);
739 (void)memcpy(ar_spa(ah), &itaddr, ah->ar_pln);
740 ah->ar_op = htons(ARPOP_REPLY);
741 ah->ar_pro = htons(ETHERTYPE_IP); /* let's be sure! */
742 m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln);
743 m->m_pkthdr.len = m->m_len;
744 sa.sa_family = AF_ARP;
746 (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0);
757 arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa)
761 if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) {
762 arprequest(ifp, &IA_SIN(ifa)->sin_addr,
763 &IA_SIN(ifa)->sin_addr, IF_LLADDR(ifp));
765 * interface address is considered static entry
766 * because the output of the arp utility shows
767 * that L2 entry as permanent
770 lle = lla_lookup(LLTABLE(ifp), (LLE_CREATE | LLE_IFADDR | LLE_STATIC),
771 (struct sockaddr *)IA_SIN(ifa));
772 IF_AFDATA_UNLOCK(ifp);
774 log(LOG_INFO, "arp_ifinit: cannot create arp "
775 "entry for interface address\n");
779 ifa->ifa_rtrequest = NULL;
783 arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr)
785 if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY)
786 arprequest(ifp, &IA_SIN(ifa)->sin_addr,
787 &IA_SIN(ifa)->sin_addr, enaddr);
788 ifa->ifa_rtrequest = NULL;
794 INIT_VNET_INET(curvnet);
796 V_arpt_keep = (20*60); /* once resolved, good for 20 more minutes */
798 V_useloopback = 1; /* use loopback interface for local traffic */
801 arpintrq.ifq_maxlen = 50;
802 mtx_init(&arpintrq.ifq_mtx, "arp_inq", NULL, MTX_DEF);
803 netisr_register(NETISR_ARP, arpintr, &arpintrq, 0);
805 SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0);