diff options
author | wenxu <wenxu@ucloud.cn> | 2019-01-19 00:11:25 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-01-24 20:54:12 -0500 |
commit | d71b57532d70c03f4671dd04e84157ac6bf021b0 (patch) | |
tree | ada00d0ab5a5a040df915f8786d520d07cec01f1 | |
parent | 63530aba7826a0f8e129874df9c4d264f9db3f9e (diff) |
ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel
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>
-rw-r--r-- | net/ipv4/ip_tunnel.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index c4f5602308ed..054d01c16dc6 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c | |||
@@ -644,13 +644,19 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, | |||
644 | dst = tnl_params->daddr; | 644 | dst = tnl_params->daddr; |
645 | if (dst == 0) { | 645 | if (dst == 0) { |
646 | /* NBMA tunnel */ | 646 | /* NBMA tunnel */ |
647 | struct ip_tunnel_info *tun_info; | ||
647 | 648 | ||
648 | if (!skb_dst(skb)) { | 649 | if (!skb_dst(skb)) { |
649 | dev->stats.tx_fifo_errors++; | 650 | dev->stats.tx_fifo_errors++; |
650 | goto tx_error; | 651 | goto tx_error; |
651 | } | 652 | } |
652 | 653 | ||
653 | if (skb->protocol == htons(ETH_P_IP)) { | 654 | tun_info = skb_tunnel_info(skb); |
655 | if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX) && | ||
656 | ip_tunnel_info_af(tun_info) == AF_INET && | ||
657 | tun_info->key.u.ipv4.dst) | ||
658 | dst = tun_info->key.u.ipv4.dst; | ||
659 | else if (skb->protocol == htons(ETH_P_IP)) { | ||
654 | rt = skb_rtable(skb); | 660 | rt = skb_rtable(skb); |
655 | dst = rt_nexthop(rt, inner_iph->daddr); | 661 | dst = rt_nexthop(rt, inner_iph->daddr); |
656 | } | 662 | } |