Skip to content

Commit 17f2f52

Browse files
Florian Westphalkaber
authored andcommitted
netfilter: ipt_MASQUERADE: remove redundant rwlock
The lock "protects" an assignment and a comparision of an integer. When the caller of device_cmp() evaluates the result, nat->masq_index may already have been changed (regardless if the lock is there or not). So, the lock either has to be held during nf_ct_iterate_cleanup(), or can be removed. This does the latter. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent 10662aa commit 17f2f52

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

‎net/ipv4/netfilter/ipt_MASQUERADE.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ MODULE_LICENSE("GPL");
2727
MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
2828
MODULE_DESCRIPTION("Xtables: automatic-address SNAT");
2929

30-
/* Lock protects masq region inside conntrack */
31-
static DEFINE_RWLOCK(masq_lock);
32-
3330
/* FIXME: Multiple targets. --RR */
3431
static bool masquerade_tg_check(const struct xt_tgchk_param *par)
3532
{
@@ -79,9 +76,7 @@ masquerade_tg(struct sk_buff *skb, const struct xt_target_param *par)
7976
return NF_DROP;
8077
}
8178

82-
write_lock_bh(&masq_lock);
8379
nat->masq_index = par->out->ifindex;
84-
write_unlock_bh(&masq_lock);
8580

8681
/* Transfer from original range. */
8782
newrange = ((struct nf_nat_range)
@@ -97,16 +92,11 @@ static int
9792
device_cmp(struct nf_conn *i, void *ifindex)
9893
{
9994
const struct nf_conn_nat *nat = nfct_nat(i);
100-
int ret;
10195

10296
if (!nat)
10397
return 0;
10498

105-
read_lock_bh(&masq_lock);
106-
ret = (nat->masq_index == (int)(long)ifindex);
107-
read_unlock_bh(&masq_lock);
108-
109-
return ret;
99+
return nat->masq_index == (int)(long)ifindex;
110100
}
111101

112102
static int masq_device_event(struct notifier_block *this,

0 commit comments

Comments
 (0)