All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] openvswitch: using a bit shift as a mask
@ 2016-03-17 10:41 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-03-17 10:41 UTC (permalink / raw)
  To: Pravin Shelar, Pablo Neira Ayuso, Jarno Rajahalme
  Cc: dev, linux-kernel, kernel-janitors

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] openvswitch: using a bit shift as a mask
@ 2016-03-17 10:41 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-03-17 10:41 UTC (permalink / raw)
  To: Pravin Shelar, Pablo Neira Ayuso, Jarno Rajahalme
  Cc: dev, linux-kernel, kernel-janitors

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] openvswitch: using a bit shift as a mask
  2016-03-17 10:41 ` Dan Carpenter
@ 2016-03-18 17:05   ` Jarno Rajahalme
  -1 siblings, 0 replies; 4+ messages in thread
From: Jarno Rajahalme @ 2016-03-18 17:05 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Pravin Shelar, Pablo Neira Ayuso, dev, linux-kernel, kernel-janitors


> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] openvswitch: using a bit shift as a mask
@ 2016-03-18 17:05   ` Jarno Rajahalme
  0 siblings, 0 replies; 4+ messages in thread
From: Jarno Rajahalme @ 2016-03-18 17:05 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Pravin Shelar, Pablo Neira Ayuso, dev, linux-kernel, kernel-janitors


> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-18 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-03-18 17:05   ` Jarno Rajahalme

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.