ip_gre: get key from session_id correctly in erspan_rcv

erspan only uses the first 10 bits of session_id as the key to look
up the tunnel. But in erspan_rcv, it missed 'session_id & ID_MASK'
when getting the key from session_id.

If any other flag is also set in session_id in a packet, it would
fail to find the tunnel due to incorrect key in erspan_rcv.

This patch is to add 'session_id & ID_MASK' there and also remove
the unnecessary variable session_id.

Fixes: 84e54fe0a5 ("gre: introduce native tunnel support for ERSPAN")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Xin Long 2017-10-01 22:00:53 +08:00 committed by David S. Miller
parent aad06212d3
commit 935a9749a3
1 changed files with 1 additions and 3 deletions

View File

@ -259,7 +259,6 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
struct ip_tunnel *tunnel; struct ip_tunnel *tunnel;
struct erspanhdr *ershdr; struct erspanhdr *ershdr;
const struct iphdr *iph; const struct iphdr *iph;
__be32 session_id;
__be32 index; __be32 index;
int len; int len;
@ -275,8 +274,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
/* The original GRE header does not have key field, /* The original GRE header does not have key field,
* Use ERSPAN 10-bit session ID as key. * Use ERSPAN 10-bit session ID as key.
*/ */
session_id = cpu_to_be32(ntohs(ershdr->session_id)); tpi->key = cpu_to_be32(ntohs(ershdr->session_id) & ID_MASK);
tpi->key = session_id;
index = ershdr->md.index; index = ershdr->md.index;
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex,
tpi->flags | TUNNEL_KEY, tpi->flags | TUNNEL_KEY,