aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPouria Mousavizadeh Tehrani <pouria@FreeBSD.org>2026-11-18 19:21:53 +0000
committerPouria Mousavizadeh Tehrani <pouria@FreeBSD.org>2026-11-25 20:18:33 +0000
commitc7cd7e7fad57ec3e44b68dddf3037134b805d0c3 (patch)
tree6e89c03aeb919dd1f06ccbd90e4524793bc22787
parent276085c192993e68aca41e2402f94436f99aa33b (diff)
nd6: Add support for Optimistic DAD (RFC 4429)
Implement optimistic address based on RFC 4429. Relnotes: yes Differential Revision: https://reviews.freebsd.org/D55229
-rw-r--r--sbin/ifconfig/af_inet6.c4
-rw-r--r--share/man/man4/inet6.411
-rw-r--r--sys/netinet6/in6.c66
-rw-r--r--sys/netinet6/in6.h5
-rw-r--r--sys/netinet6/in6_proto.c3
-rw-r--r--sys/netinet6/in6_src.c6
-rw-r--r--sys/netinet6/in6_var.h3
-rw-r--r--sys/netinet6/ip6_var.h2
-rw-r--r--sys/netinet6/nd6.c15
-rw-r--r--sys/netinet6/nd6_nbr.c69
-rw-r--r--sys/netinet6/nd6_rtr.c5
-rw-r--r--sys/netlink/route/iface.c4
-rw-r--r--usr.sbin/rtsold/if.c1
13 files changed, 142 insertions, 52 deletions
diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
index 492ee5bbbed0..2f6259920da3 100644
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -271,6 +271,8 @@ print_flags(int flags6)
printf(" temporary");
if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0)
printf(" prefer_source");
+ if ((flags6 & IN6_IFF_OPTIMISTIC) != 0)
+ printf(" optimistic");
}
@@ -730,6 +732,8 @@ static struct cmd inet6_cmds[] = {
DEF_CMD("eui64", 0, setip6eui64),
DEF_CMD("stableaddr", ND6_IFF_STABLEADDR, setnd6flags),
DEF_CMD("-stableaddr", -ND6_IFF_STABLEADDR, setnd6flags),
+ DEF_CMD("optimistic", IN6_IFF_OPTIMISTIC, setip6flags),
+ DEF_CMD("-optimistic", -IN6_IFF_OPTIMISTIC, setip6flags),
};
static struct afswtch af_inet6 = {
diff --git a/share/man/man4/inet6.4 b/share/man/man4/inet6.4
index 20d32e03ec60..3f1f248be0bc 100644
--- a/share/man/man4/inet6.4
+++ b/share/man/man4/inet6.4
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 31, 2026
+.Dd November 25, 2026
.Dt INET6 4
.Os
.Sh NAME
@@ -306,6 +306,15 @@ The packets will be generated when
.Tn IPv6
interface addresses are configured or when there are changes to
link-layer interface addresses.
+.It Dv IPV6CTL_USE_OPTIMISTIC
+.Pq ip6.use_optimistic
+Boolean: enable/disable Optimistic DAD
+.Pq RFC 4429
+for autoconfigured addresses.
+If enabled, an autoconfigured address is available for use
+while duplicate address detection is still in progress.
+It has no effect if the node acts as a router.
+Defaults to on.
.It Dv IPV6CTL_AUTO_FLOWLABEL
.Pq ip6.auto_flowlabel
Boolean: enable/disable automatic filling of
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 742bcaa2ecfc..878ac7ec2e4b 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1093,8 +1093,17 @@ in6_update_ifa_internal(struct ifnet *ifp, struct in6_aliasreq *ifra,
* an interface with ND6_IFF_IFDISABLED.
*/
if (in6if_do_dad(ifp) &&
- (hostIsNew || (ifp->if_inet6->nd_flags & ND6_IFF_IFDISABLED)))
- ia->ia6_flags |= IN6_IFF_TENTATIVE;
+ (hostIsNew || (ifp->if_inet6->nd_flags & ND6_IFF_IFDISABLED))) {
+ /*
+ * RFC 4429 section 3: A router SHOULD NOT configure an
+ * Optimistic Address. Optimistic DAD SHOULD only be used
+ * when the implementation is aware that the address is
+ * based on a most likely unique interface identifier.
+ * XXX: A host that does not know the SLLAO of its router
+ * SHOULD NOT configure a new address as Optimistic.
+ */
+ in6_ifa_need_dad(ia);
+ }
/* notify other subsystems */
error = in6_notify_ifa(ifp, ia, ifra, hostIsNew);
@@ -1134,8 +1143,8 @@ in6_broadcast_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
}
}
- /* Perform DAD, if the address is TENTATIVE. */
- if ((ia->ia6_flags & IN6_IFF_TENTATIVE)) {
+ /* Perform DAD, if the address is TENTATIVE or OPTIMISTIC. */
+ if ((ia->ia6_flags & IN6_IFF_NEED_DAD) != 0) {
int delay, mindelay, maxdelay;
delay = 0;
@@ -2013,11 +2022,11 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
int dst_scope = in6_addrscope(dst), blen = -1, tlen;
struct ifaddr *ifa;
struct in6_ifaddr *besta = NULL;
- struct in6_ifaddr *dep[2]; /* last-resort: deprecated */
+ struct in6_ifaddr *dep[4]; /* last-resort: optimistic/deprecated */
NET_EPOCH_ASSERT();
- dep[0] = dep[1] = NULL;
+ dep[0] = dep[1] = dep[2] = dep[3] = NULL;
/*
* We first look for addresses in the same scope.
@@ -2034,12 +2043,16 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
continue; /* don't use this interface */
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DETACHED)
continue;
+ if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_OPTIMISTIC) {
+ if (V_ip6_use_optimistic)
+ dep[0] = (struct in6_ifaddr *)ifa;
+ continue;
+ }
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DEPRECATED) {
if (V_ip6_use_deprecated)
- dep[0] = (struct in6_ifaddr *)ifa;
+ dep[1] = (struct in6_ifaddr *)ifa;
continue;
}
-
if (dst_scope == in6_addrscope(IFA_IN6(ifa))) {
/*
* call in6_matchlen() as few as possible
@@ -2068,22 +2081,26 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
continue; /* don't use this interface */
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DETACHED)
continue;
+ if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_OPTIMISTIC) {
+ if (V_ip6_use_optimistic)
+ dep[2] = (struct in6_ifaddr *)ifa;
+ continue;
+ }
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DEPRECATED) {
if (V_ip6_use_deprecated)
- dep[1] = (struct in6_ifaddr *)ifa;
+ dep[3] = (struct in6_ifaddr *)ifa;
continue;
}
-
return (struct in6_ifaddr *)ifa;
}
- /* use the last-resort values, that are, deprecated addresses */
- if (dep[0])
- return dep[0];
- if (dep[1])
- return dep[1];
+ /* use the last-resort values */
+ for (int i = 0; i < nitems(dep); i++) {
+ if (dep[i] != NULL)
+ return (dep[i]);
+ }
- return NULL;
+ return (NULL);
}
/*
@@ -2101,9 +2118,9 @@ in6_if_up(struct ifnet *ifp)
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
ia = (struct in6_ifaddr *)ifa;
- if (ia->ia6_flags & IN6_IFF_TENTATIVE) {
+ if ((ia->ia6_flags & IN6_IFF_NEED_DAD) != 0) {
/*
- * The TENTATIVE flag was likely set by hand
+ * The TENTATIVE/OPTIMISTIC flag was likely set by hand
* beforehand, implicitly indicating the need for DAD.
* We may be able to skip the random delay in this
* case, but we impose delays just in case.
@@ -2134,6 +2151,19 @@ in6_init(void *arg __unused)
}
SYSINIT(in6_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, in6_init, NULL);
+void
+in6_ifa_need_dad(struct in6_ifaddr *ia)
+{
+
+ if ((ia->ia6_flags & IN6_IFF_OPTIMISTIC) != 0 ||
+ (V_ip6_use_optimistic && !V_ip6_forwarding &&
+ (ia->ia6_flags & IN6_IFF_AUTOCONF) != 0)) {
+ ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia->ia6_flags |= IN6_IFF_OPTIMISTIC;
+ } else
+ ia->ia6_flags |= IN6_IFF_TENTATIVE;
+}
+
int
in6if_do_dad(struct ifnet *ifp)
{
diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h
index a574e2cb137f..722ed6f24d56 100644
--- a/sys/netinet6/in6.h
+++ b/sys/netinet6/in6.h
@@ -364,6 +364,8 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
(u_int32_t)((time_uptime - (a)->ia6_updatetime)) >= \
(a)->ia6_lifetime.ia6t_vltime)
+#define IFA6_IS_AVOIDED(a) \
+ (IFA6_IS_DEPRECATED(a) || ((a)->ia6_flags & IN6_IFF_OPTIMISTIC) != 0)
#endif /* _KERNEL */
/*
@@ -644,7 +646,8 @@ struct ip6_mtuinfo {
#define IPV6CTL_MAXFRAGSPERPACKET 53 /* Max fragments per packet */
#define IPV6CTL_MAXFRAGBUCKETSIZE 54 /* Max reassembly queues per bucket */
#define IPV6CTL_GRAND_COUNT 55
-#define IPV6CTL_MAXID 56
+#define IPV6CTL_USE_OPTIMISTIC 56
+#define IPV6CTL_MAXID 57
#endif /* __BSD_VISIBLE */
/*
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 784b824478fc..b80811319f5e 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -358,3 +358,6 @@ SYSCTL_BOOL(_net_inet6_ip6, OID_AUTO,
log_cannot_forward, CTLFLAG_VNET | CTLFLAG_RW,
&VNET_NAME(ip6_log_cannot_forward), 1,
"Log packets that cannot be forwarded");
+SYSCTL_BOOL(_net_inet6_ip6, IPV6CTL_USE_OPTIMISTIC, use_optimistic,
+ CTLFLAG_VNET | CTLFLAG_RWTUN, &VNET_NAME(ip6_use_optimistic), 0,
+ "Enable RFC4429 optimistic DAD");
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 1923908873f8..f9e798c905a8 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -353,10 +353,12 @@ in6_selectsrc(uint32_t fibnum, struct sockaddr_in6 *dstsock,
/*
* Rule 3: Avoid deprecated addresses. Note that the case of
* !ip6_use_deprecated is already rejected above.
+ * RFC 4429 section 2.1: treat optimistic addresses
+ * equivalently to deprecated addresses.
*/
- if (!IFA6_IS_DEPRECATED(ia_best) && IFA6_IS_DEPRECATED(ia))
+ if (!IFA6_IS_AVOIDED(ia_best) && IFA6_IS_AVOIDED(ia))
NEXT(3);
- if (IFA6_IS_DEPRECATED(ia_best) && !IFA6_IS_DEPRECATED(ia))
+ if (IFA6_IS_AVOIDED(ia_best) && !IFA6_IS_AVOIDED(ia))
REPLACE(3);
/* Rule 4: Prefer home addresses */
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 7c8639841741..01e2b0059277 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -482,7 +482,9 @@ struct in6_rrenumreq {
#define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */
#define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */
#define IN6_IFF_PREFER_SOURCE 0x0100 /* preferred address for SAS */
+#define IN6_IFF_OPTIMISTIC 0x0200 /* optimistic address */
+#define IN6_IFF_NEED_DAD (IN6_IFF_TENTATIVE|IN6_IFF_OPTIMISTIC)
/* do not input/output */
#define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
@@ -904,6 +906,7 @@ int in6_addifaddr(struct ifnet *, struct in6_aliasreq *, struct in6_ifaddr *);
void in6_purgeaddr(struct ifaddr *);
void in6_purgeifaddr(struct in6_ifaddr *);
int in6if_do_dad(struct ifnet *);
+void in6_ifa_need_dad(struct in6_ifaddr *);
void in6_savemkludge(struct in6_ifaddr *);
uint32_t in6_ifmtu(const struct ifnet *);
struct rib_head *in6_inithead(uint32_t fibnum);
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index f96847ddc30f..42d7c7d3f28f 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -342,9 +342,11 @@ VNET_DECLARE(int, ip6_prefer_tempaddr); /* Whether to prefer temporary
* addresses in the source address
* selection */
VNET_DECLARE(bool, ip6_use_stableaddr); /* Whether to use stable address generation (RFC 7217) */
+VNET_DECLARE(bool, ip6_use_optimistic); /* Whether to use optimistic DAD (RFC 4429) */
#define V_ip6_use_tempaddr VNET(ip6_use_tempaddr)
#define V_ip6_prefer_tempaddr VNET(ip6_prefer_tempaddr)
#define V_ip6_use_stableaddr VNET(ip6_use_stableaddr)
+#define V_ip6_use_optimistic VNET(ip6_use_optimistic)
#define IP6_IDGEN_RETRIES 3 /* RFC 7217 section 7 default max retries */
VNET_DECLARE(u_int, ip6_stableaddr_maxretries);
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 07daaedeaf32..7952bc1985b0 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1026,11 +1026,11 @@ nd6_timer(void *arg)
goto addrloop;
}
}
- } else if ((ia6->ia6_flags & IN6_IFF_TENTATIVE) != 0) {
+ } else if ((ia6->ia6_flags & IN6_IFF_NEED_DAD) != 0) {
/*
- * Schedule DAD for a tentative address. This happens
- * if the interface was down or not running
- * when the address was configured.
+ * Schedule DAD for a tentative or optimistic address.
+ * This happens if the interface was down or not
+ * running when the address was configured.
*/
int delay;
@@ -1040,7 +1040,8 @@ nd6_timer(void *arg)
} else {
/*
* Check status of the interface. If it is down,
- * mark the address as tentative for future DAD.
+ * mark the address as optimistic if available, or
+ * mark it as tentative for future DAD.
*/
ifp = ia6->ia_ifp;
if ((ifp->if_inet6->nd_flags & ND6_IFF_NO_DAD) == 0 &&
@@ -1048,7 +1049,7 @@ nd6_timer(void *arg)
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
(ifp->if_inet6->nd_flags & ND6_IFF_IFDISABLED))){
ia6->ia6_flags &= ~IN6_IFF_DUPLICATED;
- ia6->ia6_flags |= IN6_IFF_TENTATIVE;
+ in6_ifa_need_dad(ia6);
}
/*
@@ -1764,7 +1765,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
AF_INET6)
continue;
ia = (struct in6_ifaddr *)ifa;
- ia->ia6_flags |= IN6_IFF_TENTATIVE;
+ in6_ifa_need_dad(ia);
}
NET_EPOCH_EXIT(et);
}
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 9f7d64cc1870..f8c54e5ec201 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -154,6 +154,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
int rflag, tentative, tlladdr;
u_int lladdr_pad, lladdrlen;
uint32_t dflags;
+ bool optimistic;
ifa = NULL;
@@ -296,6 +297,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
dflags |= ND6_QUEUE_FLAG_ANYCAST;
myaddr6 = *IFA_IN6(ifa);
tentative = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE;
+ optimistic = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_OPTIMISTIC;
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED)
goto freeit;
@@ -315,7 +317,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
/*
* We have neighbor solicitation packet, with target address equals to
- * one of my tentative address.
+ * one of my tentative/optimistic address.
*
* src addr how to process?
* --- ---
@@ -325,27 +327,30 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
*
* The processing is defined in RFC 2462.
*/
- if (tentative) {
+ if (tentative || optimistic) {
/*
* If source address is unspecified address, it is for
* duplicate address detection.
*
* If not, the packet is for addess resolution;
+ * Therefore, if the target address is not optimistic,
* silently ignore it.
*/
- if (IN6_IS_ADDR_UNSPECIFIED(&saddr6))
+ if (IN6_IS_ADDR_UNSPECIFIED(&saddr6)) {
nd6_dad_ns_input(ifa, ndopts.nd_opts_nonce);
-
- goto freeit;
+ goto freeit;
+ }
+ if (tentative)
+ goto freeit;
}
/*
- * If the Target Address is either an anycast address or a unicast
- * address for which the node is providing proxy service, or the Target
- * Link-Layer Address option is not included, the Override flag SHOULD
+ * If the Target Address is an anycast address, an optimistic address,
+ * or a unicast address for which the node is providing proxy service,
+ * or the Target LLA option is not included, the Override flag SHOULD
* be set to zero. Otherwise, the Override flag SHOULD be set to one.
*/
- if (dflags == 0 && (tlladdr & ND6_NA_OPT_LLA) != 0)
+ if (dflags == 0 && !optimistic && (tlladdr & ND6_NA_OPT_LLA) != 0)
rflag |= ND_NA_FLAG_OVERRIDE;
/*
* If the source address is unspecified address, entries must not
@@ -507,9 +512,16 @@ nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6,
* We use the source address for the prompting packet
* (saddr6), if saddr6 belongs to the outgoing interface.
* Otherwise, we perform the source address selection as usual.
+ *
+ * RFC 4429 3.2: NS cannot be sent from Optimistic Addresses.
*/
if (saddr6 != NULL)
ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, saddr6);
+ if (ifa != NULL && (((struct in6_ifaddr *)ifa)->ia6_flags &
+ IN6_IFF_OPTIMISTIC) != 0) {
+ ifa_free(ifa);
+ ifa = NULL;
+ }
if (ifa == NULL) {
int error;
@@ -522,6 +534,20 @@ nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6,
error));
goto bad;
}
+ ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, &ip6->ip6_src);
+ if (ifa != NULL && (((struct in6_ifaddr *)ifa)->ia6_flags &
+ IN6_IFF_OPTIMISTIC) != 0) {
+ ifa_free(ifa);
+ ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp,
+ IN6_IFF_NOTREADY | IN6_IFF_ANYCAST | IN6_IFF_OPTIMISTIC);
+ if (ifa == NULL) {
+ nd6log((LOG_DEBUG, "%s: no non-optimistic "
+ "source address: dst=%s\n", __func__,
+ ip6_sprintf(ip6buf, &ip6->ip6_dst)));
+ goto bad;
+ }
+ ip6->ip6_src = *IFA_IN6(ifa);
+ }
} else
ip6->ip6_src = *saddr6;
@@ -772,14 +798,14 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
/*
* Target address matches one of my interface address.
*
- * If my address is tentative, this means that there's somebody
+ * If my address is tentative/optimistic, means that there's somebody
* already using the same address as mine. This indicates DAD failure.
* This is defined in RFC 2462.
*
* Otherwise, process as defined in RFC 2461.
*/
if (ifa
- && (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE)) {
+ && (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_NEED_DAD)) {
nd6_dad_na_input(ifa);
ifa_free(ifa);
goto freeit;
@@ -1308,7 +1334,7 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
struct dadq *dp;
char ip6buf[INET6_ADDRSTRLEN];
- KASSERT((ia->ia6_flags & IN6_IFF_TENTATIVE) != 0,
+ KASSERT((ia->ia6_flags & IN6_IFF_NEED_DAD) != 0,
("starting DAD on non-tentative address %p", ifa));
/*
@@ -1320,7 +1346,7 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
if ((ia->ia6_flags & IN6_IFF_ANYCAST) != 0 ||
V_ip6_dad_count == 0 ||
(ifa->ifa_ifp->if_inet6->nd_flags & ND6_IFF_NO_DAD) != 0) {
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia->ia6_flags &= ~IN6_IFF_NEED_DAD;
return;
}
if ((ifa->ifa_ifp->if_flags & IFF_UP) == 0 ||
@@ -1428,7 +1454,7 @@ nd6_dad_timer(void *arg)
ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
goto err;
}
- if ((ia->ia6_flags & IN6_IFF_TENTATIVE) == 0) {
+ if ((ia->ia6_flags & IN6_IFF_NEED_DAD) == 0) {
log(LOG_ERR, "nd6_dad_timer: called with non-tentative address "
"%s(%s)\n",
ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
@@ -1497,7 +1523,7 @@ nd6_dad_timer(void *arg)
* Reset DAD failures counter if using stable addresses.
*/
if ((ifp->if_inet6->nd_flags & ND6_IFF_IFDISABLED) == 0) {
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia->ia6_flags &= ~IN6_IFF_NEED_DAD;
if ((ifp->if_inet6->nd_flags & ND6_IFF_STABLEADDR) && !(ia->ia6_flags & IN6_IFF_TEMPORARY))
atomic_store_int(&DAD_FAILURES(ifp), 0);
/*
@@ -1543,7 +1569,7 @@ nd6_dad_duplicated(struct ifaddr *ifa, struct dadq *dp)
dp->dad_ns_icount, dp->dad_ns_ocount, dp->dad_ns_lcount,
dp->dad_na_icount);
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia->ia6_flags &= ~IN6_IFF_NEED_DAD;
ia->ia6_flags |= IN6_IFF_DUPLICATED;
log(LOG_ERR, "%s: DAD complete for %s - duplicate found\n",
@@ -1723,11 +1749,6 @@ nd6_queue_timer(void *arg)
* then the Override flag SHOULD NOT be set.
*/
if ((ndq->ndq_flags & ND6_QUEUE_FLAG_NEWGUA) != 0) {
- /*
- * XXX: If the address is in the Optimistic state,
- * then the Override flag MUST NOT be set.
- * We don't support RFC 4429 yet.
- */
if ((ifp->if_inet6->nd_flags & ND6_IFF_PREFER_SOURCE) == 0)
flags |= ND_NA_FLAG_OVERRIDE;
}
@@ -1737,6 +1758,12 @@ nd6_queue_timer(void *arg)
*/
if ((ndq->ndq_flags & ND6_QUEUE_FLAG_LLADDR) != 0)
flags |= ND_NA_FLAG_OVERRIDE;
+ /*
+ * RFC 9131 Section 6.1.2 and RFC 4429 Section 2.2: If the address
+ * is in the Optimistic state, then the Override flag MUST NOT be set.
+ */
+ if ((((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_OPTIMISTIC) != 0)
+ flags &= ~ND_NA_FLAG_OVERRIDE;
/* anycast advertisement delay rule (RFC 4861 7.2.7, SHOULD) */
if ((ndq->ndq_flags & ND6_QUEUE_FLAG_ANYCAST) != 0)
flags |= ND_NA_FLAG_SOLICITED;
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index e3e9f7f54221..22171dd01a84 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -108,6 +108,7 @@ VNET_DEFINE(int, nd6_defifindex);
VNET_DEFINE(int, ip6_use_tempaddr) = 0;
VNET_DEFINE(bool, ip6_use_stableaddr) = 1;
+VNET_DEFINE(bool, ip6_use_optimistic) = 1;
VNET_DEFINE(int, ip6_desync_factor);
VNET_DEFINE(uint32_t, ip6_temp_max_desync_factor) = TEMP_MAX_DESYNC_FACTOR_BASE;
@@ -1985,7 +1986,7 @@ restart:
if (find_pfxlist_reachable_router(ifa->ia6_ndpr)) {
if (ifa->ia6_flags & IN6_IFF_DETACHED) {
ifa->ia6_flags &= ~IN6_IFF_DETACHED;
- ifa->ia6_flags |= IN6_IFF_TENTATIVE;
+ in6_ifa_need_dad(ifa);
nd6_dad_start((struct ifaddr *)ifa, 0);
}
} else {
@@ -1999,7 +2000,7 @@ restart:
if (ifa->ia6_flags & IN6_IFF_DETACHED) {
ifa->ia6_flags &= ~IN6_IFF_DETACHED;
- ifa->ia6_flags |= IN6_IFF_TENTATIVE;
+ in6_ifa_need_dad(ifa);
/* Do we need a delay in this case? */
nd6_dad_start((struct ifaddr *)ifa, 0);
}
diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c
index 59101ee60e77..236a007ddfe8 100644
--- a/sys/netlink/route/iface.c
+++ b/sys/netlink/route/iface.c
@@ -1508,6 +1508,8 @@ in6_flags_to_nl(uint32_t flags)
nl_flags |= IFA_F_DEPRECATED;
if (flags & IN6_IFF_TENTATIVE)
nl_flags |= IFA_F_TENTATIVE;
+ if (flags & IN6_IFF_OPTIMISTIC)
+ nl_flags |= IFA_F_OPTIMISTIC;
if ((flags & (IN6_IFF_AUTOCONF|IN6_IFF_TEMPORARY)) == 0)
flags |= IFA_F_PERMANENT;
if (flags & IN6_IFF_DUPLICATED)
@@ -1528,6 +1530,8 @@ nl_flags_to_in6(uint32_t flags)
in6_flags |= IN6_IFF_DEPRECATED;
if (flags & IFA_F_TENTATIVE)
in6_flags |= IN6_IFF_TENTATIVE;
+ if (flags & IFA_F_OPTIMISTIC)
+ in6_flags |= IN6_IFF_OPTIMISTIC;
if (flags & IFA_F_DADFAILED)
in6_flags |= IN6_IFF_DUPLICATED;
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c
index a0f61b991e8a..c026d606a4ea 100644
--- a/usr.sbin/rtsold/if.c
+++ b/usr.sbin/rtsold/if.c
@@ -163,6 +163,7 @@ interface_up(char *name)
close(s);
if (cap_llflags_get(capllflags, name, &llflag) != 0) {
+ /* XXX: RFC 4429 section 2.4: don't try with optimistic address */
warnmsg(LOG_WARNING, __func__,
"cap_llflags_get() failed, anyway I'll try");
return (0);