* [PATCH iproute2] seg6local: accept lblen and nflen in either order
@ 2026-11-24 22:52 Dave Seddon
0 siblings, 0 replies; only message in thread
From: Dave Seddon @ 2026-11-24 22:52 UTC (permalink / raw)
To: netdev
Cc: Dave Seddon, Stephen Hemminger, David Ahern, Paolo Lungaroni,
Frank Dressler
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 22:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 22:52 [PATCH iproute2] seg6local: accept lblen and nflen in either order Dave Seddon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox