All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel
@ 2019-01-15  2:44 wenxu
  2019-01-18  0:10 ` wenxu
  2019-01-18 19:06 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: wenxu @ 2019-01-15  2:44 UTC (permalink / raw)
  To: netdev

From: wenxu <wenxu@ucloud.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@ucloud.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..d87f92e 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel
  2019-01-15  2:44 [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel wenxu
@ 2019-01-18  0:10 ` wenxu
  2019-01-18  4:00   ` David Miller
  2019-01-18 19:06 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: wenxu @ 2019-01-18  0:10 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Hi David,

what about the status of this patch?

BR
wenxu
On 2019/1/15 上午10:44, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.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@ucloud.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..d87f92e 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);
>  }
>  



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel
  2019-01-18  0:10 ` wenxu
@ 2019-01-18  4:00   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-01-18  4:00 UTC (permalink / raw)
  To: wenxu; +Cc: netdev

From: wenxu <wenxu@ucloud.cn>
Date: Fri, 18 Jan 2019 08:10:55 +0800

> what about the status of this patch?

Why don't you look in patchwork and see for yourself?

https://patchwork.ozlabs.org/patch/1024965/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel
  2019-01-15  2:44 [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel wenxu
  2019-01-18  0:10 ` wenxu
@ 2019-01-18 19:06 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-01-18 19:06 UTC (permalink / raw)
  To: wenxu; +Cc: netdev

From: wenxu@ucloud.cn
Date: Tue, 15 Jan 2019 10:44:35 +0800

> +		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));

It is not at all reasonable to build and memcpy an entire extra iphdr
on the cpu stack, for every packet transmit.  That's terrible for
performance.

Please find a more minimal and efficient way to achieve the behavior
you are looking for.

Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-18 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15  2:44 [PATCH net-next] ip_gre: Make none-tunnel-dst gre port work with lwtunnel wenxu
2019-01-18  0:10 ` wenxu
2019-01-18  4:00   ` David Miller
2019-01-18 19:06 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.