Skip to content

Commit

Permalink
erspan: fix invalid erspan version.
Browse files Browse the repository at this point in the history
ERSPAN only support version 1 and 2.  When packets send to an
erspan device which does not have proper version number set,
drop the packet.  In real case, we observe multicast packets
sent to the erspan pernet device, erspan0, which does not have
erspan version configured.

Reported-by: Greg Rose <[email protected]>
Signed-off-by: William Tu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
williamtu authored and davem330 committed May 17, 2018
1 parent d13d170 commit 02f99df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
erspan_build_header(skb, ntohl(tunnel->parms.o_key),
tunnel->index,
truncate, true);
else
else if (tunnel->erspan_ver == 2)
erspan_build_header_v2(skb, ntohl(tunnel->parms.o_key),
tunnel->dir, tunnel->hwid,
truncate, true);
else
goto free_skb;

tunnel->parms.o_flags &= ~TUNNEL_KEY;
__gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_ERSPAN));
Expand Down
5 changes: 4 additions & 1 deletion net/ipv6/ip6_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,14 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
erspan_build_header(skb, ntohl(t->parms.o_key),
t->parms.index,
truncate, false);
else
else if (t->parms.erspan_ver == 2)
erspan_build_header_v2(skb, ntohl(t->parms.o_key),
t->parms.dir,
t->parms.hwid,
truncate, false);
else
goto tx_err;

fl6.daddr = t->parms.raddr;
}

Expand Down

0 comments on commit 02f99df

Please sign in to comment.