Skip to content

Commit 216e7bf

Browse files
committed
netfilter: nf_tables: skip netdev hook unregistration if table is dormant
Skip hook unregistration when adding or deleting devices from an existing netdev basechain. Otherwise, commit/abort path try to unregister hooks which not enabled. Fixes: b9703ed ("netfilter: nf_tables: support for adding new devices to an existing netdev chain") Fixes: 7d937b1 ("netfilter: nf_tables: support for deleting devices in an existing netdev chain") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 1e1fb6f commit 216e7bf

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10212,9 +10212,11 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
1021210212
if (nft_trans_chain_update(trans)) {
1021310213
nf_tables_chain_notify(&trans->ctx, NFT_MSG_DELCHAIN,
1021410214
&nft_trans_chain_hooks(trans));
10215-
nft_netdev_unregister_hooks(net,
10216-
&nft_trans_chain_hooks(trans),
10217-
true);
10215+
if (!(trans->ctx.table->flags & NFT_TABLE_F_DORMANT)) {
10216+
nft_netdev_unregister_hooks(net,
10217+
&nft_trans_chain_hooks(trans),
10218+
true);
10219+
}
1021810220
} else {
1021910221
nft_chain_del(trans->ctx.chain);
1022010222
nf_tables_chain_notify(&trans->ctx, NFT_MSG_DELCHAIN,
@@ -10490,9 +10492,11 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
1049010492
break;
1049110493
case NFT_MSG_NEWCHAIN:
1049210494
if (nft_trans_chain_update(trans)) {
10493-
nft_netdev_unregister_hooks(net,
10494-
&nft_trans_chain_hooks(trans),
10495-
true);
10495+
if (!(trans->ctx.table->flags & NFT_TABLE_F_DORMANT)) {
10496+
nft_netdev_unregister_hooks(net,
10497+
&nft_trans_chain_hooks(trans),
10498+
true);
10499+
}
1049610500
free_percpu(nft_trans_chain_stats(trans));
1049710501
kfree(nft_trans_chain_name(trans));
1049810502
nft_trans_destroy(trans);

0 commit comments

Comments
 (0)