Skip to contentSkip to conversation

netfilter: nf_tables: don't unregister hook when table is dormant

PATCH New Pablo Neira Ayuso 1 participant 1 message Apr 2, 2025

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH v2 1/1 netfilter: nf_tables: don't unregister hook when table is dormant

From: Florian Westphal <[email protected]>

When nf_tables_updchain encounters an error, hook registration needs to be rolled back.

This should only be done if the hook has been registered, which won't happen when the table is flagged as dormant (inactive).

Just move the assignment into the registration block.

Reported-by [email protected]
Fixes b9703ed44ffb ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")

---
v2: toggle unregister flag only for netdev basechain.

 net/netfilter/nf_tables_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +2 -2
index c2df81b7e950..a133e1c175ce 100644
@@ -2839,11 +2839,11 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
 			err = nft_netdev_register_hooks(ctx->net, &hook.list);
 			if (err < 0)
 				goto err_hooks;
+
+			unregister = true;
 		}
 	}
 
-	unregister = true;
-
 	if (nla[NFTA_CHAIN_COUNTERS]) {
 		if (!nft_is_base_chain(chain)) {
 			err = -EOPNOTSUPP;
Signature · 1 line
2.30.2