Skip to content

Commit 36feaac

Browse files
liuhangbindavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 59a03fe commit 36feaac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/ipv6/ip6_tunnel.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,15 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
11881188
init_tel_txopt(&opt, encap_limit);
11891189
ipv6_push_frag_opts(skb, &opt.ops, &proto);
11901190
}
1191-
hop_limit = hop_limit ? : ip6_dst_hoplimit(dst);
1191+
1192+
if (hop_limit == 0) {
1193+
if (skb->protocol == htons(ETH_P_IP))
1194+
hop_limit = ip_hdr(skb)->ttl;
1195+
else if (skb->protocol == htons(ETH_P_IPV6))
1196+
hop_limit = ipv6_hdr(skb)->hop_limit;
1197+
else
1198+
hop_limit = ip6_dst_hoplimit(dst);
1199+
}
11921200

11931201
/* Calculate max headroom for all the headers and adjust
11941202
* needed_headroom if necessary.

0 commit comments

Comments
 (0)