]> git.proxmox.com Git - mirror_ovs.git/commitdiff
erspan: auto detect truncated ipv6 packets.
authorWilliam Tu <u9012063@gmail.com>
Sun, 13 May 2018 14:03:49 +0000 (07:03 -0700)
committerBen Pfaff <blp@ovn.org>
Tue, 22 May 2018 03:33:30 +0000 (20:33 -0700)
Upstream commit:
    commit d5db21a3e6977dcb42cee3d16cd69901fa66510a
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri May 11 05:49:47 2018 -0700

    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>
Signed-off-by: William Tu <u9012063@gmail.com>
Cc: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
datapath/linux/compat/ip6_gre.c
datapath/linux/compat/ip_gre.c

index c9bd80dac69eea6f4f9eddca5409204f1a9b04d4..59694dd6c9df77ba014b98bf908097004f6502d0 100644 (file)
@@ -1071,6 +1071,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
        __be32 tun_id;
        __u32 mtu;
        int nhoff;
+       int thoff;
 
 
        /* OVS doesn't support native mode ip6 tunnel traffic so
@@ -1094,6 +1095,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
            (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 (skb_cow_head(skb, dev->needed_headroom))
                goto tx_err;
 
index 6b400139f0fc2eb7df2b62489fa41e4ddc750abf..6001d69b65fdab4dd2fbb8caec4cff36d31eef21 100644 (file)
@@ -632,6 +632,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) ||
@@ -664,6 +665,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);