All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarno Rajahalme <jarno@ovn.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Pravin Shelar <pshelar@nicira.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	dev@openvswitch.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] openvswitch: using a bit shift as a mask
Date: Fri, 18 Mar 2016 10:05:54 -0700	[thread overview]
Message-ID: <D6F6A4E4-39BC-46F3-AF93-E71D6E309E42@ovn.org> (raw)
In-Reply-To: <20160317104136.GC3100@mwanda>


> 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

WARNING: multiple messages have this Message-ID (diff)
From: Jarno Rajahalme <jarno@ovn.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Pravin Shelar <pshelar@nicira.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	dev@openvswitch.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] openvswitch: using a bit shift as a mask
Date: Fri, 18 Mar 2016 17:05:54 +0000	[thread overview]
Message-ID: <D6F6A4E4-39BC-46F3-AF93-E71D6E309E42@ovn.org> (raw)
In-Reply-To: <20160317104136.GC3100@mwanda>


> 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


  reply	other threads:[~2016-03-18 17:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 10:41 [patch] openvswitch: using a bit shift as a mask Dan Carpenter
2016-03-17 10:41 ` Dan Carpenter
2016-03-18 17:05 ` Jarno Rajahalme [this message]
2016-03-18 17:05   ` Jarno Rajahalme

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D6F6A4E4-39BC-46F3-AF93-E71D6E309E42@ovn.org \
    --to=jarno@ovn.org \
    --cc=dan.carpenter@oracle.com \
    --cc=dev@openvswitch.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=pshelar@nicira.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.