summaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_gre.c
diff options
context:
space:
mode:
authorWilliam Tu <u9012063@gmail.com>2018-05-11 14:49:47 +0200
committerDavid S. Miller <davem@davemloft.net>2018-05-11 22:03:49 +0200
commitd5db21a3e6977dcb42cee3d16cd69901fa66510a (patch)
tree02531f421723d9954ab3a3013e44e864890c6449 /net/ipv4/ip_gre.c
parentMerge branch 'mlxsw-spectrum_span-Two-minor-adjustments' (diff)
downloadlinux-d5db21a3e6977dcb42cee3d16cd69901fa66510a.tar.xz
linux-d5db21a3e6977dcb42cee3d16cd69901fa66510a.zip
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: Xiaoyan Jin <xiaoyanj@vmware.com> Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_gre.c')
-rw-r--r--net/ipv4/ip_gre.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index dfe5b22f6ed4..2409e648454d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -579,6 +579,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
int version;
__be16 df;
int nhoff;
+ int thoff;
tun_info = skb_tunnel_info(skb);
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,
(ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff))
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) {
erspan_build_header(skb, ntohl(tunnel_id_to_key32(key->tun_id)),
ntohl(md->u.index), truncate, true);