Skip to contentSkip to conversation

ipv6: fix warning messages in fib6_info_release().

PATCH In review [email protected] 3 participants 3 messages Dec 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: fix warning messages in fib6_info_release().

From: Kui-Feng Lee <[email protected]>

The previous patch doesn't handle the case in ip6_route_info_create(). Move calling to fib6_set_expires_locked() to the end of the function to avoid the false alarm of the previous patch.

Fixes 5a08d0065a91 ("ipv6: add debug checks in fib6_info_release()")
---
 include/net/ip6_fib.h |  1 -
 net/ipv6/route.c      | 16 +++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)
include/net/ip6_fib.h +0 -1
index e1e7a894863a..95ed495c3a40 100644
@@ -329,7 +329,6 @@ static inline bool fib6_info_hold_safe(struct fib6_info *f6i)
 static inline void fib6_info_release(struct fib6_info *f6i)
 {
 	if (f6i && refcount_dec_and_test(&f6i->fib6_ref)) {
-		DEBUG_NET_WARN_ON_ONCE(fib6_has_expires(f6i));
 		DEBUG_NET_WARN_ON_ONCE(!hlist_unhashed(&f6i->gc_link));
 		call_rcu(&f6i->rcu, fib6_info_destroy_rcu);
 	}
net/ipv6/route.c +9 -7
index b132feae3393..398dbfb6e12b 100644
@@ -3762,17 +3762,10 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
 	if (cfg->fc_flags & RTF_ADDRCONF)
 		rt->dst_nocount = true;
 
-	if (cfg->fc_flags & RTF_EXPIRES)
-		fib6_set_expires_locked(rt, jiffies +
-					clock_t_to_jiffies(cfg->fc_expires));
-	else
-		fib6_clean_expires_locked(rt);
-
 	if (cfg->fc_protocol == RTPROT_UNSPEC)
 		cfg->fc_protocol = RTPROT_BOOT;
 	rt->fib6_protocol = cfg->fc_protocol;
 
-	rt->fib6_table = table;
 	rt->fib6_metric = cfg->fc_metric;
 	rt->fib6_type = cfg->fc_type ? : RTN_UNICAST;
 	rt->fib6_flags = cfg->fc_flags & ~RTF_GATEWAY;
@@ -3824,6 +3817,15 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
 	} else
 		rt->fib6_prefsrc.plen = 0;
 
+	if (cfg->fc_flags & RTF_EXPIRES)
+		fib6_set_expires_locked(rt, jiffies +
+					clock_t_to_jiffies(cfg->fc_expires));
+	/* Set fib6_table after fib6_set_expires_locked() to ensure the
+	 * gc_link is not inserted until fib6_add() is called to insert the
+	 * fib6_info to the fib.
+	 */
+	rt->fib6_table = table;
+
 	return rt;
 out:
 	fib6_info_release(rt);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · On Thu, Dec 7, 2023 at 8:50 PM <[email protected]> wrote:

From: Kui-Feng Lee <[email protected]>

The previous patch doesn't handle the case in ip6_route_info_create(). Move calling to fib6_set_expires_locked() to the end of the function to avoid the false alarm of the previous patch.

Fixes 5a08d0065a91 ("ipv6: add debug checks in fib6_info_release()")

This looks quite wrong.

Let's separate things to have clean stable backports.

I will submit my single liner, you will submit a patch fixing your prior commit, otherwise linux-6.6 and linux-6.7 will still have a bug.

#2 lore raw
Quoted 8 lines · Eric Dumazet
Quoted 7 lines · On Thu, Dec 7, 2023 at 8:50 PM <[email protected]> wrote:

From: Kui-Feng Lee <[email protected]>

The previous patch doesn't handle the case in ip6_route_info_create(). Move calling to fib6_set_expires_locked() to the end of the function to avoid the false alarm of the previous patch.

Quoted 8 lines
Quoted 1 line
Fixes 5a08d0065a91 ("ipv6: add debug checks in fib6_info_release()")

This looks quite wrong.

Let's separate things to have clean stable backports.

I will submit my single liner, you will submit a patch fixing your prior commit, otherwise linux-6.6 and linux-6.7 will still have a bug.

Sure, I am working on that.