All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ip6_tunnel: respect ttl inherit for ip6tnl
@ 2018-08-31  8:52 Hangbin Liu
  2018-09-04  2:04 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Hangbin Liu @ 2018-08-31  8:52 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Hangbin Liu

man ip-tunnel ttl section says:
0 is a special value meaning that packets inherit the TTL value.

IPv4 tunnel respect this in ip_tunnel_xmit(), but IPv6 tunnel has not
implement it yet. To make IPv6 behave consistently with IP tunnel,
add ipv6 tunnel inherit support.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/ip6_tunnel.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 5df2a58..419960b 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1188,7 +1188,15 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
 		init_tel_txopt(&opt, encap_limit);
 		ipv6_push_frag_opts(skb, &opt.ops, &proto);
 	}
-	hop_limit = hop_limit ? : ip6_dst_hoplimit(dst);
+
+	if (hop_limit == 0) {
+		if (skb->protocol == htons(ETH_P_IP))
+			hop_limit = ip_hdr(skb)->ttl;
+		else if (skb->protocol == htons(ETH_P_IPV6))
+			hop_limit = ipv6_hdr(skb)->hop_limit;
+		else
+			hop_limit = ip6_dst_hoplimit(dst);
+	}
 
 	/* Calculate max headroom for all the headers and adjust
 	 * needed_headroom if necessary.
-- 
2.5.5

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

* Re: [PATCH net] ip6_tunnel: respect ttl inherit for ip6tnl
  2018-08-31  8:52 [PATCH net] ip6_tunnel: respect ttl inherit for ip6tnl Hangbin Liu
@ 2018-09-04  2:04 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-09-04  2:04 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Fri, 31 Aug 2018 16:52:01 +0800

> man ip-tunnel ttl section says:
> 0 is a special value meaning that packets inherit the TTL value.
> 
> IPv4 tunnel respect this in ip_tunnel_xmit(), but IPv6 tunnel has not
> implement it yet. To make IPv6 behave consistently with IP tunnel,
> add ipv6 tunnel inherit support.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied, thank you.

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

end of thread, other threads:[~2018-09-04  6:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31  8:52 [PATCH net] ip6_tunnel: respect ttl inherit for ip6tnl Hangbin Liu
2018-09-04  2:04 ` 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.