lwtunnel: add options process for arp request
authorXin Long <lucien.xin@gmail.com>
Wed, 6 Nov 2019 09:01:03 +0000 (17:01 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 Nov 2019 05:14:21 +0000 (21:14 -0800)
Without options copied to the dst tun_info in iptunnel_metadata_reply()
called by arp_process for handling arp_request, the generated arp_reply
packet may be dropped or sent out with wrong options for some tunnels
like erspan and vxlan, and the traffic will break.

Fixes: 63d008a4e9ee ("ipv4: send arp replies to the correct tunnel")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_tunnel_core.c

index 1452a97914a0d7e81e558d1137a45878e01a89af..10f08481b00399a116ec8b9c7b3a786a99e2c11b 100644 (file)
@@ -126,15 +126,14 @@ struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,
 
        if (!md || md->type != METADATA_IP_TUNNEL ||
            md->u.tun_info.mode & IP_TUNNEL_INFO_TX)
-
                return NULL;
 
-       res = metadata_dst_alloc(0, METADATA_IP_TUNNEL, flags);
+       src = &md->u.tun_info;
+       res = metadata_dst_alloc(src->options_len, METADATA_IP_TUNNEL, flags);
        if (!res)
                return NULL;
 
        dst = &res->u.tun_info;
-       src = &md->u.tun_info;
        dst->key.tun_id = src->key.tun_id;
        if (src->mode & IP_TUNNEL_INFO_IPV6)
                memcpy(&dst->key.u.ipv6.dst, &src->key.u.ipv6.src,
@@ -143,6 +142,8 @@ struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,
                dst->key.u.ipv4.dst = src->key.u.ipv4.src;
        dst->key.tun_flags = src->key.tun_flags;
        dst->mode = src->mode | IP_TUNNEL_INFO_TX;
+       ip_tunnel_info_opts_set(dst, ip_tunnel_info_opts(src),
+                               src->options_len, 0);
 
        return res;
 }