提交 d5db21a3 编写于 作者: W William Tu 提交者: David S. Miller

erspan: auto detect truncated ipv6 packets.

Currently the truncated bit is set only when 1) the mirrored packet
is larger than mtu and 2) the ipv4 packet tot_len is larger than
the actual skb->len.  This patch adds another case for detecting
whether ipv6 packet is truncated or not, by checking the ipv6 header
payload_len and the skb->len.
Reported-by: NXiaoyan Jin <xiaoyanj@vmware.com>
Signed-off-by: NWilliam Tu <u9012063@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 755bbc1c
...@@ -579,6 +579,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev, ...@@ -579,6 +579,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
int version; int version;
__be16 df; __be16 df;
int nhoff; int nhoff;
int thoff;
tun_info = skb_tunnel_info(skb); tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) || if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
...@@ -611,6 +612,11 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev, ...@@ -611,6 +612,11 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
(ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff)) (ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff))
truncate = true; truncate = true;
thoff = skb_transport_header(skb) - skb_mac_header(skb);
if (skb->protocol == htons(ETH_P_IPV6) &&
(ntohs(ipv6_hdr(skb)->payload_len) > skb->len - thoff))
truncate = true;
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);
......
...@@ -897,6 +897,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, ...@@ -897,6 +897,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
int err = -EINVAL; int err = -EINVAL;
__u32 mtu; __u32 mtu;
int nhoff; int nhoff;
int thoff;
if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr)) if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
goto tx_err; goto tx_err;
...@@ -914,6 +915,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, ...@@ -914,6 +915,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
(ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff)) (ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff))
truncate = true; truncate = true;
thoff = skb_transport_header(skb) - skb_mac_header(skb);
if (skb->protocol == htons(ETH_P_IPV6) &&
(ntohs(ipv6_hdr(skb)->payload_len) > skb->len - thoff))
truncate = true;
if (skb_cow_head(skb, dev->needed_headroom)) if (skb_cow_head(skb, dev->needed_headroom))
goto tx_err; goto tx_err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册