🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Dave Seddon Tue, 24 Nov 2026 22:52
[PATCH iproute2] seg6local: accept lblen and nflen in either order
#22163
Author: Dave Seddon
Date: Tue, 24 Nov 2026 22:52
77 lines
13027 bytes
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
Re: [PATCH iproute2] seg6local: accept lblen and nflen in either order
#23386
Author: Hangbin Liu
Date: Fri, 27 Nov 2026 07:13
91 lines
11103 bytes
Hi Dave,
On Tue, Nov 24, 2026 at 02:52:27PM -0800, Dave Seddon wrote:
> 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

There is no need to add Assisted-by tag now.

> 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.

Stephen may handle the order.

Generally, if a patch depends on another patch that hasn’t been applied yet,
we should post them together as a new series.

Thanks
Hangbin
> 
>  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
> 
Re: [PATCH iproute2] seg6local: accept lblen and nflen in either order
#25451
Author: patchwork-bot+netdevbpf
Date: Tue, 01 Dec 2026 19:50
24 lines
8553 bytes
Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Tue, 24 Nov 2026 14:52:27 -0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [iproute2] seg6local: accept lblen and nflen in either order
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=e7a9ce923a2d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads