43#include <sys/eventhandler.h>
44#include <sys/malloc.h>
45#include <sys/libkern.h>
47#include <sys/rwlock.h>
49#include <sys/socket.h>
50#include <sys/sockio.h>
52#include <sys/kernel.h>
54#include <sys/sysctl.h>
55#include <sys/syslog.h>
57#include <sys/callout.h>
58#include <sys/refcount.h>
61#include <net/if_types.h>
63#include <net/if_var.h>
67#include <netinet/in.h>
68#include <netinet/in_var.h>
69#include <net/if_llatbl.h>
72#include <netinet/ip6.h>
76#include <netinet/icmp6.h>
77#include <netinet/ip_carp.h>
80#define SDL(s) ((struct sockaddr_dl *)s)
95 const struct in6_addr *, u_long,
int,
struct sockaddr *, u_int);
100#define V_dad_enhanced VNET(dad_enhanced)
103SYSCTL_INT(_net_inet6_ip6, OID_AUTO, dad_enhanced, CTLFLAG_VNET | CTLFLAG_RW,
104 &VNET_NAME(dad_enhanced), 0,
105 "Enable Enhanced DAD, which adds a random nonce to NS messages for DAD.");
109#define V_dad_maxtry VNET(dad_maxtry)
122 struct nd_neighbor_solicit *nd_ns;
123 struct in6_addr daddr6, myaddr6, saddr6, taddr6;
125 struct sockaddr_dl proxydl;
129 int anycast, lladdrlen, proxy, rflag, tentative, tlladdr;
137 ifp = m->m_pkthdr.rcvif;
138 ip6 = mtod(m,
struct ip6_hdr *);
139 if (__predict_false(ip6->ip6_hlim != 255)) {
140 ICMP6STAT_INC(icp6s_invlhlim);
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 (m->m_len < off + icmp6len) {
149 m = m_pullup(m, off + icmp6len);
155 ip6 = mtod(m,
struct ip6_hdr *);
156 nd_ns = (
struct nd_neighbor_solicit *)((caddr_t)ip6 + off);
158 saddr6 = ip6->ip6_src;
159 daddr6 = ip6->ip6_dst;
160 taddr6 = nd_ns->nd_ns_target;
172 daddr6.s6_addr32[1] == 0 &&
174 daddr6.s6_addr8[12] == 0xff) {
177 nd6log((LOG_INFO,
"nd6_ns_input: bad DAD packet "
178 "(wrong ip6 dst)\n"));
190 bzero(&src_sa6,
sizeof(src_sa6));
195 nd6log((LOG_INFO,
"nd6_ns_input: "
196 "NS packet from non-neighbor\n"));
202 nd6log((LOG_INFO,
"nd6_ns_input: bad NS target (multicast)\n"));
206 icmp6len -=
sizeof(*nd_ns);
210 "nd6_ns_input: invalid ND option, ignored\n"));
217 if (ndopts.nd_opts_src_lladdr) {
218 lladdr = (
char *)(ndopts.nd_opts_src_lladdr + 1);
219 lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
223 nd6log((LOG_INFO,
"nd6_ns_input: bad DAD packet "
224 "(link-layer address option)\n"));
251 ifa = (*carp_iamatch6_p)(ifp, &taddr6);
258 struct sockaddr_dl rt_gateway;
259 struct rt_addrinfo info;
262 bzero(&dst6,
sizeof(dst6));
267 bzero(&rt_gateway,
sizeof(rt_gateway));
268 rt_gateway.sdl_len =
sizeof(rt_gateway);
269 bzero(&info,
sizeof(info));
270 info.rti_info[RTAX_GATEWAY] = (
struct sockaddr *)&rt_gateway;
272 if (rib_lookup_info(ifp->if_fib, (
struct sockaddr *)&dst6,
275 rt_gateway.sdl_family == AF_LINK) {
279 proxydl = *
SDL(&rt_gateway);
301 if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
302 nd6log((LOG_INFO,
"nd6_ns_input: lladdrlen mismatch for %s "
303 "(if %d, NS packet %d)\n",
305 ifp->if_addrlen, lladdrlen - 2));
310 nd6log((LOG_INFO,
"nd6_ns_input: duplicate IP6 address %s\n",
356 ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
357 rflag, tlladdr, proxy ? (
struct sockaddr *)&proxydl : NULL,
363 ND_NEIGHBOR_SOLICIT, 0);
366 ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
367 rflag | ND_NA_FLAG_SOLICITED, tlladdr,
368 proxy ? (
struct sockaddr *)&proxydl : NULL, M_GETFIB(m));
376 nd6log((LOG_ERR,
"nd6_ns_input: src=%s\n",
378 nd6log((LOG_ERR,
"nd6_ns_input: dst=%s\n",
380 nd6log((LOG_ERR,
"nd6_ns_input: tgt=%s\n",
383 ICMP6STAT_INC(icp6s_badns);
405 uint8_t *nonce, u_int fibnum)
410 struct nd_neighbor_solicit *nd_ns;
411 struct ip6_moptions im6o;
421 maxlen =
sizeof(*ip6) +
sizeof(*nd_ns);
422 maxlen += (
sizeof(
struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
423 KASSERT(max_linkhdr + maxlen <= MCLBYTES, (
424 "%s: max_linkhdr + maxlen > MCLBYTES (%d + %d > %d)",
425 __func__, max_linkhdr, maxlen, MCLBYTES));
427 if (max_linkhdr + maxlen > MHLEN)
428 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
430 m = m_gethdr(M_NOWAIT, MT_DATA);
436 m->m_flags |= M_MCAST;
437 im6o.im6o_multicast_ifp = ifp;
438 im6o.im6o_multicast_hlim = 255;
439 im6o.im6o_multicast_loop = 0;
442 icmp6len =
sizeof(*nd_ns);
443 m->m_pkthdr.len = m->m_len =
sizeof(*ip6) + icmp6len;
444 m->m_data += max_linkhdr;
447 ip6 = mtod(m,
struct ip6_hdr *);
449 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
450 ip6->ip6_vfc |= IPV6_VERSION;
452 ip6->ip6_nxt = IPPROTO_ICMPV6;
455 ip6->ip6_dst = *daddr6;
458 ip6->ip6_dst.s6_addr16[1] = 0;
459 ip6->ip6_dst.s6_addr32[1] = 0;
461 ip6->ip6_dst.s6_addr32[3] = taddr6->s6_addr32[3];
462 ip6->ip6_dst.s6_addr8[12] = 0xff;
467 struct ifaddr *ifa = NULL;
487 ip6->ip6_src = *saddr6;
496 scopeid, ifp, &src6, NULL);
499 nd6log((LOG_DEBUG,
"%s: source can't be "
500 "determined: dst=%s, error=%d\n", __func__,
515 bzero(&ip6->ip6_src,
sizeof(ip6->ip6_src));
517 nd_ns = (
struct nd_neighbor_solicit *)(ip6 + 1);
518 nd_ns->nd_ns_type = ND_NEIGHBOR_SOLICIT;
519 nd_ns->nd_ns_code = 0;
520 nd_ns->nd_ns_reserved = 0;
521 nd_ns->nd_ns_target = *taddr6;
537 struct nd_opt_hdr *nd_opt;
543 mac = (*carp_macmatch6_p)(ifp, m, &ip6->ip6_src);
548 nd_opt = (
struct nd_opt_hdr *)(nd_ns + 1);
549 optlen =
sizeof(
struct nd_opt_hdr) + ifp->if_addrlen;
551 optlen = (optlen + 7) & ~7;
552 m->m_pkthdr.len += optlen;
555 bzero(nd_opt, optlen);
556 nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
557 nd_opt->nd_opt_len = optlen >> 3;
558 bcopy(mac, nd_opt + 1, ifp->if_addrlen);
568 int optlen =
sizeof(
struct nd_opt_hdr) + ND_OPT_NONCE_LEN;
569 struct nd_opt_hdr *nd_opt = (
struct nd_opt_hdr *)(nd_ns + 1);
571 optlen = (optlen + 7) & ~7;
573 m->m_pkthdr.len += optlen;
576 bzero((caddr_t)nd_opt, optlen);
577 nd_opt->nd_opt_type = ND_OPT_NONCE;
578 nd_opt->nd_opt_len = optlen >> 3;
579 bcopy(nonce, (caddr_t)(nd_opt + 1), ND_OPT_NONCE_LEN);
581 ip6->ip6_plen = htons((u_short)icmp6len);
582 nd_ns->nd_ns_cksum = 0;
584 in6_cksum(m, IPPROTO_ICMPV6,
sizeof(*ip6), icmp6len);
587 mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
588 sizeof(
unsigned short), M_NOWAIT);
591 *(
unsigned short *)(mtag + 1) = nd_ns->nd_ns_type;
592 m_tag_prepend(m, mtag);
597 icmp6_ifstat_inc(ifp, ifs6_out_msg);
598 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
599 ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_SOLICIT]);
610 const struct in6_addr *daddr6,
const struct in6_addr *taddr6,uint8_t *nonce)
634 struct nd_neighbor_advert *nd_na;
637 u_char linkhdr[LLE_MAX_LINKHDR];
641 int flags, is_override, is_router, is_solicited;
642 int lladdr_off, lladdrlen, checklink;
643 bool flush_holdchain =
false;
655 ifp = m->m_pkthdr.rcvif;
656 ip6 = mtod(m,
struct ip6_hdr *);
657 if (__predict_false(ip6->ip6_hlim != 255)) {
658 ICMP6STAT_INC(icp6s_invlhlim);
660 "nd6_na_input: invalid hlim (%d) from %s to %s on %s\n",
661 ip6->ip6_hlim,
ip6_sprintf(ip6bufs, &ip6->ip6_src),
662 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
666 if (m->m_len < off + icmp6len) {
667 m = m_pullup(m, off + icmp6len);
673 ip6 = mtod(m,
struct ip6_hdr *);
674 nd_na = (
struct nd_neighbor_advert *)((caddr_t)ip6 + off);
676 flags = nd_na->nd_na_flags_reserved;
677 is_router = ((flags & ND_NA_FLAG_ROUTER) != 0);
678 is_solicited = ((flags & ND_NA_FLAG_SOLICITED) != 0);
679 is_override = ((flags & ND_NA_FLAG_OVERRIDE) != 0);
681 taddr6 = nd_na->nd_na_target;
687 "nd6_na_input: invalid target address %s\n",
692 daddr6 = ip6->ip6_dst;
696 "nd6_na_input: a solicited adv is multicasted\n"));
700 icmp6len -=
sizeof(*nd_na);
704 "nd6_na_input: invalid ND option, ignored\n"));
711 if (ndopts.nd_opts_tgt_lladdr) {
712 lladdr = (
char *)(ndopts.nd_opts_tgt_lladdr + 1);
713 lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
721 ifa = (*carp_iamatch6_p)(ifp, &taddr6);
745 "nd6_na_input: duplicate IP6 address %s\n",
750 if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
751 nd6log((LOG_INFO,
"nd6_na_input: lladdrlen mismatch for %s "
752 "(if %d, NA packet %d)\n",
ip6_sprintf(ip6bufs, &taddr6),
753 ifp->if_addrlen, lladdrlen - 2));
761 ln =
nd6_lookup(&taddr6, LLE_SF(AF_INET6, LLE_EXCLUSIVE), ifp);
769 if (ln->la_flags & LLE_STATIC)
777 if (ifp->if_addrlen && lladdr == NULL) {
787 flush_holdchain =
true;
788 EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
793 if ((ln->ln_router = is_router) != 0) {
810 if (ln->la_flags & LLE_VALID) {
811 if (bcmp(lladdr, ln->ll_addr, ifp->if_addrlen))
838 if (!is_override && (lladdr != NULL && llchange)) {
846 }
else if (is_override
847 || (!is_override && (lladdr != NULL && !llchange))
852 if (lladdr != NULL) {
853 linkhdrsize =
sizeof(linkhdr);
854 if (lltable_calc_llheader(ifp, AF_INET6, lladdr,
855 linkhdr, &linkhdrsize, &lladdr_off) != 0)
857 if (lltable_try_set_entry_addr(ifp, ln, linkhdr,
858 linkhdrsize, lladdr_off) == 0) {
862 EVENTHANDLER_INVOKE(lle_event, ln,
874 if (lladdr != NULL && llchange)
879 if (ln->ln_router && !is_router) {
885 struct ifnet *nd6_ifp;
887 nd6_ifp = lltable_get_ifp(ln->lle_tbl);
899 ln->ln_router = is_router;
906 if (ln->la_hold != NULL)
927 ICMP6STAT_INC(icp6s_badna);
945 const struct in6_addr *taddr6, u_long flags,
int tlladdr,
946 struct sockaddr *sdl0, u_int fibnum)
951 struct nd_neighbor_advert *nd_na;
952 struct ip6_moptions im6o;
958 int icmp6len, maxlen, error;
964 maxlen =
sizeof(*ip6) +
sizeof(*nd_na);
965 maxlen += (
sizeof(
struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
966 KASSERT(max_linkhdr + maxlen <= MCLBYTES, (
967 "%s: max_linkhdr + maxlen > MCLBYTES (%d + %d > %d)",
968 __func__, max_linkhdr, maxlen, MCLBYTES));
970 if (max_linkhdr + maxlen > MHLEN)
971 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
973 m = m_gethdr(M_NOWAIT, MT_DATA);
979 m->m_flags |= M_MCAST;
980 im6o.im6o_multicast_ifp = ifp;
981 im6o.im6o_multicast_hlim = 255;
982 im6o.im6o_multicast_loop = 0;
985 icmp6len =
sizeof(*nd_na);
986 m->m_pkthdr.len = m->m_len =
sizeof(
struct ip6_hdr) + icmp6len;
987 m->m_data += max_linkhdr;
990 ip6 = mtod(m,
struct ip6_hdr *);
992 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
993 ip6->ip6_vfc |= IPV6_VERSION;
994 ip6->ip6_nxt = IPPROTO_ICMPV6;
999 daddr6.s6_addr16[1] = 0;
1000 daddr6.s6_addr32[1] = 0;
1001 daddr6.s6_addr32[2] = 0;
1006 flags &= ~ND_NA_FLAG_SOLICITED;
1008 ip6->ip6_dst = daddr6;
1015 scopeid, ifp, &src6, NULL);
1018 nd6log((LOG_DEBUG,
"nd6_na_output: source can't be "
1019 "determined: dst=%s, error=%d\n",
1023 ip6->ip6_src = src6;
1024 nd_na = (
struct nd_neighbor_advert *)(ip6 + 1);
1025 nd_na->nd_na_type = ND_NEIGHBOR_ADVERT;
1026 nd_na->nd_na_code = 0;
1027 nd_na->nd_na_target = *taddr6;
1044 mac = (*carp_macmatch6_p)(ifp, m, taddr6);
1047 }
else if (sdl0->sa_family == AF_LINK) {
1048 struct sockaddr_dl *sdl;
1049 sdl = (
struct sockaddr_dl *)sdl0;
1050 if (sdl->sdl_alen == ifp->if_addrlen)
1054 if (tlladdr && mac) {
1055 int optlen =
sizeof(
struct nd_opt_hdr) + ifp->if_addrlen;
1056 struct nd_opt_hdr *nd_opt = (
struct nd_opt_hdr *)(nd_na + 1);
1059 optlen = (optlen + 7) & ~7;
1061 m->m_pkthdr.len += optlen;
1064 bzero((caddr_t)nd_opt, optlen);
1065 nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
1066 nd_opt->nd_opt_len = optlen >> 3;
1067 bcopy(mac, (caddr_t)(nd_opt + 1), ifp->if_addrlen);
1069 flags &= ~ND_NA_FLAG_OVERRIDE;
1071 ip6->ip6_plen = htons((u_short)icmp6len);
1072 nd_na->nd_na_flags_reserved = flags;
1073 nd_na->nd_na_cksum = 0;
1074 nd_na->nd_na_cksum =
1075 in6_cksum(m, IPPROTO_ICMPV6,
sizeof(
struct ip6_hdr), icmp6len);
1078 mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
1079 sizeof(
unsigned short), M_NOWAIT);
1082 *(
unsigned short *)(mtag + 1) = nd_na->nd_na_type;
1083 m_tag_prepend(m, mtag);
1086 ip6_output(m, NULL, NULL, 0, &im6o, NULL, NULL);
1087 icmp6_ifstat_inc(ifp, ifs6_out_msg);
1088 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
1089 ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_ADVERT]);
1100 const struct in6_addr *taddr6, u_long flags,
int tlladdr,
1101 struct sockaddr *sdl0)
1112 switch (ifp->if_type) {
1116 case IFT_INFINIBAND:
1118 return IF_LLADDR(ifp);
1125 TAILQ_ENTRY(
dadq) dad_list;
1126 struct ifaddr *dad_ifa;
1133 int dad_loopbackprobe;
1134 struct callout dad_timer_ch;
1135 struct vnet *dad_vnet;
1137#define ND_OPT_NONCE_LEN32 \
1138 ((ND_OPT_NONCE_LEN + sizeof(uint32_t) - 1)/sizeof(uint32_t))
1145#define V_dadq VNET(dadq)
1146#define V_dad_rwlock VNET(dad_rwlock)
1148#define DADQ_LOCKPTR() (&V_dad_rwlock)
1149#define DADQ_LOCK_INIT() rw_init(DADQ_LOCKPTR(), "nd6 DAD queue")
1150#define DADQ_RLOCK() rw_rlock(DADQ_LOCKPTR())
1151#define DADQ_RUNLOCK() rw_runlock(DADQ_LOCKPTR())
1152#define DADQ_WLOCK() rw_wlock(DADQ_LOCKPTR())
1153#define DADQ_WUNLOCK() rw_wunlock(DADQ_LOCKPTR())
1155#define DADQ_LOCK_ASSERT() rw_assert(DADQ_LOCKPTR(), RA_LOCKED);
1156#define DADQ_RLOCK_ASSERT() rw_assert(DADQ_LOCKPTR(), RA_RLOCKED);
1157#define DADQ_WLOCK_ASSERT() rw_assert(DADQ_LOCKPTR(), RA_WLOCKED);
1164 TAILQ_INSERT_TAIL(&
V_dadq, dp, dad_list);
1165 dp->dad_ondadq =
true;
1173 if (dp->dad_ondadq) {
1178 TAILQ_REMOVE(&
V_dadq, dp, dad_list);
1179 dp->dad_ondadq =
false;
1191 TAILQ_FOREACH(dp, &
V_dadq, dad_list) {
1192 if (dp->dad_ifa != ifa)
1201 n->nd_opt_nonce_len == (ND_OPT_NONCE_LEN + 2) / 8 &&
1202 memcmp(&n->nd_opt_nonce[0], &dp->dad_nonce[0],
1203 ND_OPT_NONCE_LEN) == 0) {
1204 dp->dad_ns_lcount++;
1224 callout_drain(&dp->dad_timer_ch);
1230 if (refcount_release(&dp->dad_refcnt)) {
1231 KASSERT(!dp->dad_ondadq, (
"dp %p still on DAD queue", dp));
1232 ifa_free(dp->dad_ifa);
1255 (
"starting DAD on non-tentative address %p", ifa));
1269 if ((ifa->ifa_ifp->if_flags & IFF_UP) == 0 ||
1270 (ifa->ifa_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
1284 dp = malloc(
sizeof(*dp), M_IP6NDP, M_NOWAIT | M_ZERO);
1286 log(LOG_ERR,
"nd6_dad_start: memory allocation failed for "
1289 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) :
"???");
1293 CALLOUT_RETURNUNLOCKED);
1295 dp->dad_vnet = curvnet;
1297 nd6log((LOG_DEBUG,
"%s: starting DAD for %s\n", if_name(ifa->ifa_ifp),
1307 ifa_ref(dp->dad_ifa);
1309 dp->dad_ns_icount = dp->dad_na_icount = 0;
1310 dp->dad_ns_ocount = dp->dad_ns_tcount = 0;
1311 dp->dad_ns_lcount = dp->dad_loopbackprobe = 0;
1314 refcount_init(&dp->dad_refcnt, 1);
1339 (void)refcount_acquire(&dp->dad_refcnt);
1350 struct dadq *dp = arg;
1351 struct ifaddr *ifa = dp->dad_ifa;
1352 struct ifnet *ifp = dp->dad_ifa->ifa_ifp;
1355 struct epoch_tracker et;
1357 CURVNET_SET(dp->dad_vnet);
1358 KASSERT(ia != NULL, (
"DAD entry %p with no address", dp));
1360 NET_EPOCH_ENTER(et);
1363 log(LOG_ERR,
"nd6_dad_timer: cancel DAD on %s because of "
1364 "ND6_IFF_IFDISABLED.\n", ifp->if_xname);
1368 log(LOG_ERR,
"nd6_dad_timer: called with duplicated address "
1371 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) :
"???");
1375 log(LOG_ERR,
"nd6_dad_timer: called with non-tentative address "
1378 ifa->ifa_ifp ? if_name(ifa->ifa_ifp) :
"???");
1384 (((ifp->if_flags & IFF_UP) == 0) ||
1385 ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0))) {
1386 nd6log((LOG_INFO,
"%s: could not run DAD "
1387 "because the interface was down or not running.\n",
1388 if_name(ifa->ifa_ifp)));
1393 if (dp->dad_ns_ocount < dp->dad_count) {
1398 (
long)
ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
1406 if (dp->dad_ns_icount > 0 || dp->dad_na_icount > 0) {
1410 dp->dad_ns_lcount > 0 &&
1411 dp->dad_ns_lcount > dp->dad_loopbackprobe) {
1417 log(LOG_ERR,
"%s: a looped back NS message is "
1418 "detected during DAD for %s. "
1419 "Another DAD probes are being sent.\n",
1420 if_name(ifa->ifa_ifp),
1422 dp->dad_loopbackprobe = dp->dad_ns_lcount;
1430 (
long)
ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
1444 "%s: DAD complete for %s - no duplicates found\n",
1445 if_name(ifa->ifa_ifp),
1447 if (dp->dad_ns_lcount > 0)
1448 log(LOG_ERR,
"%s: DAD completed while "
1449 "a looped back NS message is detected "
1450 "during DAD for %s.\n",
1451 if_name(ifa->ifa_ifp),
1470 log(LOG_ERR,
"%s: DAD detected duplicate IPv6 address %s: "
1471 "NS in/out/loopback=%d/%d/%d, NA in=%d\n",
1473 dp->dad_ns_icount, dp->dad_ns_ocount, dp->dad_ns_lcount,
1480 log(LOG_ERR,
"%s: DAD complete for %s - duplicate found\n",
1482 log(LOG_ERR,
"%s: manual intervention required\n",
1499 switch (ifp->if_type) {
1503 case IFT_INFINIBAND:
1508 log(LOG_ERR,
"%s: possible hardware address "
1509 "duplication detected, disable IPv6\n",
1525 struct ifnet *ifp = dp->dad_ifa->ifa_ifp;
1530 dp->dad_ns_tcount++;
1531 if ((ifp->if_flags & IFF_UP) == 0) {
1535 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
1540 dp->dad_ns_ocount++;
1543 dp->dad_nonce[i] = arc4random();
1555 (uint8_t *)&dp->dad_nonce[0]);
1564 panic(
"ifa == NULL in nd6_dad_ns_input");
1572 dp->dad_ns_icount++;
1582 panic(
"ifa == NULL in nd6_dad_na_input");
1587 dp->dad_na_icount++;
TAILQ_HEAD(ip6qhead, ip6q)
struct in6_ifaddr * in6ifa_ifpforlinklocal(struct ifnet *ifp, int ignoreflags)
char * ip6_sprintf(char *ip6buf, const struct in6_addr *addr)
const struct in6_addr in6addr_linklocal_allnodes
struct in6_ifaddr * in6ifa_ifpwithaddr(struct ifnet *ifp, const struct in6_addr *addr)
#define IPV6_ADDR_INT32_ONE
#define IN6_IS_ADDR_LINKLOCAL(a)
#define IN6_IS_ADDR_UNSPECIFIED(a)
#define IN6_ARE_ADDR_EQUAL(a, b)
#define IPV6_ADDR_INT16_MLL
int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t)
#define IN6_IS_ADDR_MULTICAST(a)
int in6_get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6)
int in6_selectsrc_addr(uint32_t fibnum, const struct in6_addr *dst, uint32_t scopeid, struct ifnet *ifp, struct in6_addr *srcp, int *hlim)
#define IN6_IFF_TENTATIVE
#define IN6_IFF_DUPLICATED
int ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro, int flags, struct ip6_moptions *im6o, struct ifnet **ifpp, struct inpcb *inp)
#define V_ip6_norbit_raif
#define IP6STAT_INC(name)
int nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp)
struct llentry * nd6_lookup(const struct in6_addr *addr6, int flags, struct ifnet *ifp)
void nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, int lladdrlen, int type, int code)
__noinline void nd6_llinfo_setstate(struct llentry *lle, int newstate)
struct mbuf * nd6_grab_holdchain(struct llentry *ln)
int nd6_flush_holdchain(struct ifnet *ifp, struct llentry *lle, struct mbuf *chain)
int nd6_options(union nd_opts *ndopts)
bool nd6_try_set_entry_addr(struct ifnet *ifp, struct llentry *lle, char *lladdr)
int(* send_sendso_input_hook)(struct mbuf *, struct ifnet *, int, int)
void nd6_option_init(void *opt, int icmp6len, union nd_opts *ndopts)
__noinline void nd6_flush_children_holdchain(struct ifnet *ifp, struct llentry *lle)
#define ND6_LLINFO_INCOMPLETE
void pfxlist_onlink_check(void)
#define V_nd6_onlink_ns_rfc4861
void rt6_flush(struct in6_addr *, struct ifnet *)
#define ND6_IFF_IFDISABLED
#define ND6_LLINFO_REACHABLE
bool defrouter_remove(struct in6_addr *, struct ifnet *)
#define ND6_IFF_ACCEPT_RTADV
void nd6_dad_stop(struct ifaddr *ifa)
static void nd6_dad_starttimer(struct dadq *, int)
SYSCTL_DECL(_net_inet6_ip6)
SYSCTL_INT(_net_inet6_ip6, OID_AUTO, dad_enhanced, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(dad_enhanced), 0, "Enable Enhanced DAD, which adds a random nonce to NS messages for DAD.")
static struct dadq * nd6_dad_find(struct ifaddr *, struct nd_opt_nonce *)
static void nd6_dad_rele(struct dadq *)
VNET_DEFINE_STATIC(int, dad_enhanced)
static void nd6_dad_stoptimer(struct dadq *)
#define DADQ_WLOCK_ASSERT()
static void nd6_dad_na_input(struct ifaddr *)
void nd6_ns_output(struct ifnet *ifp, const struct in6_addr *saddr6, const struct in6_addr *daddr6, const struct in6_addr *taddr6, uint8_t *nonce)
static void nd6_dad_del(struct dadq *dp)
static void nd6_dad_ns_output(struct dadq *)
caddr_t nd6_ifptomac(struct ifnet *ifp)
static void nd6_ns_output_fib(struct ifnet *, const struct in6_addr *, const struct in6_addr *, const struct in6_addr *, uint8_t *, u_int)
#define DADQ_LOCK_ASSERT()
void nd6_dad_start(struct ifaddr *ifa, int delay)
void nd6_na_output(struct ifnet *ifp, const struct in6_addr *daddr6_0, const struct in6_addr *taddr6, u_long flags, int tlladdr, struct sockaddr *sdl0)
void nd6_na_input(struct mbuf *m, int off, int icmp6len)
static void nd6_na_output_fib(struct ifnet *, const struct in6_addr *, const struct in6_addr *, u_long, int, struct sockaddr *, u_int)
#define ND_OPT_NONCE_LEN32
static void nd6_dad_ns_input(struct ifaddr *, struct nd_opt_nonce *)
static void nd6_dad_timer(void *)
static void nd6_dad_duplicated(struct ifaddr *, struct dadq *)
static void nd6_dad_add(struct dadq *dp)
void nd6_ns_input(struct mbuf *m, int off, int icmp6len)
int in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
void in6_splitscope(const struct in6_addr *src, struct in6_addr *dst, uint32_t *scopeid)
int in6_clearscope(struct in6_addr *in6)
struct sockaddr_in6 ia_addr
struct in6_addr sin6_addr