Skip to contentSkip to conversation

netfilter: don't use atomic bit operation

PATCH Applied Changli Gao 2 participants 3 messages Nov 14, 2010 – Nov 20, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: don't use atomic bit operation

As we own ct, and the others can't see it until we confirm it, we don't need to use atomic bit operation on ct->status.

---
 include/net/netfilter/nf_nat_core.h |    4 ++--
 net/ipv4/netfilter/nf_nat_core.c    |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/net/netfilter/nf_nat_core.h +2 -2
index 33602ab..52ac1d8 100644
@@ -21,9 +21,9 @@ static inline int nf_nat_initialized(struct nf_conn *ct,
 				     enum nf_nat_manip_type manip)
 {
 	if (manip == IP_NAT_MANIP_SRC)
-		return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
+		return IPS_SRC_NAT_DONE_BIT & ct->status;
 	else
-		return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
+		return IPS_DST_NAT_DONE_BIT & ct->status;
 }
 
 struct nlattr;
net/ipv4/netfilter/nf_nat_core.c +2 -2
index c04787c..ab877ac 100644
@@ -323,9 +323,9 @@ nf_nat_setup_info(struct nf_conn *ct,
 
 	/* It's done. */
 	if (maniptype == IP_NAT_MANIP_DST)
-		set_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
+		ct->status |= IPS_DST_NAT_DONE_BIT;
 	else
-		set_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
+		ct->status |= IPS_SRC_NAT_DONE_BIT;
 
 	return NF_ACCEPT;
 }
#1 lore raw
Quoted 13 lines · Changli Gao

As we own ct, and the others can't see it until we confirm it, we don't need to use atomic bit operation on ct->status.

---
 include/net/netfilter/nf_nat_core.h |    4 ++--
 net/ipv4/netfilter/nf_nat_core.c    |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/net/netfilter/nf_nat_core.h +0 -0
index 33602ab..52ac1d8 100644

include/net/netfilter/nf_nat_core.h static inline int nf_nat_initialized(struct nf_conn *ct, · line 27

Quoted 9 lines
include/net/netfilter/nf_nat_core.h +2 -2
@@ -21,9 +21,9 @@ static inline int nf_nat_initialized(struct nf_conn *ct,
 				     enum nf_nat_manip_type manip)
 {
 	if (manip == IP_NAT_MANIP_SRC)
-		return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
+		return IPS_SRC_NAT_DONE_BIT & ct->status;
 	else
-		return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
+		return IPS_DST_NAT_DONE_BIT & ct->status;
 }

Looks fine, but I changed the order to ct->status & ...

Applied.

#2 lore raw
Quoted 17 lines · Patrick McHardy
Quoted 16 lines · Changli Gao

As we own ct, and the others can't see it until we confirm it, we don't need to use atomic bit operation on ct->status.

---
 include/net/netfilter/nf_nat_core.h |    4 ++--
 net/ipv4/netfilter/nf_nat_core.c    |    4 ++--

 2 files changed, 4 insertions(+), 4 deletions(-)
include/net/netfilter/nf_nat_core.h +0 -0
index 33602ab..52ac1d8 100644
@@ -21,9 +21,9 @@ static inline int nf_nat_initialized(struct nf_conn *ct,
                                    enum nf_nat_manip_type manip)
  {
       if (manip == IP_NAT_MANIP_SRC)
Quoted 9 lines
Quoted 6 lines
include/net/netfilter/nf_nat_core.h +1 -1
-             return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
+             return IPS_SRC_NAT_DONE_BIT & ct->status;

      else
-             return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
+             return IPS_DST_NAT_DONE_BIT & ct->status; }

Looks fine, but I changed the order to ct->status & ...

Sorry, I made a mistake. The suffix _BIT should be removed.

Signature · 6 lines
Regards,
Changli Gao([email protected])
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html