mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element
@ 2026-11-30  2:55 Hu Xinyao
  2026-11-30  2:59 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: Hu Xinyao @ 2026-11-30  2:55 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal
  Cc: Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Willem de Bruijn, Simon Horman, netfilter-devel,
	coreteam, netdev, linux-kernel

nft_rbtree_gc_scan() iterates the rbtree from highest to lowest key and
records each active NFT_SET_ELEM_INTERVAL_END node in rbe_end so it can
be removed alongside its matching start element.

When the start element is not expired, the loop skips it without
clearing rbe_end. If a subsequent lower-valued expired start element is
not preceded by its own active end node (for instance, after its end
marker was separately removed via NFT_MSG_DELSETELEM), gc_scan()
deactivates and erases the stale rbe_end belonging to the live interval.

Reset rbe_end to NULL when skipping an unexpired start element.

Fixes: 8d8540c4f5e0 ("netfilter: nft_set_rbtree: add timeout support")
Cc: stable@vger.kernel.org
Signed-off-by: Hu Xinyao <huxinyao@kylinsec.com.cn>
---
 net/netfilter/nft_set_rbtree.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
index 9d68589..2f7887e 100644
--- a/net/netfilter/nft_set_rbtree.c
+++ b/net/netfilter/nft_set_rbtree.c
@@ -911,8 +911,10 @@ static void nft_rbtree_gc_scan(struct nft_set *set)
 			rbe_end = rbe;
 			continue;
 		}
-		if (!__nft_set_elem_expired(&rbe->ext, tstamp))
+		if (!__nft_set_elem_expired(&rbe->ext, tstamp)) {
+			rbe_end = NULL;
 			continue;
+		}
 
 		/* end element needs to be removed first, it has
 		 * no timeout extension.
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30  3:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30  2:55 [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element Hu Xinyao
2026-11-30  2:59 ` netdev-bot+sinfo
2026-11-30  3:09   ` Hu Xinyao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®