]> git.ipfire.org Git - thirdparty/nftables.git/commit
evaluate: set NFT_SET_EVAL flag if dynamic set already exists
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 18 May 2023 12:40:38 +0000 (14:40 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 2 Nov 2023 10:56:20 +0000 (11:56 +0100)
commita566d41a3b2eab1ade5daaff13ba6fda339055e2
tree5065b5575d90e33d3e85ab42d12e2bb7fa60c8e2
parentf0b297aeadd4bcd332fd971ef1276e006999cd21
evaluate: set NFT_SET_EVAL flag if dynamic set already exists

commit 5629f9c211fff71b72f2ba0c452801605b63cbfb upstream.

nft reports EEXIST when reading an existing set whose NFT_SET_EVAL has
been previously inferred from the ruleset.

 # cat test.nft
 table ip test {
        set dlist {
                type ipv4_addr
                size 65535
        }

        chain output {
                type filter hook output priority filter; policy accept;
                udp dport 1234 update @dlist { ip daddr } counter packets 0 bytes 0
        }
 }
 # nft -f test.nft
 # nft -f test.nft
 test.nft:2:6-10: Error: Could not process rule: File exists
         set dlist {
             ^^^^^

Phil Sutter says:

In the first call, the set lacking 'dynamic' flag does not exist
and is therefore added to the cache. Consequently, both the 'add set'
command and the set statement point at the same set object. In the
second call, a set with same name exists already, so the object created
for 'add set' command is not added to cache and consequently not updated
with the missing flag. The kernel thus rejects the NEWSET request as the
existing set differs from the new one.

Set on the NFT_SET_EVAL flag if the existing set sets it on.

Fixes: 8d443adfcc8c1 ("evaluate: attempt to set_eval flag if dynamic updates requested")
Tested-by: Eric Garver <eric@garver.life>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c