diff mbox series

seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation

Message ID 1736995236-23063-1-git-send-email-liyonglong@chinatelecom.cn (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: pabeni@redhat.com horms@kernel.org
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest pending net-next-2025-01-16--06-01 (tests: 0)

Commit Message

Yonglong Li Jan. 16, 2025, 2:40 a.m. UTC
inherit inner IPv4 TTL on ip4ip6 SHR encapsulation like as inherit 
inner hop_limit on ip6ip6 SHR encapsulation

Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn>
---
 net/ipv6/seg6_iptunnel.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 098632a..2f1f9cf 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -160,7 +160,10 @@  int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto)
 		hdr->hop_limit = inner_hdr->hop_limit;
 	} else {
 		ip6_flow_hdr(hdr, 0, flowlabel);
-		hdr->hop_limit = ip6_dst_hoplimit(skb_dst(skb));
+		if (skb->protocol == htons(ETH_P_IP))
+			hdr->hop_limit = ((struct iphdr *)inner_hdr)->ttl;
+		else
+			hdr->hop_limit = ip6_dst_hoplimit(skb_dst(skb));
 
 		memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
 
@@ -249,7 +252,10 @@  static int seg6_do_srh_encap_red(struct sk_buff *skb,
 		hdr->hop_limit = inner_hdr->hop_limit;
 	} else {
 		ip6_flow_hdr(hdr, 0, flowlabel);
-		hdr->hop_limit = ip6_dst_hoplimit(skb_dst(skb));
+		if (skb->protocol == htons(ETH_P_IP))
+			hdr->hop_limit = ((struct iphdr *)inner_hdr)->ttl;
+		else
+			hdr->hop_limit = ip6_dst_hoplimit(skb_dst(skb));
 
 		memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
 		IP6CB(skb)->iif = skb->skb_iif;