All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering
@ 2018-03-21 19:34 Colin King
  2018-03-21 21:22   ` William Tu
  2018-03-22 18:53   ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Colin King @ 2018-03-21 19:34 UTC (permalink / raw)
  To: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The current logic of flags | TUNNEL_SEQ is always non-zero and hence
sequence numbers are always incremented no matter the setting of the
TUNNEL_SEQ bit.  Fix this by using & instead of |.

Detected by CoverityScan, CID#1466039 ("Operands don't affect result")

Fixes: 77a5196a804e ("gre: add sequence number for collect md mode.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/ipv4/ip_gre.c  | 2 +-
 net/ipv6/ip6_gre.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 2fa2ef2e2af9..9ab1aa2f7660 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -550,7 +550,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 		(TUNNEL_CSUM | TUNNEL_KEY | TUNNEL_SEQ);
 	gre_build_header(skb, tunnel_hlen, flags, proto,
 			 tunnel_id_to_key32(tun_info->key.tun_id),
-			 (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
+			 (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
 
 	df = key->tun_flags & TUNNEL_DONT_FRAGMENT ?  htons(IP_DF) : 0;
 
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 0bcefc480aeb..3a98c694da5f 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -725,7 +725,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
 		gre_build_header(skb, tunnel->tun_hlen,
 				 flags, protocol,
 				 tunnel_id_to_key32(tun_info->key.tun_id),
-				 (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
+				 (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
 						      : 0);
 
 	} else {
-- 
2.15.1

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

* Re: [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering
  2018-03-21 19:34 [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering Colin King
@ 2018-03-21 21:22   ` William Tu
  2018-03-22 18:53   ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: William Tu @ 2018-03-21 21:22 UTC (permalink / raw)
  To: Colin King
  Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	Linux Kernel Network Developers, kernel-janitors, LKML

On Wed, Mar 21, 2018 at 12:34 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current logic of flags | TUNNEL_SEQ is always non-zero and hence
> sequence numbers are always incremented no matter the setting of the
> TUNNEL_SEQ bit.  Fix this by using & instead of |.
>
> Detected by CoverityScan, CID#1466039 ("Operands don't affect result")
>
> Fixes: 77a5196a804e ("gre: add sequence number for collect md mode.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks for the fix!
btw, how can I access the CoverityScan result with this CID?

Acked-by: William Tu <u9012063@gmail.com>


> ---
>  net/ipv4/ip_gre.c  | 2 +-
>  net/ipv6/ip6_gre.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index 2fa2ef2e2af9..9ab1aa2f7660 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -550,7 +550,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
>                 (TUNNEL_CSUM | TUNNEL_KEY | TUNNEL_SEQ);
>         gre_build_header(skb, tunnel_hlen, flags, proto,
>                          tunnel_id_to_key32(tun_info->key.tun_id),
> -                        (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
> +                        (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
>
>         df = key->tun_flags & TUNNEL_DONT_FRAGMENT ?  htons(IP_DF) : 0;
>
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 0bcefc480aeb..3a98c694da5f 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -725,7 +725,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
>                 gre_build_header(skb, tunnel->tun_hlen,
>                                  flags, protocol,
>                                  tunnel_id_to_key32(tun_info->key.tun_id),
> -                                (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
> +                                (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
>                                                       : 0);
>
>         } else {
> --
> 2.15.1
>

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

* Re: [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering
@ 2018-03-21 21:22   ` William Tu
  0 siblings, 0 replies; 5+ messages in thread
From: William Tu @ 2018-03-21 21:22 UTC (permalink / raw)
  To: Colin King
  Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	Linux Kernel Network Developers, kernel-janitors, LKML

On Wed, Mar 21, 2018 at 12:34 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current logic of flags | TUNNEL_SEQ is always non-zero and hence
> sequence numbers are always incremented no matter the setting of the
> TUNNEL_SEQ bit.  Fix this by using & instead of |.
>
> Detected by CoverityScan, CID#1466039 ("Operands don't affect result")
>
> Fixes: 77a5196a804e ("gre: add sequence number for collect md mode.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks for the fix!
btw, how can I access the CoverityScan result with this CID?

Acked-by: William Tu <u9012063@gmail.com>


> ---
>  net/ipv4/ip_gre.c  | 2 +-
>  net/ipv6/ip6_gre.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index 2fa2ef2e2af9..9ab1aa2f7660 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -550,7 +550,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
>                 (TUNNEL_CSUM | TUNNEL_KEY | TUNNEL_SEQ);
>         gre_build_header(skb, tunnel_hlen, flags, proto,
>                          tunnel_id_to_key32(tun_info->key.tun_id),
> -                        (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
> +                        (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
>
>         df = key->tun_flags & TUNNEL_DONT_FRAGMENT ?  htons(IP_DF) : 0;
>
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 0bcefc480aeb..3a98c694da5f 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -725,7 +725,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
>                 gre_build_header(skb, tunnel->tun_hlen,
>                                  flags, protocol,
>                                  tunnel_id_to_key32(tun_info->key.tun_id),
> -                                (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
> +                                (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
>                                                       : 0);
>
>         } else {
> --
> 2.15.1
>

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

* Re: [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering
  2018-03-21 19:34 [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering Colin King
@ 2018-03-22 18:53   ` David Miller
  2018-03-22 18:53   ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-22 18:53 UTC (permalink / raw)
  To: colin.king; +Cc: kuznet, yoshfuji, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Wed, 21 Mar 2018 19:34:58 +0000

> From: Colin Ian King <colin.king@canonical.com>
> 
> The current logic of flags | TUNNEL_SEQ is always non-zero and hence
> sequence numbers are always incremented no matter the setting of the
> TUNNEL_SEQ bit.  Fix this by using & instead of |.
> 
> Detected by CoverityScan, CID#1466039 ("Operands don't affect result")
> 
> Fixes: 77a5196a804e ("gre: add sequence number for collect md mode.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks Colin.

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

* Re: [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering
@ 2018-03-22 18:53   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-22 18:53 UTC (permalink / raw)
  To: colin.king; +Cc: kuznet, yoshfuji, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Wed, 21 Mar 2018 19:34:58 +0000

> From: Colin Ian King <colin.king@canonical.com>
> 
> The current logic of flags | TUNNEL_SEQ is always non-zero and hence
> sequence numbers are always incremented no matter the setting of the
> TUNNEL_SEQ bit.  Fix this by using & instead of |.
> 
> Detected by CoverityScan, CID#1466039 ("Operands don't affect result")
> 
> Fixes: 77a5196a804e ("gre: add sequence number for collect md mode.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks Colin.

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

end of thread, other threads:[~2018-03-22 18:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 19:34 [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering Colin King
2018-03-21 21:22 ` William Tu
2018-03-21 21:22   ` William Tu
2018-03-22 18:53 ` David Miller
2018-03-22 18:53   ` David Miller

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.