]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel
authorwenxu <wenxu@ucloud.cn>
Sat, 19 Jan 2019 05:11:25 +0000 (13:11 +0800)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:21:40 +0000 (14:21 -0300)
BugLink: https://bugs.launchpad.net/bugs/1855787
[ Upstream commit d71b57532d70c03f4671dd04e84157ac6bf021b0 ]

ip l add dev tun type gretap key 1000
ip a a dev tun 10.0.0.1/24

Packets with tun-id 1000 can be recived by tun dev. But packet can't
be sent through dev tun for non-tunnel-dst

With this patch: tunnel-dst can be get through lwtunnel like beflow:
ip r a 10.0.0.7 encap ip dst 172.168.0.11 dev tun

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
net/ipv4/ip_tunnel.c

index 52814f3ffb01a58ea5a1c96cf95266b79455a91c..7150d9cba4a0336e6f6460e8cc1cde6d522b85ec 100644 (file)
@@ -652,13 +652,19 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
        dst = tnl_params->daddr;
        if (dst == 0) {
                /* NBMA tunnel */
+               struct ip_tunnel_info *tun_info;
 
                if (!skb_dst(skb)) {
                        dev->stats.tx_fifo_errors++;
                        goto tx_error;
                }
 
-               if (skb->protocol == htons(ETH_P_IP)) {
+               tun_info = skb_tunnel_info(skb);
+               if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX) &&
+                   ip_tunnel_info_af(tun_info) == AF_INET &&
+                   tun_info->key.u.ipv4.dst)
+                       dst = tun_info->key.u.ipv4.dst;
+               else if (skb->protocol == htons(ETH_P_IP)) {
                        rt = skb_rtable(skb);
                        dst = rt_nexthop(rt, inner_iph->daddr);
                }