]> git.itanic.dy.fi Git - linux-stable/commit
netfilter: nf_tables: don't fail inserts if duplicate has expired
authorFlorian Westphal <fw@strlen.de>
Sat, 12 Aug 2023 18:03:57 +0000 (20:03 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 15 Aug 2023 22:05:15 +0000 (00:05 +0200)
commit7845914f45f066497ac75b30c50dbc735e84e884
treea1453c1ae125d4de2824b43dcf1a2b9abcda6228
parent90e5b3462efa37b8bba82d7c4e63683856e188af
netfilter: nf_tables: don't fail inserts if duplicate has expired

nftables selftests fail:
run-tests.sh testcases/sets/0044interval_overlap_0
Expected: 0-2 . 0-3, got:
W: [FAILED]     ./testcases/sets/0044interval_overlap_0: got 1

Insertion must ignore duplicate but expired entries.

Moreover, there is a strange asymmetry in nft_pipapo_activate:

It refetches the current element, whereas the other ->activate callbacks
(bitmap, hash, rhash, rbtree) use elem->priv.
Same for .remove: other set implementations take elem->priv,
nft_pipapo_remove fetches elem->priv, then does a relookup,
remove this.

I suspect this was the reason for the change that prompted the
removal of the expired check in pipapo_get() in the first place,
but skipping exired elements there makes no sense to me, this helper
is used for normal get requests, insertions (duplicate check)
and deactivate callback.

In first two cases expired elements must be skipped.

For ->deactivate(), this gets called for DELSETELEM, so it
seems to me that expired elements should be skipped as well, i.e.
delete request should fail with -ENOENT error.

Fixes: 24138933b97b ("netfilter: nf_tables: don't skip expired elements during walk")
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_set_pipapo.c