Commit 2420770b3fe56ca97ecf34e230762cd9f3296dae

Authored by Florian Westphal
Committed by Pablo Neira Ayuso
1 parent 63c2af90e5

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 <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

Showing 1 changed file with 3 additions and 6 deletions Side-by-side Diff

net/netfilter/nf_nat_core.c
... ... @@ -542,17 +542,14 @@
542 542 if (nf_nat_proto_remove(ct, data))
543 543 return 1;
544 544  
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.
549 546 * Remove it from bysource hash, as the table will be freed soon.
550 547 *
551 548 * Else, when the conntrack is destoyed, nf_nat_cleanup_conntrack()
552 549 * will delete entry from already-freed table.
553 550 */
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);
556 553  
557 554 /* don't delete conntrack. Although that would make things a lot
558 555 * simpler, we'd end up flushing all conntracks on nat rmmod.