Skip to content

Commit 2420770

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nat: use test_and_clear_bit when deleting ct from bysource list
We can use a single statement for this. While at it, fixup the comment -- we don't have pernet table/ops anymore, the function is only called from module exit path. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 63c2af9 commit 2420770

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

net/netfilter/nf_nat_core.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,14 @@ static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
542542
if (nf_nat_proto_remove(ct, data))
543543
return 1;
544544

545-
if ((ct->status & IPS_SRC_NAT_DONE) == 0)
546-
return 0;
547-
548-
/* This netns is being destroyed, and conntrack has nat null binding.
545+
/* This module is being removed and conntrack has nat null binding.
549546
* Remove it from bysource hash, as the table will be freed soon.
550547
*
551548
* Else, when the conntrack is destoyed, nf_nat_cleanup_conntrack()
552549
* will delete entry from already-freed table.
553550
*/
554-
clear_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
555-
__nf_nat_cleanup_conntrack(ct);
551+
if (test_and_clear_bit(IPS_SRC_NAT_DONE_BIT, &ct->status))
552+
__nf_nat_cleanup_conntrack(ct);
556553

557554
/* don't delete conntrack. Although that would make things a lot
558555
* simpler, we'd end up flushing all conntracks on nat rmmod.

0 commit comments

Comments
 (0)