netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation
@ 2025-01-16  2:40 Yonglong Li
  2025-01-20 22:51 ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: Yonglong Li @ 2025-01-16  2:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, davem, dsahern, edumazet, kuba, liyonglong

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 --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;
-- 
1.8.3.1


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

* Re: [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation
  2025-01-16  2:40 [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation Yonglong Li
@ 2025-01-20 22:51 ` Jakub Kicinski
       [not found]   ` <CAAvhMUmdse_8GJtn_dD0psRmSA_BCy-fv6eYj9CorpaeVm-H3g@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-01-20 22:51 UTC (permalink / raw)
  To: Yonglong Li; +Cc: linux-kernel, netdev, davem, dsahern, edumazet

On Thu, 16 Jan 2025 10:40:36 +0800 Yonglong Li wrote:
> inherit inner IPv4 TTL on ip4ip6 SHR encapsulation like as inherit 
> inner hop_limit on ip6ip6 SHR encapsulation

Could you add some references to RFCs which recommend this behavior 
to the commit message?
-- 
pw-bot: cr

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

* Re: [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation
       [not found]   ` <CAAvhMUmdse_8GJtn_dD0psRmSA_BCy-fv6eYj9CorpaeVm-H3g@mail.gmail.com>
@ 2025-01-22 16:13     ` David Ahern
  2025-01-23 15:48     ` Jakub Kicinski
  1 sibling, 0 replies; 5+ messages in thread
From: David Ahern @ 2025-01-22 16:13 UTC (permalink / raw)
  To: Ahmed Abdelsalam, Jakub Kicinski
  Cc: Yonglong Li, linux-kernel, netdev, davem, edumazet

On 1/22/25 3:20 AM, Ahmed Abdelsalam wrote:
> Copying hop limit from inner packet can be added via a new sysctl.
> Where the default is to use the node default hop limit, But you can set
> the sysctl value to enable copying from inner packet. 
> 

not a sysctl. vxlan, geneve, mpls have netlink attributes that allow the
TTL to be inherited or propagated. I think that model should apply to seg6.

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

* Re: [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation
       [not found]   ` <CAAvhMUmdse_8GJtn_dD0psRmSA_BCy-fv6eYj9CorpaeVm-H3g@mail.gmail.com>
  2025-01-22 16:13     ` David Ahern
@ 2025-01-23 15:48     ` Jakub Kicinski
  2025-02-05  7:25       ` YonglongLi
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-01-23 15:48 UTC (permalink / raw)
  To: Ahmed Abdelsalam
  Cc: Yonglong Li, linux-kernel, netdev, davem, dsahern, edumazet

On Wed, 22 Jan 2025 11:20:05 +0100 Ahmed Abdelsalam wrote:
> This patch is not RFC complaint. Section 6.3 of RFC 2473 (Generic Packet
> Tunneling in IPv6 Specification) discussed IPv6 Tunnel Hop Limit.
> The hop limit field of the tunnel IPv6 header of each packet encapsulated
> is set to the hop limit default value of the tunnel entry-point ode.
> The SRv6 RFC (RFC 8986) inherits the tunnel behavior from RFC2473l

I see. I think this information would be good to have in the commit
message. IIRC we do inherit already in other tunnel implementations, 
ideally we should elaborate on precedents in Linux behavior in the
commit message, too.

reminder: please don't top post on the list

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

* Re: [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation
  2025-01-23 15:48     ` Jakub Kicinski
@ 2025-02-05  7:25       ` YonglongLi
  0 siblings, 0 replies; 5+ messages in thread
From: YonglongLi @ 2025-02-05  7:25 UTC (permalink / raw)
  To: Jakub Kicinski, Ahmed Abdelsalam
  Cc: netdev, davem, dsahern, edumazet, liyonglong



On 1/23/2025 23:48, 【外部账号】 Jakub Kicinski wrote:
> On Wed, 22 Jan 2025 11:20:05 +0100 Ahmed Abdelsalam wrote:
>> This patch is not RFC complaint. Section 6.3 of RFC 2473 (Generic Packet
>> Tunneling in IPv6 Specification) discussed IPv6 Tunnel Hop Limit.
>> The hop limit field of the tunnel IPv6 header of each packet encapsulated
>> is set to the hop limit default value of the tunnel entry-point ode.
>> The SRv6 RFC (RFC 8986) inherits the tunnel behavior from RFC2473l
> 
> I see. I think this information would be good to have in the commit
> message. IIRC we do inherit already in other tunnel implementations, 
> ideally we should elaborate on precedents in Linux behavior in the
> commit message, too.
> 
> reminder: please don't top post on the list
> 

Sorry for the late relay. And thanks for your review.

Is it ok that copying inner hop limit(TTL) on SRv6 encapsulation just
like what ip/ip6 tunnel does in Linux implementation?
if it is ok, I will send v2 which will add more detailed commit message.

-- 
Li YongLong

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

end of thread, other threads:[~2025-02-05  7:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16  2:40 [PATCH] seg6: inherit inner IPv4 TTL on ip4ip6 encapsulation Yonglong Li
2025-01-20 22:51 ` Jakub Kicinski
     [not found]   ` <CAAvhMUmdse_8GJtn_dD0psRmSA_BCy-fv6eYj9CorpaeVm-H3g@mail.gmail.com>
2025-01-22 16:13     ` David Ahern
2025-01-23 15:48     ` Jakub Kicinski
2025-02-05  7:25       ` YonglongLi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).