Thread (11 messages) 11 messages, 4 authors, 10d ago

Re: [PATCH net v2 1/2] ipv6: serialize address publication with device teardown

flat view

From: Ido Schimmel <idosch@nvidia.com>
Date: 2026-10-07 19:20:43
Also in: lkml
Subsystem: networking [general], networking [ipv4/ipv6], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern, Ido Schimmel, Linus Torvalds

On Wed, Oct 07, 2026 at 07:45:48PM +0300, Ido Schimmel wrote:
Yes, we need to pass the public address to ipv6_add_addr() so that we
only publish a fully initialized temporary address in the per-idev list
and the per-netns hashtable. Something like the diff below. It should be
another patch in this series.
Thinking about it again, the following diff seems cleaner to me. That
way we don't modify the timestamps after publishing the address.
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index e6764245995f..0cfc99b4d251 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -87,6 +87,8 @@ struct ifa6_config {
 	u32			preferred_lft;
 	u32			valid_lft;
 	u16			scope;
+	struct inet6_ifaddr	*ifpub;
+	unsigned long		tstamp;
 };
 
 enum addr_type_t {
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c90ee6dd7446..df3f25fbab64 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1155,10 +1155,12 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
 		ifa->flags |= IFA_F_TENTATIVE;
 	ifa->valid_lft = cfg->valid_lft;
 	ifa->prefered_lft = cfg->preferred_lft;
-	ifa->cstamp = ifa->tstamp = jiffies;
+	ifa->cstamp = jiffies;
+	ifa->tstamp = cfg->ifpub ? cfg->tstamp : ifa->cstamp;
 	ifa->tokenized = false;
 
 	ifa->rt = f6i;
+	ifa->ifpub = cfg->ifpub;
 
 	ifa->idev = idev;
 	in6_dev_hold(idev);
@@ -1487,6 +1489,8 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
 
 	cfg.pfx = &addr;
 	cfg.scope = ipv6_addr_scope(cfg.pfx);
+	cfg.ifpub = ifp;
+	cfg.tstamp = tmp_tstamp;
 
 	ift = ipv6_add_addr(idev, &cfg, block, NULL);
 	if (IS_ERR(ift)) {
@@ -1497,12 +1501,6 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
 		goto retry;
 	}
 
-	spin_lock_bh(&ift->lock);
-	ift->ifpub = ifp;
-	ift->cstamp = now;
-	ift->tstamp = tmp_tstamp;
-	spin_unlock_bh(&ift->lock);
-
 	addrconf_dad_start(ift);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help