]> git.ipfire.org Git - thirdparty/systemd.git/commit
firewall-util-nft: attempt table recreation when add operation fails 17026/head
authorFlorian Westphal <fw@strlen.de>
Mon, 16 Nov 2020 10:15:31 +0000 (11:15 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 16 Dec 2020 00:07:11 +0000 (01:07 +0100)
commitbc5a9b82d5e8649dcd753cd5f2a90eeb07526563
tree1a878037816a378073123f1de43e278c8eb06d83
parent715a70e7218710d6a6c033e9157bf97fdf5d8ede
firewall-util-nft: attempt table recreation when add operation fails

When someone runs 'nft flush ruleset' in the same net namespace
this will also tear down the systemd nat table.

Unlike iptables -t nat -F, which will remove all rules added by
the systemd iptables backend, iptables has builtin chains that cannot
be deleted. IOW, the next add operation will 'just work'.

In the nftables case however, the entire table gets removed.

When the systemd nat table is removed by an external entity next
attempt to add a set element will yield -ENOENT.

If this happens, recreate the table, and, if successful, re-do
the add operation.

Note that this doesn't protect against external sabotage such as
a running 'while true; nft flush ruleset;done'. However, there is
nothing that could be done short of extending the kernel to allow
tables to be "frozen" or otherwise tied to a process such as
systemd-networkd.
src/shared/firewall-util-nft.c