Skip to content

Commit

Permalink
ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wenxu authored and David S. Miller committed Jan 25, 2019
1 parent 63530ab commit d71b575
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion net/ipv4/ip_tunnel.c
Original file line number Diff line number Diff line change
@@ -644,13 +644,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);
}

0 comments on commit d71b575

Please sign in to comment.