2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
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 * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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 * $KAME: nd6_nbr.c,v 1.86 2002/01/21 02:33:04 jinmei Exp $
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
36 #include "opt_inet6.h"
37 #include "opt_ipsec.h"
38 #include "opt_mpath.h"
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/malloc.h>
44 #include <sys/rwlock.h>
46 #include <sys/socket.h>
47 #include <sys/sockio.h>
49 #include <sys/kernel.h>
50 #include <sys/errno.h>
51 #include <sys/syslog.h>
52 #include <sys/queue.h>
53 #include <sys/callout.h>
56 #include <net/if_types.h>
57 #include <net/if_dl.h>
58 #include <net/if_var.h>
59 #include <net/route.h>
61 #include <net/radix_mpath.h>
64 #include <netinet/in.h>
65 #include <netinet/in_var.h>
66 #include <net/if_llatbl.h>
67 #define L3_ADDR_SIN6(le) ((struct sockaddr_in6 *) L3_ADDR(le))
68 #include <netinet6/in6_var.h>
69 #include <netinet6/in6_ifattach.h>
70 #include <netinet/ip6.h>
71 #include <netinet6/ip6_var.h>
72 #include <netinet6/scope6_var.h>
73 #include <netinet6/nd6.h>
74 #include <netinet/icmp6.h>
75 #include <netinet/ip_carp.h>
76 #include <netinet6/send.h>
78 #define SDL(s) ((struct sockaddr_dl *)s)
81 static struct dadq *nd6_dad_find(struct ifaddr *);
82 static void nd6_dad_starttimer(struct dadq *, int);
83 static void nd6_dad_stoptimer(struct dadq *);
84 static void nd6_dad_timer(struct dadq *);
85 static void nd6_dad_ns_output(struct dadq *, struct ifaddr *);
86 static void nd6_dad_ns_input(struct ifaddr *);
87 static void nd6_dad_na_input(struct ifaddr *);
88 static void nd6_na_output_fib(struct ifnet *, const struct in6_addr *,
89 const struct in6_addr *, u_long, int, struct sockaddr *, u_int);
91 VNET_DEFINE(int, dad_ignore_ns) = 0; /* ignore NS in DAD - specwise incorrect*/
92 VNET_DEFINE(int, dad_maxtry) = 15; /* max # of *tries* to transmit DAD packet */
93 #define V_dad_ignore_ns VNET(dad_ignore_ns)
94 #define V_dad_maxtry VNET(dad_maxtry)
97 * Input a Neighbor Solicitation Message.
100 * Based on RFC 2462 (duplicate address detection)
103 nd6_ns_input(struct mbuf *m, int off, int icmp6len)
105 struct ifnet *ifp = m->m_pkthdr.rcvif;
106 struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
107 struct nd_neighbor_solicit *nd_ns;
108 struct in6_addr saddr6 = ip6->ip6_src;
109 struct in6_addr daddr6 = ip6->ip6_dst;
110 struct in6_addr taddr6;
111 struct in6_addr myaddr6;
113 struct ifaddr *ifa = NULL;
115 int anycast = 0, proxy = 0, tentative = 0;
118 union nd_opts ndopts;
119 struct sockaddr_dl proxydl;
120 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
122 rflag = (V_ip6_forwarding) ? ND_NA_FLAG_ROUTER : 0;
123 if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV && V_ip6_norbit_raif)
125 #ifndef PULLDOWN_TEST
126 IP6_EXTHDR_CHECK(m, off, icmp6len,);
127 nd_ns = (struct nd_neighbor_solicit *)((caddr_t)ip6 + off);
129 IP6_EXTHDR_GET(nd_ns, struct nd_neighbor_solicit *, m, off, icmp6len);
131 ICMP6STAT_INC(icp6s_tooshort);
135 ip6 = mtod(m, struct ip6_hdr *); /* adjust pointer for safety */
136 taddr6 = nd_ns->nd_ns_target;
137 if (in6_setscope(&taddr6, ifp, NULL) != 0)
140 if (ip6->ip6_hlim != 255) {
142 "nd6_ns_input: invalid hlim (%d) from %s to %s on %s\n",
143 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
144 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
148 if (IN6_IS_ADDR_UNSPECIFIED(&saddr6)) {
149 /* dst has to be a solicited node multicast address. */
150 if (daddr6.s6_addr16[0] == IPV6_ADDR_INT16_MLL &&
151 /* don't check ifindex portion */
152 daddr6.s6_addr32[1] == 0 &&
153 daddr6.s6_addr32[2] == IPV6_ADDR_INT32_ONE &&
154 daddr6.s6_addr8[12] == 0xff) {
157 nd6log((LOG_INFO, "nd6_ns_input: bad DAD packet "
158 "(wrong ip6 dst)\n"));
161 } else if (!V_nd6_onlink_ns_rfc4861) {
162 struct sockaddr_in6 src_sa6;
165 * According to recent IETF discussions, it is not a good idea
166 * to accept a NS from an address which would not be deemed
167 * to be a neighbor otherwise. This point is expected to be
168 * clarified in future revisions of the specification.
170 bzero(&src_sa6, sizeof(src_sa6));
171 src_sa6.sin6_family = AF_INET6;
172 src_sa6.sin6_len = sizeof(src_sa6);
173 src_sa6.sin6_addr = saddr6;
174 if (nd6_is_addr_neighbor(&src_sa6, ifp) == 0) {
175 nd6log((LOG_INFO, "nd6_ns_input: "
176 "NS packet from non-neighbor\n"));
181 if (IN6_IS_ADDR_MULTICAST(&taddr6)) {
182 nd6log((LOG_INFO, "nd6_ns_input: bad NS target (multicast)\n"));
186 icmp6len -= sizeof(*nd_ns);
187 nd6_option_init(nd_ns + 1, icmp6len, &ndopts);
188 if (nd6_options(&ndopts) < 0) {
190 "nd6_ns_input: invalid ND option, ignored\n"));
191 /* nd6_options have incremented stats */
195 if (ndopts.nd_opts_src_lladdr) {
196 lladdr = (char *)(ndopts.nd_opts_src_lladdr + 1);
197 lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
200 if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) && lladdr) {
201 nd6log((LOG_INFO, "nd6_ns_input: bad DAD packet "
202 "(link-layer address option)\n"));
207 * Attaching target link-layer address to the NA?
210 * NS IP dst is unicast/anycast MUST NOT add
211 * NS IP dst is solicited-node multicast MUST add
213 * In implementation, we add target link-layer address by default.
214 * We do not add one in MUST NOT cases.
216 if (!IN6_IS_ADDR_MULTICAST(&daddr6))
222 * Target address (taddr6) must be either:
223 * (1) Valid unicast/anycast address for my receiving interface,
224 * (2) Unicast address for which I'm offering proxy service, or
225 * (3) "tentative" address on which DAD is being performed.
227 /* (1) and (3) check. */
229 ifa = (*carp_iamatch6_p)(ifp, &taddr6);
231 ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, &taddr6);
236 struct sockaddr_in6 tsin6;
242 bzero(&tsin6, sizeof tsin6);
243 tsin6.sin6_len = sizeof(struct sockaddr_in6);
244 tsin6.sin6_family = AF_INET6;
245 tsin6.sin6_addr = taddr6;
247 /* Always use the default FIB. */
249 bzero(&ro, sizeof(ro));
251 rtalloc_mpath_fib((struct route *)&ro, RTF_ANNOUNCE,
255 rt = in6_rtalloc1((struct sockaddr *)&tsin6, 0, 0,
258 need_proxy = (rt && (rt->rt_flags & RTF_ANNOUNCE) != 0 &&
259 rt->rt_gateway->sa_family == AF_LINK);
262 * Make a copy while we can be sure that rt_gateway
263 * is still stable before unlocking to avoid lock
264 * order problems. proxydl will only be used if
265 * proxy will be set in the next block.
268 proxydl = *SDL(rt->rt_gateway);
273 * proxy NDP for single entry
275 ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp,
276 IN6_IFF_NOTREADY|IN6_IFF_ANYCAST);
283 * We've got an NS packet, and we don't have that adddress
284 * assigned for us. We MUST silently ignore it.
289 myaddr6 = *IFA_IN6(ifa);
290 anycast = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST;
291 tentative = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE;
292 if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED)
295 if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
296 nd6log((LOG_INFO, "nd6_ns_input: lladdrlen mismatch for %s "
297 "(if %d, NS packet %d)\n",
298 ip6_sprintf(ip6bufs, &taddr6),
299 ifp->if_addrlen, lladdrlen - 2));
303 if (IN6_ARE_ADDR_EQUAL(&myaddr6, &saddr6)) {
304 nd6log((LOG_INFO, "nd6_ns_input: duplicate IP6 address %s\n",
305 ip6_sprintf(ip6bufs, &saddr6)));
310 * We have neighbor solicitation packet, with target address equals to
311 * one of my tentative address.
313 * src addr how to process?
315 * multicast of course, invalid (rejected in ip6_input)
316 * unicast somebody is doing address resolution -> ignore
317 * unspec dup address detection
319 * The processing is defined in RFC 2462.
323 * If source address is unspecified address, it is for
324 * duplicate address detection.
326 * If not, the packet is for addess resolution;
327 * silently ignore it.
329 if (IN6_IS_ADDR_UNSPECIFIED(&saddr6))
330 nd6_dad_ns_input(ifa);
336 * If the source address is unspecified address, entries must not
337 * be created or updated.
338 * It looks that sender is performing DAD. Output NA toward
339 * all-node multicast address, to tell the sender that I'm using
341 * S bit ("solicited") must be zero.
343 if (IN6_IS_ADDR_UNSPECIFIED(&saddr6)) {
344 struct in6_addr in6_all;
346 in6_all = in6addr_linklocal_allnodes;
347 if (in6_setscope(&in6_all, ifp, NULL) != 0)
349 nd6_na_output_fib(ifp, &in6_all, &taddr6,
350 ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
351 rflag, tlladdr, proxy ? (struct sockaddr *)&proxydl : NULL,
356 nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen,
357 ND_NEIGHBOR_SOLICIT, 0);
359 nd6_na_output_fib(ifp, &saddr6, &taddr6,
360 ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
361 rflag | ND_NA_FLAG_SOLICITED, tlladdr,
362 proxy ? (struct sockaddr *)&proxydl : NULL, M_GETFIB(m));
370 nd6log((LOG_ERR, "nd6_ns_input: src=%s\n",
371 ip6_sprintf(ip6bufs, &saddr6)));
372 nd6log((LOG_ERR, "nd6_ns_input: dst=%s\n",
373 ip6_sprintf(ip6bufs, &daddr6)));
374 nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n",
375 ip6_sprintf(ip6bufs, &taddr6)));
376 ICMP6STAT_INC(icp6s_badns);
383 * Output a Neighbor Solicitation Message. Caller specifies:
384 * - ICMP6 header source IP6 address
385 * - ND6 header target IP6 address
386 * - ND6 header source datalink address
389 * Based on RFC 2462 (duplicate address detection)
391 * ln - for source address determination
392 * dad - duplicate address detection
395 nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
396 const struct in6_addr *taddr6, struct llentry *ln, int dad)
401 struct nd_neighbor_solicit *nd_ns;
402 struct ip6_moptions im6o;
408 if (IN6_IS_ADDR_MULTICAST(taddr6))
411 /* estimate the size of message */
412 maxlen = sizeof(*ip6) + sizeof(*nd_ns);
413 maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
414 if (max_linkhdr + maxlen >= MCLBYTES) {
416 printf("nd6_ns_output: max_linkhdr + maxlen >= MCLBYTES "
417 "(%d + %d > %d)\n", max_linkhdr, maxlen, MCLBYTES);
422 MGETHDR(m, M_NOWAIT, MT_DATA);
423 if (m && max_linkhdr + maxlen >= MHLEN) {
425 if ((m->m_flags & M_EXT) == 0) {
432 m->m_pkthdr.rcvif = NULL;
434 bzero(&ro, sizeof(ro));
436 if (daddr6 == NULL || IN6_IS_ADDR_MULTICAST(daddr6)) {
437 m->m_flags |= M_MCAST;
438 im6o.im6o_multicast_ifp = ifp;
439 im6o.im6o_multicast_hlim = 255;
440 im6o.im6o_multicast_loop = 0;
443 icmp6len = sizeof(*nd_ns);
444 m->m_pkthdr.len = m->m_len = sizeof(*ip6) + icmp6len;
445 m->m_data += max_linkhdr; /* or MH_ALIGN() equivalent? */
447 /* fill neighbor solicitation packet */
448 ip6 = mtod(m, struct ip6_hdr *);
450 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
451 ip6->ip6_vfc |= IPV6_VERSION;
452 /* ip6->ip6_plen will be set later */
453 ip6->ip6_nxt = IPPROTO_ICMPV6;
456 ip6->ip6_dst = *daddr6;
458 ip6->ip6_dst.s6_addr16[0] = IPV6_ADDR_INT16_MLL;
459 ip6->ip6_dst.s6_addr16[1] = 0;
460 ip6->ip6_dst.s6_addr32[1] = 0;
461 ip6->ip6_dst.s6_addr32[2] = IPV6_ADDR_INT32_ONE;
462 ip6->ip6_dst.s6_addr32[3] = taddr6->s6_addr32[3];
463 ip6->ip6_dst.s6_addr8[12] = 0xff;
464 if (in6_setscope(&ip6->ip6_dst, ifp, NULL) != 0)
472 * "If the source address of the packet prompting the
473 * solicitation is the same as one of the addresses assigned
474 * to the outgoing interface, that address SHOULD be placed
475 * in the IP Source Address of the outgoing solicitation.
476 * Otherwise, any one of the addresses assigned to the
477 * interface should be used."
479 * We use the source address for the prompting packet
481 * - saddr6 is given from the caller (by giving "ln"), and
482 * - saddr6 belongs to the outgoing interface.
483 * Otherwise, we perform the source address selection as usual.
485 struct in6_addr *hsrc;
490 if (ln->la_hold != NULL) {
491 struct ip6_hdr *hip6; /* hold ip6 */
494 * assuming every packet in la_hold has the same IP
497 hip6 = mtod(ln->la_hold, struct ip6_hdr *);
499 if (sizeof(*hip6) < ln->la_hold->m_len) {
500 ip6->ip6_src = hip6->ip6_src;
501 hsrc = &hip6->ip6_src;
506 if (hsrc && (ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp,
508 /* ip6_src set already. */
512 struct sockaddr_in6 dst_sa;
513 struct in6_addr src_in;
516 bzero(&dst_sa, sizeof(dst_sa));
517 dst_sa.sin6_family = AF_INET6;
518 dst_sa.sin6_len = sizeof(dst_sa);
519 dst_sa.sin6_addr = ip6->ip6_dst;
522 error = in6_selectsrc(&dst_sa, NULL,
523 NULL, &ro, NULL, &oifp, &src_in);
525 char ip6buf[INET6_ADDRSTRLEN];
527 "nd6_ns_output: source can't be "
528 "determined: dst=%s, error=%d\n",
529 ip6_sprintf(ip6buf, &dst_sa.sin6_addr),
533 ip6->ip6_src = src_in;
537 * Source address for DAD packet must always be IPv6
538 * unspecified address. (0::0)
539 * We actually don't have to 0-clear the address (we did it
540 * above), but we do so here explicitly to make the intention
543 bzero(&ip6->ip6_src, sizeof(ip6->ip6_src));
545 nd_ns = (struct nd_neighbor_solicit *)(ip6 + 1);
546 nd_ns->nd_ns_type = ND_NEIGHBOR_SOLICIT;
547 nd_ns->nd_ns_code = 0;
548 nd_ns->nd_ns_reserved = 0;
549 nd_ns->nd_ns_target = *taddr6;
550 in6_clearscope(&nd_ns->nd_ns_target); /* XXX */
553 * Add source link-layer address option.
555 * spec implementation
557 * DAD packet MUST NOT do not add the option
558 * there's no link layer address:
559 * impossible do not add the option
560 * there's link layer address:
561 * Multicast NS MUST add one add the option
562 * Unicast NS SHOULD add one add the option
564 if (!dad && (mac = nd6_ifptomac(ifp))) {
565 int optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen;
566 struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_ns + 1);
567 /* 8 byte alignments... */
568 optlen = (optlen + 7) & ~7;
570 m->m_pkthdr.len += optlen;
573 bzero((caddr_t)nd_opt, optlen);
574 nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
575 nd_opt->nd_opt_len = optlen >> 3;
576 bcopy(mac, (caddr_t)(nd_opt + 1), ifp->if_addrlen);
579 ip6->ip6_plen = htons((u_short)icmp6len);
580 nd_ns->nd_ns_cksum = 0;
582 in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), icmp6len);
584 if (send_sendso_input_hook != NULL) {
585 mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
586 sizeof(unsigned short), M_NOWAIT);
589 *(unsigned short *)(mtag + 1) = nd_ns->nd_ns_type;
590 m_tag_prepend(m, mtag);
593 ip6_output(m, NULL, &ro, dad ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL);
594 icmp6_ifstat_inc(ifp, ifs6_out_msg);
595 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
596 ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_SOLICIT]);
598 /* We don't cache this route. */
612 * Neighbor advertisement input handling.
615 * Based on RFC 2462 (duplicate address detection)
617 * the following items are not implemented yet:
618 * - proxy advertisement delay rule (RFC2461 7.2.8, last paragraph, SHOULD)
619 * - anycast advertisement delay rule (RFC2461 7.2.7, SHOULD)
622 nd6_na_input(struct mbuf *m, int off, int icmp6len)
624 struct ifnet *ifp = m->m_pkthdr.rcvif;
625 struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
626 struct nd_neighbor_advert *nd_na;
627 struct in6_addr daddr6 = ip6->ip6_dst;
628 struct in6_addr taddr6;
637 struct llentry *ln = NULL;
638 union nd_opts ndopts;
639 struct mbuf *chain = NULL;
641 struct sockaddr_in6 sin6;
642 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
644 if (ip6->ip6_hlim != 255) {
646 "nd6_na_input: invalid hlim (%d) from %s to %s on %s\n",
647 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
648 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
652 #ifndef PULLDOWN_TEST
653 IP6_EXTHDR_CHECK(m, off, icmp6len,);
654 nd_na = (struct nd_neighbor_advert *)((caddr_t)ip6 + off);
656 IP6_EXTHDR_GET(nd_na, struct nd_neighbor_advert *, m, off, icmp6len);
658 ICMP6STAT_INC(icp6s_tooshort);
663 flags = nd_na->nd_na_flags_reserved;
664 is_router = ((flags & ND_NA_FLAG_ROUTER) != 0);
665 is_solicited = ((flags & ND_NA_FLAG_SOLICITED) != 0);
666 is_override = ((flags & ND_NA_FLAG_OVERRIDE) != 0);
668 taddr6 = nd_na->nd_na_target;
669 if (in6_setscope(&taddr6, ifp, NULL))
670 goto bad; /* XXX: impossible */
672 if (IN6_IS_ADDR_MULTICAST(&taddr6)) {
674 "nd6_na_input: invalid target address %s\n",
675 ip6_sprintf(ip6bufs, &taddr6)));
678 if (IN6_IS_ADDR_MULTICAST(&daddr6))
681 "nd6_na_input: a solicited adv is multicasted\n"));
685 icmp6len -= sizeof(*nd_na);
686 nd6_option_init(nd_na + 1, icmp6len, &ndopts);
687 if (nd6_options(&ndopts) < 0) {
689 "nd6_na_input: invalid ND option, ignored\n"));
690 /* nd6_options have incremented stats */
694 if (ndopts.nd_opts_tgt_lladdr) {
695 lladdr = (char *)(ndopts.nd_opts_tgt_lladdr + 1);
696 lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
700 * This effectively disables the DAD check on a non-master CARP
704 ifa = (*carp_iamatch6_p)(ifp, &taddr6);
706 ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, &taddr6);
709 * Target address matches one of my interface address.
711 * If my address is tentative, this means that there's somebody
712 * already using the same address as mine. This indicates DAD failure.
713 * This is defined in RFC 2462.
715 * Otherwise, process as defined in RFC 2461.
718 && (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE)) {
720 nd6_dad_na_input(ifa);
724 /* Just for safety, maybe unnecessary. */
728 "nd6_na_input: duplicate IP6 address %s\n",
729 ip6_sprintf(ip6bufs, &taddr6));
733 if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
734 nd6log((LOG_INFO, "nd6_na_input: lladdrlen mismatch for %s "
735 "(if %d, NA packet %d)\n", ip6_sprintf(ip6bufs, &taddr6),
736 ifp->if_addrlen, lladdrlen - 2));
741 * If no neighbor cache entry is found, NA SHOULD silently be
745 ln = nd6_lookup(&taddr6, LLE_EXCLUSIVE, ifp);
746 IF_AFDATA_UNLOCK(ifp);
751 if (ln->ln_state == ND6_LLINFO_INCOMPLETE) {
753 * If the link-layer has address, and no lladdr option came,
754 * discard the packet.
756 if (ifp->if_addrlen && lladdr == NULL) {
761 * Record link-layer address, and update the state.
763 bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
764 ln->la_flags |= LLE_VALID;
765 EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
767 ln->ln_state = ND6_LLINFO_REACHABLE;
769 if (!ND6_LLINFO_PERMANENT(ln)) {
770 nd6_llinfo_settimer_locked(ln,
771 (long)ND_IFINFO(ln->lle_tbl->llt_ifp)->reachable * hz);
774 ln->ln_state = ND6_LLINFO_STALE;
775 nd6_llinfo_settimer_locked(ln, (long)V_nd6_gctimer * hz);
777 if ((ln->ln_router = is_router) != 0) {
779 * This means a router's state has changed from
780 * non-reachable to probably reachable, and might
781 * affect the status of associated prefixes..
789 * Check if the link-layer address has changed or not.
794 if (ln->la_flags & LLE_VALID) {
795 if (bcmp(lladdr, &ln->ll_addr, ifp->if_addrlen))
804 * This is VERY complex. Look at it with care.
806 * override solicit lladdr llchange action
811 * 0 0 y y (1) REACHABLE->STALE
812 * 0 1 n -- (2c) *->REACHABLE
813 * 0 1 y n (2b) L *->REACHABLE
814 * 0 1 y y (1) REACHABLE->STALE
817 * 1 0 y y (2a) L *->STALE
818 * 1 1 n -- (2a) *->REACHABLE
819 * 1 1 y n (2a) L *->REACHABLE
820 * 1 1 y y (2a) L *->REACHABLE
822 if (!is_override && (lladdr != NULL && llchange)) { /* (1) */
824 * If state is REACHABLE, make it STALE.
825 * no other updates should be done.
827 if (ln->ln_state == ND6_LLINFO_REACHABLE) {
828 ln->ln_state = ND6_LLINFO_STALE;
829 nd6_llinfo_settimer_locked(ln, (long)V_nd6_gctimer * hz);
832 } else if (is_override /* (2a) */
833 || (!is_override && (lladdr != NULL && !llchange)) /* (2b) */
834 || lladdr == NULL) { /* (2c) */
836 * Update link-local address, if any.
838 if (lladdr != NULL) {
839 bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
840 ln->la_flags |= LLE_VALID;
841 EVENTHANDLER_INVOKE(lle_event, ln,
846 * If solicited, make the state REACHABLE.
847 * If not solicited and the link-layer address was
848 * changed, make it STALE.
851 ln->ln_state = ND6_LLINFO_REACHABLE;
853 if (!ND6_LLINFO_PERMANENT(ln)) {
854 nd6_llinfo_settimer_locked(ln,
855 (long)ND_IFINFO(ifp)->reachable * hz);
858 if (lladdr != NULL && llchange) {
859 ln->ln_state = ND6_LLINFO_STALE;
860 nd6_llinfo_settimer_locked(ln,
861 (long)V_nd6_gctimer * hz);
866 if (ln->ln_router && !is_router) {
868 * The peer dropped the router flag.
869 * Remove the sender from the Default Router List and
870 * update the Destination Cache entries.
872 struct nd_defrouter *dr;
873 struct in6_addr *in6;
875 in6 = &L3_ADDR_SIN6(ln)->sin6_addr;
878 * Lock to protect the default router list.
879 * XXX: this might be unnecessary, since this function
880 * is only called under the network software interrupt
881 * context. However, we keep it just for safety.
883 dr = defrouter_lookup(in6, ln->lle_tbl->llt_ifp);
886 else if (ND_IFINFO(ln->lle_tbl->llt_ifp)->flags &
887 ND6_IFF_ACCEPT_RTADV) {
889 * Even if the neighbor is not in the default
890 * router list, the neighbor may be used
891 * as a next hop for some destinations
892 * (e.g. redirect case). So we must
893 * call rt6_flush explicitly.
895 rt6_flush(&ip6->ip6_src, ifp);
898 ln->ln_router = is_router;
902 * rt->rt_flags &= ~RTF_REJECT;
906 struct mbuf *m_hold, *m_hold_next;
909 * reset the la_hold in advance, to explicitly
910 * prevent a la_hold lookup in nd6_output()
911 * (wouldn't happen, though...)
913 for (m_hold = ln->la_hold, ln->la_hold = NULL;
914 m_hold; m_hold = m_hold_next) {
915 m_hold_next = m_hold->m_nextpkt;
916 m_hold->m_nextpkt = NULL;
918 * we assume ifp is not a loopback here, so just set
919 * the 2nd argument as the 1st one.
922 if (send_sendso_input_hook != NULL) {
923 mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
924 sizeof(unsigned short), M_NOWAIT);
927 m_tag_prepend(m, mtag);
930 nd6_output_lle(ifp, ifp, m_hold, L3_ADDR_SIN6(ln), NULL, ln, &chain);
936 memcpy(&sin6, L3_ADDR_SIN6(ln), sizeof(sin6));
940 nd6_output_flush(ifp, ifp, chain, &sin6, NULL);
943 pfxlist_onlink_check();
952 ICMP6STAT_INC(icp6s_badna);
957 * Neighbor advertisement output handling.
961 * the following items are not implemented yet:
962 * - proxy advertisement delay rule (RFC2461 7.2.8, last paragraph, SHOULD)
963 * - anycast advertisement delay rule (RFC2461 7.2.7, SHOULD)
965 * tlladdr - 1 if include target link-layer address
966 * sdl0 - sockaddr_dl (= proxy NA) or NULL
969 nd6_na_output_fib(struct ifnet *ifp, const struct in6_addr *daddr6_0,
970 const struct in6_addr *taddr6, u_long flags, int tlladdr,
971 struct sockaddr *sdl0, u_int fibnum)
977 struct nd_neighbor_advert *nd_na;
978 struct ip6_moptions im6o;
979 struct in6_addr src, daddr6;
980 struct sockaddr_in6 dst_sa;
981 int icmp6len, maxlen, error;
985 bzero(&ro, sizeof(ro));
987 daddr6 = *daddr6_0; /* make a local copy for modification */
989 /* estimate the size of message */
990 maxlen = sizeof(*ip6) + sizeof(*nd_na);
991 maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
992 if (max_linkhdr + maxlen >= MCLBYTES) {
994 printf("nd6_na_output: max_linkhdr + maxlen >= MCLBYTES "
995 "(%d + %d > %d)\n", max_linkhdr, maxlen, MCLBYTES);
1000 MGETHDR(m, M_NOWAIT, MT_DATA);
1001 if (m && max_linkhdr + maxlen >= MHLEN) {
1002 MCLGET(m, M_NOWAIT);
1003 if ((m->m_flags & M_EXT) == 0) {
1010 m->m_pkthdr.rcvif = NULL;
1011 M_SETFIB(m, fibnum);
1013 if (IN6_IS_ADDR_MULTICAST(&daddr6)) {
1014 m->m_flags |= M_MCAST;
1015 im6o.im6o_multicast_ifp = ifp;
1016 im6o.im6o_multicast_hlim = 255;
1017 im6o.im6o_multicast_loop = 0;
1020 icmp6len = sizeof(*nd_na);
1021 m->m_pkthdr.len = m->m_len = sizeof(struct ip6_hdr) + icmp6len;
1022 m->m_data += max_linkhdr; /* or MH_ALIGN() equivalent? */
1024 /* fill neighbor advertisement packet */
1025 ip6 = mtod(m, struct ip6_hdr *);
1027 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
1028 ip6->ip6_vfc |= IPV6_VERSION;
1029 ip6->ip6_nxt = IPPROTO_ICMPV6;
1030 ip6->ip6_hlim = 255;
1031 if (IN6_IS_ADDR_UNSPECIFIED(&daddr6)) {
1033 daddr6.s6_addr16[0] = IPV6_ADDR_INT16_MLL;
1034 daddr6.s6_addr16[1] = 0;
1035 daddr6.s6_addr32[1] = 0;
1036 daddr6.s6_addr32[2] = 0;
1037 daddr6.s6_addr32[3] = IPV6_ADDR_INT32_ONE;
1038 if (in6_setscope(&daddr6, ifp, NULL))
1041 flags &= ~ND_NA_FLAG_SOLICITED;
1043 ip6->ip6_dst = daddr6;
1044 bzero(&dst_sa, sizeof(struct sockaddr_in6));
1045 dst_sa.sin6_family = AF_INET6;
1046 dst_sa.sin6_len = sizeof(struct sockaddr_in6);
1047 dst_sa.sin6_addr = daddr6;
1050 * Select a source whose scope is the same as that of the dest.
1052 bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa));
1054 error = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL, &oifp, &src);
1056 char ip6buf[INET6_ADDRSTRLEN];
1057 nd6log((LOG_DEBUG, "nd6_na_output: source can't be "
1058 "determined: dst=%s, error=%d\n",
1059 ip6_sprintf(ip6buf, &dst_sa.sin6_addr), error));
1063 nd_na = (struct nd_neighbor_advert *)(ip6 + 1);
1064 nd_na->nd_na_type = ND_NEIGHBOR_ADVERT;
1065 nd_na->nd_na_code = 0;
1066 nd_na->nd_na_target = *taddr6;
1067 in6_clearscope(&nd_na->nd_na_target); /* XXX */
1070 * "tlladdr" indicates NS's condition for adding tlladdr or not.
1071 * see nd6_ns_input() for details.
1072 * Basically, if NS packet is sent to unicast/anycast addr,
1073 * target lladdr option SHOULD NOT be included.
1077 * sdl0 != NULL indicates proxy NA. If we do proxy, use
1078 * lladdr in sdl0. If we are not proxying (sending NA for
1079 * my address) use lladdr configured for the interface.
1083 mac = (*carp_macmatch6_p)(ifp, m, taddr6);
1085 mac = nd6_ifptomac(ifp);
1086 } else if (sdl0->sa_family == AF_LINK) {
1087 struct sockaddr_dl *sdl;
1088 sdl = (struct sockaddr_dl *)sdl0;
1089 if (sdl->sdl_alen == ifp->if_addrlen)
1093 if (tlladdr && mac) {
1094 int optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen;
1095 struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_na + 1);
1097 /* roundup to 8 bytes alignment! */
1098 optlen = (optlen + 7) & ~7;
1100 m->m_pkthdr.len += optlen;
1103 bzero((caddr_t)nd_opt, optlen);
1104 nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
1105 nd_opt->nd_opt_len = optlen >> 3;
1106 bcopy(mac, (caddr_t)(nd_opt + 1), ifp->if_addrlen);
1108 flags &= ~ND_NA_FLAG_OVERRIDE;
1110 ip6->ip6_plen = htons((u_short)icmp6len);
1111 nd_na->nd_na_flags_reserved = flags;
1112 nd_na->nd_na_cksum = 0;
1113 nd_na->nd_na_cksum =
1114 in6_cksum(m, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), icmp6len);
1116 if (send_sendso_input_hook != NULL) {
1117 mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
1118 sizeof(unsigned short), M_NOWAIT);
1121 *(unsigned short *)(mtag + 1) = nd_na->nd_na_type;
1122 m_tag_prepend(m, mtag);
1125 ip6_output(m, NULL, &ro, 0, &im6o, NULL, NULL);
1126 icmp6_ifstat_inc(ifp, ifs6_out_msg);
1127 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
1128 ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_ADVERT]);
1130 /* We don't cache this route. */
1143 #ifndef BURN_BRIDGES
1145 nd6_na_output(struct ifnet *ifp, const struct in6_addr *daddr6_0,
1146 const struct in6_addr *taddr6, u_long flags, int tlladdr,
1147 struct sockaddr *sdl0)
1150 nd6_na_output_fib(ifp, daddr6_0, taddr6, flags, tlladdr, sdl0,
1156 nd6_ifptomac(struct ifnet *ifp)
1158 switch (ifp->if_type) {
1166 #ifdef IFT_IEEE80211
1169 case IFT_INFINIBAND:
1172 return IF_LLADDR(ifp);
1179 TAILQ_ENTRY(dadq) dad_list;
1180 struct ifaddr *dad_ifa;
1181 int dad_count; /* max NS to send */
1182 int dad_ns_tcount; /* # of trials to send NS */
1183 int dad_ns_ocount; /* NS sent so far */
1186 struct callout dad_timer_ch;
1187 struct vnet *dad_vnet;
1190 static VNET_DEFINE(TAILQ_HEAD(, dadq), dadq);
1191 VNET_DEFINE(int, dad_init) = 0;
1192 #define V_dadq VNET(dadq)
1193 #define V_dad_init VNET(dad_init)
1195 static struct dadq *
1196 nd6_dad_find(struct ifaddr *ifa)
1200 TAILQ_FOREACH(dp, &V_dadq, dad_list)
1201 if (dp->dad_ifa == ifa)
1208 nd6_dad_starttimer(struct dadq *dp, int ticks)
1211 callout_reset(&dp->dad_timer_ch, ticks,
1212 (void (*)(void *))nd6_dad_timer, (void *)dp);
1216 nd6_dad_stoptimer(struct dadq *dp)
1219 callout_stop(&dp->dad_timer_ch);
1223 * Start Duplicate Address Detection (DAD) for specified interface address.
1226 nd6_dad_start(struct ifaddr *ifa, int delay)
1228 struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
1230 char ip6buf[INET6_ADDRSTRLEN];
1233 TAILQ_INIT(&V_dadq);
1238 * If we don't need DAD, don't do it.
1239 * There are several cases:
1240 * - DAD is disabled (ip6_dad_count == 0)
1241 * - the interface address is anycast
1243 if (!(ia->ia6_flags & IN6_IFF_TENTATIVE)) {
1245 "nd6_dad_start: called with non-tentative address "
1247 ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
1248 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
1251 if (ia->ia6_flags & IN6_IFF_ANYCAST) {
1252 ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
1255 if (!V_ip6_dad_count) {
1256 ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
1259 if (ifa->ifa_ifp == NULL)
1260 panic("nd6_dad_start: ifa->ifa_ifp == NULL");
1261 if (!(ifa->ifa_ifp->if_flags & IFF_UP)) {
1264 if (ND_IFINFO(ifa->ifa_ifp)->flags & ND6_IFF_IFDISABLED)
1266 if (nd6_dad_find(ifa) != NULL) {
1267 /* DAD already in progress */
1271 dp = malloc(sizeof(*dp), M_IP6NDP, M_NOWAIT);
1273 log(LOG_ERR, "nd6_dad_start: memory allocation failed for "
1275 ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
1276 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
1279 bzero(dp, sizeof(*dp));
1280 callout_init(&dp->dad_timer_ch, 0);
1282 dp->dad_vnet = curvnet;
1284 TAILQ_INSERT_TAIL(&V_dadq, (struct dadq *)dp, dad_list);
1286 nd6log((LOG_DEBUG, "%s: starting DAD for %s\n", if_name(ifa->ifa_ifp),
1287 ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr)));
1290 * Send NS packet for DAD, ip6_dad_count times.
1291 * Note that we must delay the first transmission, if this is the
1292 * first packet to be sent from the interface after interface
1293 * (re)initialization.
1296 ifa_ref(ifa); /* just for safety */
1297 dp->dad_count = V_ip6_dad_count;
1298 dp->dad_ns_icount = dp->dad_na_icount = 0;
1299 dp->dad_ns_ocount = dp->dad_ns_tcount = 0;
1301 nd6_dad_ns_output(dp, ifa);
1302 nd6_dad_starttimer(dp,
1303 (long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
1305 nd6_dad_starttimer(dp, delay);
1310 * terminate DAD unconditionally. used for address removals.
1313 nd6_dad_stop(struct ifaddr *ifa)
1319 dp = nd6_dad_find(ifa);
1321 /* DAD wasn't started yet */
1325 nd6_dad_stoptimer(dp);
1327 TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
1334 nd6_dad_timer(struct dadq *dp)
1336 CURVNET_SET(dp->dad_vnet);
1337 struct ifaddr *ifa = dp->dad_ifa;
1338 struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
1339 char ip6buf[INET6_ADDRSTRLEN];
1343 log(LOG_ERR, "nd6_dad_timer: called with null parameter\n");
1346 if (ia->ia6_flags & IN6_IFF_DUPLICATED) {
1347 log(LOG_ERR, "nd6_dad_timer: called with duplicated address "
1349 ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
1350 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
1353 if ((ia->ia6_flags & IN6_IFF_TENTATIVE) == 0) {
1354 log(LOG_ERR, "nd6_dad_timer: called with non-tentative address "
1356 ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
1357 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
1361 /* timeouted with IFF_{RUNNING,UP} check */
1362 if (dp->dad_ns_tcount > V_dad_maxtry) {
1363 nd6log((LOG_INFO, "%s: could not run DAD, driver problem?\n",
1364 if_name(ifa->ifa_ifp)));
1366 TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
1373 /* Need more checks? */
1374 if (dp->dad_ns_ocount < dp->dad_count) {
1376 * We have more NS to go. Send NS packet for DAD.
1378 nd6_dad_ns_output(dp, ifa);
1379 nd6_dad_starttimer(dp,
1380 (long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
1383 * We have transmitted sufficient number of DAD packets.
1384 * See what we've got.
1390 if (dp->dad_na_icount) {
1392 * the check is in nd6_dad_na_input(),
1398 if (dp->dad_ns_icount) {
1399 /* We've seen NS, means DAD has failed. */
1404 /* (*dp) will be freed in nd6_dad_duplicated() */
1406 nd6_dad_duplicated(ifa);
1409 * We are done with DAD. No NA came, no NS came.
1410 * No duplicate address found.
1412 ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
1415 "%s: DAD complete for %s - no duplicates found\n",
1416 if_name(ifa->ifa_ifp),
1417 ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr)));
1419 TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
1431 nd6_dad_duplicated(struct ifaddr *ifa)
1433 struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
1436 char ip6buf[INET6_ADDRSTRLEN];
1438 dp = nd6_dad_find(ifa);
1440 log(LOG_ERR, "nd6_dad_duplicated: DAD structure not found\n");
1444 log(LOG_ERR, "%s: DAD detected duplicate IPv6 address %s: "
1445 "NS in/out=%d/%d, NA in=%d\n",
1446 if_name(ifa->ifa_ifp), ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
1447 dp->dad_ns_icount, dp->dad_ns_ocount, dp->dad_na_icount);
1449 ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
1450 ia->ia6_flags |= IN6_IFF_DUPLICATED;
1452 /* We are done with DAD, with duplicate address found. (failure) */
1453 nd6_dad_stoptimer(dp);
1456 log(LOG_ERR, "%s: DAD complete for %s - duplicate found\n",
1457 if_name(ifp), ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr));
1458 log(LOG_ERR, "%s: manual intervention required\n",
1462 * If the address is a link-local address formed from an interface
1463 * identifier based on the hardware address which is supposed to be
1464 * uniquely assigned (e.g., EUI-64 for an Ethernet interface), IP
1465 * operation on the interface SHOULD be disabled.
1466 * [RFC 4862, Section 5.4.5]
1468 if (IN6_IS_ADDR_LINKLOCAL(&ia->ia_addr.sin6_addr)) {
1469 struct in6_addr in6;
1472 * To avoid over-reaction, we only apply this logic when we are
1473 * very sure that hardware addresses are supposed to be unique.
1475 switch (ifp->if_type) {
1480 #ifdef IFT_IEEE80211
1483 case IFT_INFINIBAND:
1484 in6 = ia->ia_addr.sin6_addr;
1485 if (in6_get_hw_ifid(ifp, &in6) == 0 &&
1486 IN6_ARE_ADDR_EQUAL(&ia->ia_addr.sin6_addr, &in6)) {
1487 ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED;
1488 log(LOG_ERR, "%s: possible hardware address "
1489 "duplication detected, disable IPv6\n",
1496 TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
1503 nd6_dad_ns_output(struct dadq *dp, struct ifaddr *ifa)
1505 struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
1506 struct ifnet *ifp = ifa->ifa_ifp;
1508 dp->dad_ns_tcount++;
1509 if ((ifp->if_flags & IFF_UP) == 0) {
1512 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
1516 dp->dad_ns_ocount++;
1517 nd6_ns_output(ifp, NULL, &ia->ia_addr.sin6_addr, NULL, 1);
1521 nd6_dad_ns_input(struct ifaddr *ifa)
1523 struct in6_ifaddr *ia;
1525 const struct in6_addr *taddr6;
1530 panic("ifa == NULL in nd6_dad_ns_input");
1532 ia = (struct in6_ifaddr *)ifa;
1534 taddr6 = &ia->ia_addr.sin6_addr;
1536 dp = nd6_dad_find(ifa);
1538 /* Quickhack - completely ignore DAD NS packets */
1539 if (V_dad_ignore_ns) {
1540 char ip6buf[INET6_ADDRSTRLEN];
1542 "nd6_dad_ns_input: ignoring DAD NS packet for "
1543 "address %s(%s)\n", ip6_sprintf(ip6buf, taddr6),
1544 if_name(ifa->ifa_ifp)));
1549 * if I'm yet to start DAD, someone else started using this address
1550 * first. I have a duplicate and you win.
1552 if (dp == NULL || dp->dad_ns_ocount == 0)
1555 /* XXX more checks for loopback situation - see nd6_dad_timer too */
1558 dp = NULL; /* will be freed in nd6_dad_duplicated() */
1559 nd6_dad_duplicated(ifa);
1562 * not sure if I got a duplicate.
1563 * increment ns count and see what happens.
1566 dp->dad_ns_icount++;
1571 nd6_dad_na_input(struct ifaddr *ifa)
1576 panic("ifa == NULL in nd6_dad_na_input");
1578 dp = nd6_dad_find(ifa);
1580 dp->dad_na_icount++;
1582 /* remove the address. */
1583 nd6_dad_duplicated(ifa);