Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1359727 > unrolled thread

[patch] openvswitch: using a bit shift as a mask

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-03-17 11:50 +0100
Last post2016-03-18 18:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] openvswitch: using a bit shift as a mask Dan Carpenter <dan.carpenter@oracle.com> - 2016-03-17 11:50 +0100
    Re: [patch] openvswitch: using a bit shift as a mask Jarno Rajahalme <jarno@ovn.org> - 2016-03-18 18:20 +0100

#1359727 — [patch] openvswitch: using a bit shift as a mask

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-03-17 11:50 +0100
Subject[patch] openvswitch: using a bit shift as a mask
Message-ID<rdDF8-6fy-9@gated-at.bofh.it>
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.')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index dc5eb29..29c82d6 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -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

[toc] | [next] | [standalone]


#1360815

FromJarno Rajahalme <jarno@ovn.org>
Date2016-03-18 18:20 +0100
Message-ID<re6e7-2TF-21@gated-at.bofh.it>
In reply to#1359727
> On Mar 17, 2016, at 3:41 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> 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.')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index dc5eb29..29c82d6 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -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:

> +	    (!test_bit(IPS_EXPECTED_BIT, &ct->status) || info->commit)) {


  Jarno

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web