From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 924F02E88BB for ; Mon, 9 Mar 2026 18:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773079705; cv=none; b=pjQBzFUotJTM7ypN5WMN7/MkQp8P1cR2cfEoxkUFiVaPCpqYqORzpzDphxk8tCG+YeQNLDMqA3ZLSuVPhnIdXKVBf1ZtWPn/BgbpUHwoQKDAk3mQIljVOI0kFlSMwL7mjOR4rd6Wxuey6FtTGBL2BfgSfiSeyTwpiHNZep8pxsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773079705; c=relaxed/simple; bh=DEtkvabfgnLdF5SvSPKFybcDhFHNI6Lwzt0FUFp7QDk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=S6liQ+yPFrbKvmkEBljw3oTSTjrQTYt79b93XGW+kRXYk8RkgVTkTR1b5GS7eUCKs/yMWIWJF2ipJ7w5Kctv4Y9TF/w0B4GKQVGpbGBAhqeXINYaYSt7VoDShP02dil4TmV6rqzbJsej7Haq1Ohj7qC0GRlk0XAk5BldF2xuyfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ypWBOt8E; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ypWBOt8E" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2ae5031c6c5so404589275ad.3 for ; Mon, 09 Mar 2026 11:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773079704; x=1773684504; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sQmk2eqzpfEl9/Iq31te/gbhmooeym21EKQBbY/r2hM=; b=ypWBOt8ED01WypeFqfo86r9GHOHgEYH9DcFbx9P82ME1wiNnXUZc0WwH4dcEFosGn8 g2WbALHiwA5enwBMqTXDMrvj0hOpwTEc70mTIy8qSwbtMSnvV+FB5cSSSx41ugGQWDeG 13aC3Wq+kvgcBlPdaU+/M6Mb/+hHiwkBmnISyvSFYe226vVHV1y6+kDgUnLtya7ASU96 LXWQeqVYI0YJAEJ7wlOfhPqqnkLlXz+XyLjcrj32QToA/h43AfM2cuuMsUpNXkWF/9rB fabhDcNaHdoJOF9yQ7MJ7+aXDHCPMuLI/RVoFn/qX2QMJpdryndISyiPgT9T1Fgxv41K MvCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773079704; x=1773684504; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sQmk2eqzpfEl9/Iq31te/gbhmooeym21EKQBbY/r2hM=; b=iN26oy3Qi8hxZXuwvW+BhoxwvBp3oldRUsRYr1Fa4ZuTm2kvI21a+n70L/jDMGqIgv LRlroAjDM9kAUKwzxkEouHZwxrYg1LDx9uREMHytBmBWCKtw/JAc5529zyl82qILUNVo 110jFrSjJywoUY6DjhKhsGqukKA4fW41cf4HuEe2MiUsZ4m5eugUn2uZnSuN6OAieyFv KefijtGlPombQnG0TJj/gEMKfsqfezH3SyLY//Ivp2HJ2PwV5+HOWiCSz3tAtyLxE/Ma IpxORY5301yWAtZ5G+5IduORP3ZBoGExbgOZIAtOpiBL8Y6hv4ULO6f35CsxPAhZ//pb sMXg== X-Forwarded-Encrypted: i=1; AJvYcCVM/Qg91upQ1ZTfu6iz9WZCTt9gdSJW/39hbj79Gc3uzJEpoRodoUbwFPUPauJpZca4Td3oQMA=@vger.kernel.org X-Gm-Message-State: AOJu0YwATz+f9Gn1qCYHSLJqQxN8fb+RUVktbFJ637qRohhC4o+dANcx S+FvK6sSwed66KqVPAoJVM+zTQ6F20JZKX2cr9Zb9lz7hqSTAV1ToYtG4b4Kuzz6M56fprRj6DJ qD8GsNA== X-Received: from pldv19.prod.google.com ([2002:a17:902:ca93:b0:2a9:458c:21f]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e545:b0:2ae:5c3d:b07d with SMTP id d9443c01a7336-2ae824bd5b7mr117408875ad.57.1773079703768; Mon, 09 Mar 2026 11:08:23 -0700 (PDT) Date: Mon, 9 Mar 2026 18:06:49 +0000 In-Reply-To: <20260309180804.3471287-1-kuniyu@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260309180804.3471287-1-kuniyu@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309180804.3471287-3-kuniyu@google.com> Subject: [PATCH v3 net 2/2] ipv6: Don't remove permanent routes with exceptions from tb6_gc_hlist. From: Kuniyuki Iwashima To: David Ahern , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Kui-Feng Lee , Xin Long , Simon Horman , Kuniyuki Iwashima , Kuniyuki Iwashima , netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" The cited commit mechanically put fib6_remove_gc_list() just after every fib6_clean_expires() call. When a temporary route is promoted to a permanent route, there may already be exception routes tied to it. If fib6_remove_gc_list() removes the route from tb6_gc_hlist, such exception routes will no longer be aged. Let's replace fib6_remove_gc_list() with a new helper fib6_may_remove_gc_list() and use fib6_age_exceptions() there. Note that net->ipv6 is only compiled when CONFIG_IPV6 is enabled, so fib6_{add,remove,may_remove}_gc_list() are guarded. Fixes: 5eb902b8e719 ("net/ipv6: Remove expired routes with a separated list of routes.") Signed-off-by: Kuniyuki Iwashima --- v3: Use IS_ENABLED() v2: Fix build failure when CONFIG_IPV6=n (no net->ipv6 definition) --- include/net/ip6_fib.h | 19 ++++++++++++++++++- net/ipv6/addrconf.c | 4 ++-- net/ipv6/ip6_fib.c | 6 +++--- net/ipv6/route.c | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index 88b0dd4d8e09..7e91f8f35552 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h @@ -507,12 +507,14 @@ void fib6_rt_update(struct net *net, struct fib6_info *rt, void inet6_rt_notify(int event, struct fib6_info *rt, struct nl_info *info, unsigned int flags); +void fib6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args, + unsigned long now); void fib6_run_gc(unsigned long expires, struct net *net, bool force); - void fib6_gc_cleanup(void); int fib6_init(void); +#if IS_ENABLED(CONFIG_IPV6) /* Add the route to the gc list if it is not already there * * The callers should hold f6i->fib6_table->tb6_lock. @@ -545,6 +547,21 @@ static inline void fib6_remove_gc_list(struct fib6_info *f6i) hlist_del_init(&f6i->gc_link); } +static inline void fib6_may_remove_gc_list(struct net *net, + struct fib6_info *f6i) +{ + struct fib6_gc_args gc_args; + + if (hlist_unhashed(&f6i->gc_link)) + return; + + gc_args.timeout = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_interval), + gc_args.more = 0, + + fib6_age_exceptions(f6i, &gc_args, jiffies); +} +#endif + struct ipv6_route_iter { struct seq_net_private p; struct fib6_walker w; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 0e55f139e05d..f4e23b543585 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -2862,7 +2862,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) fib6_add_gc_list(rt); } else { fib6_clean_expires(rt); - fib6_remove_gc_list(rt); + fib6_may_remove_gc_list(net, rt); } spin_unlock_bh(&table->tb6_lock); @@ -4840,7 +4840,7 @@ static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp, if (!(flags & RTF_EXPIRES)) { fib6_clean_expires(f6i); - fib6_remove_gc_list(f6i); + fib6_may_remove_gc_list(net, f6i); } else { fib6_set_expires(f6i, expires); fib6_add_gc_list(f6i); diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index fadfca49d6b1..dd26657b6a4a 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -1133,7 +1133,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, return -EEXIST; if (!(rt->fib6_flags & RTF_EXPIRES)) { fib6_clean_expires(iter); - fib6_remove_gc_list(iter); + fib6_may_remove_gc_list(info->nl_net, iter); } else { fib6_set_expires(iter, rt->expires); fib6_add_gc_list(iter); @@ -2348,8 +2348,8 @@ static void fib6_flush_trees(struct net *net) /* * Garbage collection */ -static void fib6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args, - unsigned long now) +void fib6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args, + unsigned long now) { bool may_expire = rt->fib6_flags & RTF_EXPIRES && rt->expires; int old_more = gc_args->more; diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 08cd86f49bf9..cb521700cee7 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1033,7 +1033,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, if (!addrconf_finite_timeout(lifetime)) { fib6_clean_expires(rt); - fib6_remove_gc_list(rt); + fib6_may_remove_gc_list(net, rt); } else { fib6_set_expires(rt, jiffies + HZ * lifetime); fib6_add_gc_list(rt); -- 2.53.0.473.g4a7958ca14-goog