erspan: build the header with the right proto according to erspan_ver
As said in draft-foschiano-erspan-03#section4:
Different frame variants known as "ERSPAN Types" can be
distinguished based on the GRE "Protocol Type" field value: Type I
and II's value is 0x88BE while Type III's is 0x22EB [ETYPES].
So set it properly in erspan_xmit() according to erspan_ver. While at
it, also remove the unused parameter 'proto' in erspan_fb_xmit().
Fixes: 94d7d8f292
("ip6_gre: add erspan v2 support")
Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
04a4af334b
commit
20704bd163
2 changed files with 18 additions and 11 deletions
|
@ -569,8 +569,7 @@ err_free_skb:
|
||||||
dev->stats.tx_dropped++;
|
dev->stats.tx_dropped++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
|
static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
__be16 proto)
|
|
||||||
{
|
{
|
||||||
struct ip_tunnel *tunnel = netdev_priv(dev);
|
struct ip_tunnel *tunnel = netdev_priv(dev);
|
||||||
struct ip_tunnel_info *tun_info;
|
struct ip_tunnel_info *tun_info;
|
||||||
|
@ -578,10 +577,10 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||||
struct erspan_metadata *md;
|
struct erspan_metadata *md;
|
||||||
struct rtable *rt = NULL;
|
struct rtable *rt = NULL;
|
||||||
bool truncate = false;
|
bool truncate = false;
|
||||||
|
__be16 df, proto;
|
||||||
struct flowi4 fl;
|
struct flowi4 fl;
|
||||||
int tunnel_hlen;
|
int tunnel_hlen;
|
||||||
int version;
|
int version;
|
||||||
__be16 df;
|
|
||||||
int nhoff;
|
int nhoff;
|
||||||
int thoff;
|
int thoff;
|
||||||
|
|
||||||
|
@ -626,18 +625,20 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||||
if (version == 1) {
|
if (version == 1) {
|
||||||
erspan_build_header(skb, ntohl(tunnel_id_to_key32(key->tun_id)),
|
erspan_build_header(skb, ntohl(tunnel_id_to_key32(key->tun_id)),
|
||||||
ntohl(md->u.index), truncate, true);
|
ntohl(md->u.index), truncate, true);
|
||||||
|
proto = htons(ETH_P_ERSPAN);
|
||||||
} else if (version == 2) {
|
} else if (version == 2) {
|
||||||
erspan_build_header_v2(skb,
|
erspan_build_header_v2(skb,
|
||||||
ntohl(tunnel_id_to_key32(key->tun_id)),
|
ntohl(tunnel_id_to_key32(key->tun_id)),
|
||||||
md->u.md2.dir,
|
md->u.md2.dir,
|
||||||
get_hwid(&md->u.md2),
|
get_hwid(&md->u.md2),
|
||||||
truncate, true);
|
truncate, true);
|
||||||
|
proto = htons(ETH_P_ERSPAN2);
|
||||||
} else {
|
} else {
|
||||||
goto err_free_rt;
|
goto err_free_rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
gre_build_header(skb, 8, TUNNEL_SEQ,
|
gre_build_header(skb, 8, TUNNEL_SEQ,
|
||||||
htons(ETH_P_ERSPAN), 0, htonl(tunnel->o_seqno++));
|
proto, 0, htonl(tunnel->o_seqno++));
|
||||||
|
|
||||||
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
|
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
|
||||||
|
|
||||||
|
@ -721,12 +722,13 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
|
||||||
{
|
{
|
||||||
struct ip_tunnel *tunnel = netdev_priv(dev);
|
struct ip_tunnel *tunnel = netdev_priv(dev);
|
||||||
bool truncate = false;
|
bool truncate = false;
|
||||||
|
__be16 proto;
|
||||||
|
|
||||||
if (!pskb_inet_may_pull(skb))
|
if (!pskb_inet_may_pull(skb))
|
||||||
goto free_skb;
|
goto free_skb;
|
||||||
|
|
||||||
if (tunnel->collect_md) {
|
if (tunnel->collect_md) {
|
||||||
erspan_fb_xmit(skb, dev, skb->protocol);
|
erspan_fb_xmit(skb, dev);
|
||||||
return NETDEV_TX_OK;
|
return NETDEV_TX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,19 +744,22 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Push ERSPAN header */
|
/* Push ERSPAN header */
|
||||||
if (tunnel->erspan_ver == 1)
|
if (tunnel->erspan_ver == 1) {
|
||||||
erspan_build_header(skb, ntohl(tunnel->parms.o_key),
|
erspan_build_header(skb, ntohl(tunnel->parms.o_key),
|
||||||
tunnel->index,
|
tunnel->index,
|
||||||
truncate, true);
|
truncate, true);
|
||||||
else if (tunnel->erspan_ver == 2)
|
proto = htons(ETH_P_ERSPAN);
|
||||||
|
} else if (tunnel->erspan_ver == 2) {
|
||||||
erspan_build_header_v2(skb, ntohl(tunnel->parms.o_key),
|
erspan_build_header_v2(skb, ntohl(tunnel->parms.o_key),
|
||||||
tunnel->dir, tunnel->hwid,
|
tunnel->dir, tunnel->hwid,
|
||||||
truncate, true);
|
truncate, true);
|
||||||
else
|
proto = htons(ETH_P_ERSPAN2);
|
||||||
|
} else {
|
||||||
goto free_skb;
|
goto free_skb;
|
||||||
|
}
|
||||||
|
|
||||||
tunnel->parms.o_flags &= ~TUNNEL_KEY;
|
tunnel->parms.o_flags &= ~TUNNEL_KEY;
|
||||||
__gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_ERSPAN));
|
__gre_xmit(skb, dev, &tunnel->parms.iph, proto);
|
||||||
return NETDEV_TX_OK;
|
return NETDEV_TX_OK;
|
||||||
|
|
||||||
free_skb:
|
free_skb:
|
||||||
|
|
|
@ -922,6 +922,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
|
||||||
__u8 dsfield = false;
|
__u8 dsfield = false;
|
||||||
struct flowi6 fl6;
|
struct flowi6 fl6;
|
||||||
int err = -EINVAL;
|
int err = -EINVAL;
|
||||||
|
__be16 proto;
|
||||||
__u32 mtu;
|
__u32 mtu;
|
||||||
int nhoff;
|
int nhoff;
|
||||||
int thoff;
|
int thoff;
|
||||||
|
@ -1035,8 +1036,9 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Push GRE header. */
|
/* Push GRE header. */
|
||||||
gre_build_header(skb, 8, TUNNEL_SEQ,
|
proto = (t->parms.erspan_ver == 1) ? htons(ETH_P_ERSPAN)
|
||||||
htons(ETH_P_ERSPAN), 0, htonl(t->o_seqno++));
|
: htons(ETH_P_ERSPAN2);
|
||||||
|
gre_build_header(skb, 8, TUNNEL_SEQ, proto, 0, htonl(t->o_seqno++));
|
||||||
|
|
||||||
/* TooBig packet may have updated dst->dev's mtu */
|
/* TooBig packet may have updated dst->dev's mtu */
|
||||||
if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu)
|
if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu)
|
||||||
|
|
Loading…
Add table
Reference in a new issue