diff options
author | 2018-08-31 16:52:01 +0800 | |
---|---|---|
committer | 2018-09-03 19:04:12 -0700 | |
commit | 36feaac35405e932ad9c321d7a2db8a7e4a4d7ca (patch) | |
tree | d42564578858e46effaef8f971580d6ed54182c3 /net/ipv6/ip6_tunnel.c | |
parent | uapi: Fix linux/rds.h userspace compilation errors. (diff) | |
download | linux-36feaac35405e932ad9c321d7a2db8a7e4a4d7ca.tar.gz linux-36feaac35405e932ad9c321d7a2db8a7e4a4d7ca.tar.bz2 linux-36feaac35405e932ad9c321d7a2db8a7e4a4d7ca.zip |
ip6_tunnel: respect ttl inherit for ip6tnl
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_tunnel.c')
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 5df2a58d945c..419960b0ba16 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1188,7 +1188,15 @@ route_lookup: 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. |