Skip to content

Commit

Permalink
gre: fix TUNNEL_SEQ bit check on sequence numbering
Browse files Browse the repository at this point in the history
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: 77a5196 ("gre: add sequence number for collect md mode.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Colin Ian King authored and David S. Miller committed Mar 22, 2018
1 parent faf4db0 commit 1574639
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/ip6_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,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 {
Expand Down

0 comments on commit 1574639

Please sign in to comment.