[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1545903065-18580-1-git-send-email-wenxu@ucloud.cn>
Date: Thu, 27 Dec 2018 17:31:05 +0800
From: wenxu@...oud.cn
To: netdev@...r.kernel.org
Subject: [PATCH net-next] ip_gre: Support lwtunnel for none-tunnel-dst gre port
From: wenxu <wenxu@...oud.cn>
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 id 1000 dst 172.168.0.11 key dev tun
Signed-off-by: wenxu <wenxu@...oud.cn>
---
net/ipv4/ip_gre.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index c7a7bd5..69c2a1d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -450,6 +450,24 @@ static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
tunnel->parms.o_flags, proto, tunnel->parms.o_key,
htonl(tunnel->o_seqno));
+ if (!tnl_params->daddr) {
+ struct ip_tunnel_info *tun_info;
+
+ 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) {
+ struct iphdr tnl_params_info;
+
+ memcpy(&tnl_params_info, tnl_params,
+ sizeof(tnl_params_info));
+ tnl_params_info.daddr = tun_info->key.u.ipv4.dst;
+
+ return ip_tunnel_xmit(skb, dev, &tnl_params_info,
+ tnl_params_info.protocol);
+ }
+ }
+
ip_tunnel_xmit(skb, dev, tnl_params, tnl_params->protocol);
}
--
1.8.3.1
Powered by blists - more mailing lists