All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Seddon <dave.seddon.ca@gmail.com>
To: netdev@vger.kernel.org
Cc: Dave Seddon <dave.seddon.ca@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	David Ahern <dsahern@kernel.org>,
	Paolo Lungaroni <paolo.lungaroni@uniroma2.it>,
	Frank Dressler <frank@dressler.pro>
Subject: [PATCH iproute2] seg6local: accept lblen and nflen in either order
Date: Tue, 24 Nov 2026 14:52:27 -0800	[thread overview]
Message-ID: <20261124225227.3795875-1-dave.seddon.ca@gmail.com> (raw)

The man page lists lblen and nflen as flavors attributes in no fixed
order, but ip only accepts lblen first:

  ip -6 route add 2001:db8:2::/64 dev lo encap seg6local action End \
    flavors next-csid nflen 16 lblen 32
  Error: either "to" is duplicate, or "lblen" is garbage.

Parse them in a loop.

Fixes: 04a6b456bf74 ("seg6: add support for flavors in SRv6 End* behaviors")
Suggested-by: Frank Dressler <frank@dressler.pro>
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
This applies on top of "seg6local: fix crash when next-csid ends the
command", as discussed in that thread.

 ip/iproute_lwtunnel.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 53004b5f..3a6bf7c0 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -1433,27 +1433,30 @@ static int seg6local_parse_flavors(struct rtattr *rta, size_t len,
 		return ret;
 
 	if (flavors & (1 << SEG6_LOCAL_FLV_OP_NEXT_CSID)) {
-		NEXT_ARG_FWD();
-		if (argc > 0 && strcmp(*argv, "lblen") == 0) {
-			NEXT_ARG();
-			if (lbl_ok++)
-				duparg2("lblen", *argv);
-			if (get_u8(&lbl, *argv, 0))
-				invarg("\"locator-block length\" value is invalid\n", *argv);
-			ret = rta_addattr8(rta, len, SEG6_LOCAL_FLV_LCBLOCK_BITS, lbl);
-			NEXT_ARG_FWD();
-		}
-
-		if (argc > 0 && strcmp(*argv, "nflen") == 0) {
-			NEXT_ARG();
-			if (nfl_ok++)
-				duparg2("nflen", *argv);
-			if (get_u8(&nfl, *argv, 0))
-				invarg("\"locator-node function length\" value is invalid\n", *argv);
-			ret = rta_addattr8(rta, len, SEG6_LOCAL_FLV_LCNODE_FN_BITS, nfl);
+		while (NEXT_ARG_OK()) {
 			NEXT_ARG_FWD();
+			if (strcmp(*argv, "lblen") == 0) {
+				NEXT_ARG();
+				if (lbl_ok++)
+					duparg2("lblen", *argv);
+				if (get_u8(&lbl, *argv, 0))
+					invarg("\"locator-block length\" value is invalid\n",
+					       *argv);
+				ret = rta_addattr8(rta, len, SEG6_LOCAL_FLV_LCBLOCK_BITS, lbl);
+			} else if (strcmp(*argv, "nflen") == 0) {
+				NEXT_ARG();
+				if (nfl_ok++)
+					duparg2("nflen", *argv);
+				if (get_u8(&nfl, *argv, 0))
+					invarg("\"locator-node function length\" value is invalid\n",
+					       *argv);
+				ret = rta_addattr8(rta, len,
+						   SEG6_LOCAL_FLV_LCNODE_FN_BITS, nfl);
+			} else {
+				PREV_ARG();
+				break;
+			}
 		}
-		PREV_ARG();
 	}
 
 	rta_nest_end(rta, nest);
-- 
2.56.0


             reply	other threads:[~2026-11-24 22:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 22:52 Dave Seddon [this message]
2026-11-27  7:13 ` [PATCH iproute2] seg6local: accept lblen and nflen in either order Hangbin Liu
2026-12-01 19:50 ` patchwork-bot+netdevbpf

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=20261124225227.3795875-1-dave.seddon.ca@gmail.com \
    --to=dave.seddon.ca@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=frank@dressler.pro \
    --cc=netdev@vger.kernel.org \
    --cc=paolo.lungaroni@uniroma2.it \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.