Skip to contentSkip to conversation

openvswitch: using a bit shift as a mask

PATCH Superseded Dan Carpenter 2 participants 2 messages Mar 17, 2016 – Mar 18, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 openvswitch: using a bit shift as a mask

The original condition is never true. We want to test if BIT(0) is set but the code is ANDing with zero.

Fixes 05752523e565 ('openvswitch: Interface with NAT.')
net/openvswitch/conntrack.c +1 -1
index dc5eb29..29c82d6 100644
@@ -668,7 +668,7 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key,
 	 */
 	if (info->nat & OVS_CT_NAT && ctinfo != IP_CT_NEW &&
 	    ct->status & IPS_NAT_MASK &&
-	    (!(ct->status & IPS_EXPECTED_BIT) || info->commit)) {
+	    (!(ct->status & IPS_EXPECTED) || info->commit)) {
 		/* NAT an established or related connection like before. */
 		if (CTINFO2DIR(ctinfo) = IP_CT_DIR_REPLY)
 			/* This is the REPLY direction for a connection
#1 lore raw
Quoted 14 lines · Dan Carpenter

The original condition is never true. We want to test if BIT(0) is set but the code is ANDing with zero.

Fixes 05752523e565 ('openvswitch: Interface with NAT.')
net/openvswitch/conntrack.c +0 -0
index dc5eb29..29c82d6 100644

net/openvswitch/conntrack.c static int ovs_ct_nat(struct net *net, struct sw_flow_key *key, · line 674

Quoted 8 lines
net/openvswitch/conntrack.c +1 -1
@@ -668,7 +668,7 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key,
 	 */
 	if (info->nat & OVS_CT_NAT && ctinfo != IP_CT_NEW &&
 	    ct->status & IPS_NAT_MASK &&
-	    (!(ct->status & IPS_EXPECTED_BIT) || info->commit)) {
+	    (!(ct->status & IPS_EXPECTED) || info->commit)) {
 		/* NAT an established or related connection like before. */
 		if (CTINFO2DIR(ctinfo) = IP_CT_DIR_REPLY)
 			/* This is the REPLY direction for a connection

Thanks for spotting this! Maybe it would be even better to use the test_bit() function, like this:

net/openvswitch/conntrack.c

Quoted 1 line
net/openvswitch/conntrack.c +1 -0
+	    (!test_bit(IPS_EXPECTED_BIT, &ct->status) || info->commit)) {

Jarno