Skip to content

Commit 2f99aa3

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nf_tables: skip synchronize_rcu if transaction log is empty
After processing the transaction log, the remaining entries of the log need to be released. However, in some cases no entries remain, e.g. because the transaction did not remove anything. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent dceb48d commit 2f99aa3

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5761,7 +5761,7 @@ static void nft_chain_commit_update(struct nft_trans *trans)
57615761
}
57625762
}
57635763

5764-
static void nf_tables_commit_release(struct nft_trans *trans)
5764+
static void nft_commit_release(struct nft_trans *trans)
57655765
{
57665766
switch (trans->msg_type) {
57675767
case NFT_MSG_DELTABLE:
@@ -5790,6 +5790,21 @@ static void nf_tables_commit_release(struct nft_trans *trans)
57905790
kfree(trans);
57915791
}
57925792

5793+
static void nf_tables_commit_release(struct net *net)
5794+
{
5795+
struct nft_trans *trans, *next;
5796+
5797+
if (list_empty(&net->nft.commit_list))
5798+
return;
5799+
5800+
synchronize_rcu();
5801+
5802+
list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) {
5803+
list_del(&trans->list);
5804+
nft_commit_release(trans);
5805+
}
5806+
}
5807+
57935808
static int nf_tables_commit(struct net *net, struct sk_buff *skb)
57945809
{
57955810
struct nft_trans *trans, *next;
@@ -5920,13 +5935,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
59205935
}
59215936
}
59225937

5923-
synchronize_rcu();
5924-
5925-
list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) {
5926-
list_del(&trans->list);
5927-
nf_tables_commit_release(trans);
5928-
}
5929-
5938+
nf_tables_commit_release(net);
59305939
nf_tables_gen_notify(net, skb, NFT_MSG_NEWGEN);
59315940

59325941
return 0;

0 commit comments

Comments
 (0)