public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Mathis Marion <Mathis.Marion@silabs•com>
To: "David S. Miller" <davem@davemloft•net>,
	David Ahern <dsahern@kernel•org>,
	Eric Dumazet <edumazet@google•com>,
	Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>
Cc: netdev@vger•kernel.org, linux-kernel@vger•kernel.org,
	"Jérôme Pouiller" <jerome.pouiller@silabs•com>,
	"Kylian Balan" <kylian.balan@silabs•com>,
	"Alexander Aring" <alex.aring@gmail•com>,
	"Mathis Marion" <mathis.marion@silabs•com>
Subject: [PATCH v1 2/2] ipv6: always accept routing headers with 0 segments left
Date: Mon, 24 Jun 2024 16:15:33 +0200	[thread overview]
Message-ID: <20240624141602.206398-3-Mathis.Marion@silabs.com> (raw)
In-Reply-To: <20240624141602.206398-1-Mathis.Marion@silabs.com>

From: Mathis Marion <mathis.marion@silabs•com>

Routing headers of type 3 and 4 would be rejected even if segments left
was 0, in the case that they were disabled through system configuration.

RFC 8200 section 4.4 specifies:

      If Segments Left is zero, the node must ignore the Routing header
      and proceed to process the next header in the packet, whose type
      is identified by the Next Header field in the Routing header.

Signed-off-by: Mathis Marion <mathis.marion@silabs•com>
---
 net/ipv6/exthdrs.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 083dbbafb166..913160b0fe13 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -662,17 +662,6 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
 		return -1;
 	}
 
-	switch (hdr->type) {
-	case IPV6_SRCRT_TYPE_4:
-		/* segment routing */
-		return ipv6_srh_rcv(skb);
-	case IPV6_SRCRT_TYPE_3:
-		/* rpl segment routing */
-		return ipv6_rpl_srh_rcv(skb);
-	default:
-		break;
-	}
-
 looped_back:
 	if (hdr->segments_left == 0) {
 		switch (hdr->type) {
@@ -708,6 +697,12 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
 		}
 		break;
 #endif
+	case IPV6_SRCRT_TYPE_3:
+		/* rpl segment routing */
+		return ipv6_rpl_srh_rcv(skb);
+	case IPV6_SRCRT_TYPE_4:
+		/* segment routing */
+		return ipv6_srh_rcv(skb);
 	default:
 		goto unknown_rh;
 	}
-- 
2.43.0


  parent reply	other threads:[~2024-06-24 14:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 14:15 [PATCH v1 0/2] ipv6: always accept routing headers with 0 segments left Mathis Marion
2024-06-24 14:15 ` [PATCH v1 1/2] ipv6: introduce ipv6_rthdr_rcv_last() Mathis Marion
2024-06-24 14:15 ` Mathis Marion [this message]
2024-06-25 21:38   ` [PATCH v1 2/2] ipv6: always accept routing headers with 0 segments left Kuniyuki Iwashima
2024-06-26  1:45     ` Alexander Aring
2024-06-26 10:10       ` Mathis Marion
2024-06-26 13:48         ` Alexander Aring
2024-07-16 21:27         ` Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240624141602.206398-3-Mathis.Marion@silabs.com \
    --to=mathis.marion@silabs$(echo .)com \
    --cc=alex.aring@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=dsahern@kernel$(echo .)org \
    --cc=edumazet@google$(echo .)com \
    --cc=jerome.pouiller@silabs$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=kylian.balan@silabs$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox