mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route
@ 2026-09-20 10:06 Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 1/6] net: lwtunnel: change encap fill order Hangbin Liu
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

This series adds YNL sub-message support for lwtunnel encap data in
the rt-route netlink family, and describes the tunnel-specific
attribute sets that were previously opaque binary blobs.

The kernel currently emits encap_type after the encap payload nest,
but YNL sub-message parsing needs the selector (encap_type) first to
dispatch on the correct attribute set. Patch 1 reorders the kernel
output, and patch 2 teaches the YNL C code generator to convert enum
selectors to their string form for sub-message dispatch.

Patches 3-6 extend the rt-route YAML spec.

Tested with ynl selftest and checked with following cmds

 # modprobe ila
 # modprobe xfrm_interface
 # ip addr add 10.1.0.1/24 dev lo
 # ip route add 10.1.0.0/24 dev lo encap mpls 100 via 10.1.0.254
 # ip route add 10.2.0.0/24 dev lo encap ip id 1 dst 127.0.0.1 src 127.0.0.1
 # ip route add 2001:db8:3::/64 dev lo encap ila 1:2:3:4 csum-mode no-action ident-type luid hook-type output
 # ip route add 2001:db8:4::/64 dev lo encap ip6 id 1 dst 2001:db8::5 src 2001:db8::1 hoplimit 64
 # ip route add 2001:db8:5::/64 dev lo encap seg6 mode inline segs 2001:db8::1
 # ip route add 2001:db8:6::/65 dev lo encap seg6local action End
 # ip route add 2001:db8:7::/65 dev lo encap bpf in ob /tmp/kself/net/lib/xdp_dummy.bpf.o sec xdp
 # ip route add 2001:db8:8::/64 dev lo encap rpl segs 2001:db8::1
 # ip route add 2001:db8:9::/64 encap ioam6 trace prealloc type 0x800000 ns 0 size 4 dev lo
 # ip route add 2001:db8:10::/64 dev lo encap xfrm if_id 100
 # ip route show
 10.1.0.0/24  encap mpls  100 via 10.1.0.254 dev lo
 10.2.0.0/24  encap ip id 1 src 127.0.0.1 dst 127.0.0.1 ttl 0 tos 0 dev lo scope link
 # ip -6 route show
 2001:db8:3::/64  encap ila  1:2:3:4  csum-mode no-action  ident-type luid  hook-type output dev lo metric 1024 pref medium
 2001:db8:4::/64  encap ip6 id 1 src 2001:db8::1 dst 2001:db8::5 hoplimit 64 tc 0 dev lo metric 1024 pref medium
 2001:db8:5::/64  encap seg6 mode inline segs 2 [ 2001:db8::1 :: ] dev lo metric 1024 pref medium
 2001:db8:6::/65  encap seg6local action End dev lo metric 1024 pref medium
 2001:db8:7::/65  encap bpf in xdp_dummy.bpf.o:[xdp] dev lo metric 1024 pref medium
 2001:db8:8::/64  encap rpl segs 1 [ 2001:db8::1 ] dev lo metric 1024 pref medium
 2001:db8:9::/64  encap ioam6 freq 1/1 mode inline trace prealloc type 0x800000 ns 0 size 4 dev lo metric 1024 pref medium
 2001:db8:10::/64  encap xfrm if_id 100 dev lo metric 1024 pref medium
 # ./tools/net/ynl/pyynl/cli.py --family rt-route --dump getroute > /tmp/route_dump.json

All the result looks good.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
Changes in v2:
- Patch 1: Check ops->fill_encap before setting encap_type_attr
- Patch 2: Get string in generated sub-message parser and check it before reference
- Patch 3-4: set byte-orders and max-len
- Patch 5: include lwtunnel.h
- Link to v1: https://lore.kernel.org/r/20260917-ynl_rt_encap-v1-0-fbbe6e680571@kylinos.cn

---
Hangbin Liu (6):
      net: lwtunnel: change encap fill order
      tools: ynl: convert enum selector to string for sub-message parsing
      netlink: specs: rt-route: add lwtunnel encap sub-message support
      netlink: specs: rt-route: describe lwtunnel IP options
      netlink: specs: rt-route: describe lwt BPF program options
      netlink: specs: rt-route: describe seg6-local actions, counters and flavors

 Documentation/netlink/specs/rt-route.yaml | 413 +++++++++++++++++++++++++++++-
 net/core/lwtunnel.c                       |  35 +--
 tools/net/ynl/Makefile.deps               |   9 +-
 tools/net/ynl/pyynl/ynl_gen_c.py          |  20 +-
 4 files changed, 454 insertions(+), 23 deletions(-)
---
base-commit: 8830e65ed46de41f849eefb8ba227d4852c460f6
change-id: 20260908-ynl_rt_encap-3140103b368a

Best regards,
-- 
Hangbin Liu <liuhangbin@kylinos.cn>


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

* [PATCH net-next v2 1/6] net: lwtunnel: change encap fill order
  2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
@ 2026-09-20 10:06 ` Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 2/6] tools: ynl: convert enum selector to string for sub-message parsing Hangbin Liu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

When decoding sub‑messages, YNL tries to fetch the "selector" (encap‑type)
first. However, lwtunnel fills encap‑payload data first, which causes YNL
to fail decoding the lwtunnel encap message.

Fixing this inside YNL would be complex, so change the order in the kernel
and emit encap_type first.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 net/core/lwtunnel.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
index b01a395d9a96..8223c44f10c8 100644
--- a/net/core/lwtunnel.c
+++ b/net/core/lwtunnel.c
@@ -231,7 +231,7 @@ int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate,
 {
 	const struct lwtunnel_encap_ops *ops;
 	struct nlattr *nest;
-	int ret;
+	int ret = 0;
 
 	if (!lwtstate)
 		return 0;
@@ -240,30 +240,31 @@ int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate,
 	    lwtstate->type > LWTUNNEL_ENCAP_MAX)
 		return 0;
 
-	nest = nla_nest_start_noflag(skb, encap_attr);
-	if (!nest)
-		return -EMSGSIZE;
-
-	ret = -EOPNOTSUPP;
 	rcu_read_lock();
+
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
-	if (likely(ops && ops->fill_encap))
-		ret = ops->fill_encap(skb, lwtstate);
-	rcu_read_unlock();
+	if (unlikely(!ops || !ops->fill_encap))
+		goto unlock_out;
 
-	if (ret)
-		goto nla_put_failure;
-	nla_nest_end(skb, nest);
 	ret = nla_put_u16(skb, encap_type_attr, lwtstate->type);
 	if (ret)
-		goto nla_put_failure;
+		goto unlock_out;
 
-	return 0;
+	nest = nla_nest_start_noflag(skb, encap_attr);
+	if (!nest) {
+		ret = -EMSGSIZE;
+		goto unlock_out;
+	}
 
-nla_put_failure:
-	nla_nest_cancel(skb, nest);
+	ret = ops->fill_encap(skb, lwtstate);
+	if (ret)
+		nla_nest_cancel(skb, nest);
+	else
+		nla_nest_end(skb, nest);
 
-	return (ret == -EOPNOTSUPP ? 0 : ret);
+unlock_out:
+	rcu_read_unlock();
+	return ret;
 }
 EXPORT_SYMBOL_GPL(lwtunnel_fill_encap);
 

-- 
2.55.0


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

* [PATCH net-next v2 2/6] tools: ynl: convert enum selector to string for sub-message parsing
  2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 1/6] net: lwtunnel: change encap fill order Hangbin Liu
@ 2026-09-20 10:06 ` Hangbin Liu
  2026-09-24  1:14   ` Jakub Kicinski
  2026-09-20 10:06 ` [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support Hangbin Liu
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

YNL sub-message parsing expects a string selector for strcmp(). So for
non-external enum selectors, convert the integer value to its string form
via the family's {enum}_str() helper. This enables correct decoding of
sub-messages keyed by enum values.

After change, the new generated code looks like

	const char *encap_type_str;
	encap_type_str = rt_route_encap_type_str(dst->encap_type);
	if (!encap_type_str)
		return ynl_submsg_failed(yarg, "encap", "encap-type");
	if (rt_route_encap_data_parse(&parg, encap_type_str, attr))
		return YNL_PARSE_CB_ERROR;

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 tools/net/ynl/pyynl/ynl_gen_c.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 2b3483db1b60..785e747e5865 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -951,10 +951,22 @@ class TypeSubMessage(TypeNest):
             sel_var = f"_sel_{sel}"
         else:
             sel_var = f"{var}->{sel}"
-        get_lines = [f'if (!{sel_var})',
-                     f'return ynl_submsg_failed(yarg, "{self.name}", "{selector}");',
-                     f"if ({self.nested_render_name}_parse(&parg, {sel_var}, attr))",
-                     "return YNL_PARSE_CB_ERROR;"]
+
+        parse_sel = sel_var
+        get_lines = []
+        if not self.selector.is_external() and self.selector.attr and \
+           "enum" in self.selector.attr.attr:
+            enum_name = self.selector.attr.attr["enum"]
+            str_fn = c_lower(self.family.ident_name + "-" + enum_name) + "_str"
+            sel_str_var = f"{sel}_str"
+            get_lines += [f'const char *{sel_str_var};',
+                          f'{sel_str_var} = {str_fn}({sel_var});']
+            parse_sel = sel_str_var
+
+        get_lines += [f'if (!{parse_sel})',
+                      f'return ynl_submsg_failed(yarg, "{self.name}", "{selector}");',
+                      f"if ({self.nested_render_name}_parse(&parg, {parse_sel}, attr))",
+                      "return YNL_PARSE_CB_ERROR;"]
         init_lines = [f"parg.rsp_policy = &{self.nested_render_name}_nest;",
                       f"parg.data = &{var}->{self.c_name};"]
         return get_lines, init_lines, None

-- 
2.55.0


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

* [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support
  2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 1/6] net: lwtunnel: change encap fill order Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 2/6] tools: ynl: convert enum selector to string for sub-message parsing Hangbin Liu
@ 2026-09-20 10:06 ` Hangbin Liu
  2026-09-24  1:14   ` Jakub Kicinski
  2026-09-20 10:06 ` [PATCH net-next v2 4/6] netlink: specs: rt-route: describe lwtunnel IP options Hangbin Liu
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

Define encap-type enum (LWTUNNEL_ENCAP_*) and add encap-data sub-message
keyed by encap-type. Add tunnel attribute sets (mpls, ila, seg6, rpl,
ioam6, xfrm) and IP/IP6 tunnel sets.

Keep some nested option attributes as binary in this patch to simplify
review; they will be converted in follow-up patches.

Also add the Makefile to include uapi headers. Note the lwtunnel.h
is guarded by _UAPI_LWTUNNEL_H_.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 Documentation/netlink/specs/rt-route.yaml | 285 +++++++++++++++++++++++++++++-
 tools/net/ynl/Makefile.deps               |   9 +-
 2 files changed, 292 insertions(+), 2 deletions(-)

diff --git a/Documentation/netlink/specs/rt-route.yaml b/Documentation/netlink/specs/rt-route.yaml
index 253037ea5176..86fc52f856bf 100644
--- a/Documentation/netlink/specs/rt-route.yaml
+++ b/Documentation/netlink/specs/rt-route.yaml
@@ -99,6 +99,58 @@ definitions:
         name: ra-withdrawn
         doc: A Router Advertisement withdrew the route with a zero
           lifetime.
+  -
+    name: encap-type
+    type: enum
+    name-prefix: lwtunnel-encap-
+    enum-name:
+    entries:
+      - none
+      - mpls
+      - ip
+      - ila
+      - ip6
+      - seg6
+      - bpf
+      - seg6-local
+      - rpl
+      - ioam6
+      - xfrm
+
+sub-messages:
+  -
+    name: encap-data
+    formats:
+      -
+        value: mpls
+        attribute-set: mpls-iptunnel
+      -
+        value: ip
+        attribute-set: lwtunnel-ip
+      -
+        value: ila
+        attribute-set: ila-attrs
+      -
+        value: ip6
+        attribute-set: lwtunnel-ip6
+      -
+        value: seg6
+        attribute-set: seg6-iptunnel
+      -
+        value: bpf
+        attribute-set: lwt-bpf
+      -
+        value: seg6-local
+        attribute-set: seg6-local
+      -
+        value: rpl
+        attribute-set: rpl-iptunnel
+      -
+        value: ioam6
+        attribute-set: ioam6-iptunnel
+      -
+        value: xfrm
+        attribute-set: lwt-xfrm
 
 attribute-sets:
   -
@@ -174,9 +226,12 @@ attribute-sets:
       -
         name: encap-type
         type: u16
+        enum: encap-type
       -
         name: encap
-        type: binary  # tunnel specific nest
+        type: sub-message
+        sub-message: encap-data
+        selector: encap-type
       -
         name: expires
         type: u32
@@ -277,6 +332,234 @@ attribute-sets:
       -
         name: fastopen-no-cookie
         type: u32
+  -
+    name: mpls-iptunnel
+    name-prefix: mpls-iptunnel-
+    header: linux/mpls_iptunnel.h
+    attributes:
+      -
+        name: dst
+        type: binary
+      -
+        name: ttl
+        type: u8
+  -
+    name: lwtunnel-ip
+    name-prefix: lwtunnel-ip-
+    header: linux/lwtunnel.h
+    attributes:
+      -
+        name: id
+        type: u64
+        byte-order: big-endian
+      -
+        name: dst
+        type: u32
+        byte-order: big-endian
+        display-hint: ipv4
+      -
+        name: src
+        type: u32
+        byte-order: big-endian
+        display-hint: ipv4
+      -
+        name: ttl
+        type: u8
+      -
+        name: tos
+        type: u8
+      -
+        name: flags
+        type: u16
+        byte-order: big-endian
+      -
+        name: pad
+        type: pad
+      -
+        name: opts
+        type: binary  # lwtunnel ip nest options
+  -
+    name: ila-attrs
+    name-prefix: ila-attr-
+    header: linux/ila.h
+    attributes:
+      -
+        name: locator
+        type: u64
+      -
+        name: identifier
+        type: u64
+      -
+        name: locator-match
+        type: u64
+      -
+        name: ifindex
+        type: s32
+      -
+        name: dir
+        type: u32
+      -
+        name: pad
+        type: pad
+      -
+        name: csum-mode
+        type: u8
+      -
+        name: ident-type
+        type: u8
+      -
+        name: hook-type
+        type: u8
+  -
+    name: lwtunnel-ip6
+    name-prefix: lwtunnel-ip6-
+    header: linux/lwtunnel.h
+    attributes:
+      -
+        name: id
+        type: u64
+        byte-order: big-endian
+      -
+        name: dst
+        type: binary
+        display-hint: ipv6
+      -
+        name: src
+        type: binary
+        display-hint: ipv6
+      -
+        name: hoplimit
+        type: u8
+      -
+        name: tc
+        type: u8
+      -
+        name: flags
+        type: u16
+        byte-order: big-endian
+      -
+        name: pad
+        type: pad
+      -
+        name: opts
+        type: binary  # lwtunnel ip nest options
+  -
+    name: seg6-iptunnel
+    name-prefix: seg6-iptunnel-
+    header: linux/seg6_iptunnel.h
+    attributes:
+      -
+        name: srh
+        type: binary
+      -
+        name: src
+        type: binary
+        display-hint: ipv6
+      -
+        name: table
+        type: u32
+  -
+    name: lwt-bpf
+    name-prefix: lwt-bpf-
+    header: linux/lwtunnel.h
+    attributes:
+      -
+        name: in
+        type: binary  # bpf prog
+      -
+        name: out
+        type: binary
+      -
+        name: xmit
+        type: binary
+      -
+        name: xmit-headroom
+        type: u32
+  -
+    name: seg6-local
+    name-prefix: seg6-local-
+    header: linux/seg6_local.h
+    attributes:
+      -
+        name: action
+        type: u32
+      -
+        name: srh
+        type: binary
+      -
+        name: table
+        type: u32
+      -
+        name: nh4
+        type: u32
+        byte-order: big-endian
+        display-hint: ipv4
+      -
+        name: nh6
+        type: binary
+        display-hint: ipv6
+      -
+        name: iif
+        type: u32
+      -
+        name: oif
+        type: u32
+      -
+        name: bpf
+        type: binary
+      -
+        name: vrftable
+        type: u32
+      -
+        name: counters
+        type: binary
+      -
+        name: flavors
+        type: binary
+  -
+    name: rpl-iptunnel
+    name-prefix: rpl-iptunnel-
+    header: linux/rpl_iptunnel.h
+    attributes:
+      -
+        name: srh
+        type: binary
+  -
+    name: ioam6-iptunnel
+    name-prefix: ioam6-iptunnel-
+    header: linux/ioam6_iptunnel.h
+    attributes:
+      -
+        name: mode
+        type: u8
+      -
+        name: dst
+        type: binary
+        display-hint: ipv6
+      -
+        name: trace
+        type: binary
+      -
+        name: freq-k
+        type: u32
+      -
+        name: freq-n
+        type: u32
+      -
+        name: src
+        type: binary
+        display-hint: ipv6
+  -
+    name: lwt-xfrm
+    name-prefix: lwt-xfrm-
+    header: linux/lwtunnel.h
+    attributes:
+      -
+        name: if-id
+        type: u32
+      -
+        name: link
+        type: u32
 
 operations:
   enum-model: directional
diff --git a/tools/net/ynl/Makefile.deps b/tools/net/ynl/Makefile.deps
index 1e746e25e2bc..904433761524 100644
--- a/tools/net/ynl/Makefile.deps
+++ b/tools/net/ynl/Makefile.deps
@@ -45,7 +45,14 @@ CFLAGS_rt-link:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
 	$(call get_hdr_inc,_LINUX_IF_LINK_H,if_link.h)
 CFLAGS_rt-neigh:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
 	$(call get_hdr_inc,__LINUX_NEIGHBOUR_H,neighbour.h)
-CFLAGS_rt-route:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h)
+CFLAGS_rt-route:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
+	$(call get_hdr_inc,_LINUX_IOAM6_IPTUNNEL_H,ioam6_iptunnel.h) \
+	$(call get_hdr_inc,_LINUX_MPLS_IPTUNNEL_H,mpls_iptunnel.h) \
+	$(call get_hdr_inc,_LINUX_SEG6_IPTUNNEL_H,seg6_iptunnel.h) \
+	$(call get_hdr_inc,_LINUX_RPL_IPTUNNEL_H,rpl_iptunnel.h) \
+	$(call get_hdr_inc,_LINUX_SEG6_LOCAL_H,seg6_local.h) \
+	$(call get_hdr_inc,_LWTUNNEL_H_,lwtunnel.h) \
+	$(call get_hdr_inc,_LINUX_ILA_H,ila.h)
 CFLAGS_rt-rule:=$(call get_hdr_inc,__LINUX_FIB_RULES_H,fib_rules.h)
 CFLAGS_tc:= $(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
 	$(call get_hdr_inc,__LINUX_PKT_SCHED_H,pkt_sched.h) \

-- 
2.55.0


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

* [PATCH net-next v2 4/6] netlink: specs: rt-route: describe lwtunnel IP options
  2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
                   ` (2 preceding siblings ...)
  2026-09-20 10:06 ` [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support Hangbin Liu
@ 2026-09-20 10:06 ` Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 5/6] netlink: specs: rt-route: describe lwt BPF program options Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 6/6] netlink: specs: rt-route: describe seg6-local actions, counters and flavors Hangbin Liu
  5 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

Replace binary opts in lwtunnel-ip and lwtunnel-ip6 with a nested
lwtunnel-ip-opts set. Add attribute sets for geneve, vxlan, and erspan
IP options to match linux/lwtunnel.h.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 Documentation/netlink/specs/rt-route.yaml | 62 ++++++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/Documentation/netlink/specs/rt-route.yaml b/Documentation/netlink/specs/rt-route.yaml
index 86fc52f856bf..4b12a8a58652 100644
--- a/Documentation/netlink/specs/rt-route.yaml
+++ b/Documentation/netlink/specs/rt-route.yaml
@@ -377,7 +377,8 @@ attribute-sets:
         type: pad
       -
         name: opts
-        type: binary  # lwtunnel ip nest options
+        type: nest
+        nested-attributes: lwtunnel-ip-opts
   -
     name: ila-attrs
     name-prefix: ila-attr-
@@ -442,7 +443,8 @@ attribute-sets:
         type: pad
       -
         name: opts
-        type: binary  # lwtunnel ip nest options
+        type: nest
+        nested-attributes: lwtunnel-ip-opts
   -
     name: seg6-iptunnel
     name-prefix: seg6-iptunnel-
@@ -560,6 +562,62 @@ attribute-sets:
       -
         name: link
         type: u32
+  -
+    name: lwtunnel-ip-opts
+    name-prefix: lwtunnel-ip-opts-
+    attributes:
+      -
+        name: geneve
+        type: nest
+        nested-attributes: lwtunnel-ip-opt-geneve
+      -
+        name: vxlan
+        type: nest
+        nested-attributes: lwtunnel-ip-opt-vxlan
+      -
+        name: erspan
+        type: nest
+        nested-attributes: lwtunnel-ip-opt-erspan
+  -
+    name: lwtunnel-ip-opt-geneve
+    name-prefix: lwtunnel-ip-opt-geneve-
+    attributes:
+      -
+        name: class
+        type: u16
+        byte-order: big-endian
+      -
+        name: type
+        type: u8
+      -
+        name: data
+        type: binary
+        checks:
+          max-len: 127
+  -
+    name: lwtunnel-ip-opt-vxlan
+    name-prefix: lwtunnel-ip-opt-vxlan-
+    attributes:
+      -
+        name: gbp
+        type: u32
+  -
+    name: lwtunnel-ip-opt-erspan
+    name-prefix: lwtunnel-ip-opt-erspan-
+    attributes:
+      -
+        name: ver
+        type: u8
+      -
+        name: index
+        type: u32
+        byte-order: big-endian
+      -
+        name: dir
+        type: u8
+      -
+        name: hwid
+        type: u8
 
 operations:
   enum-model: directional

-- 
2.55.0


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

* [PATCH net-next v2 5/6] netlink: specs: rt-route: describe lwt BPF program options
  2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
                   ` (3 preceding siblings ...)
  2026-09-20 10:06 ` [PATCH net-next v2 4/6] netlink: specs: rt-route: describe lwtunnel IP options Hangbin Liu
@ 2026-09-20 10:06 ` Hangbin Liu
  2026-09-20 10:06 ` [PATCH net-next v2 6/6] netlink: specs: rt-route: describe seg6-local actions, counters and flavors Hangbin Liu
  5 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

Replace binary BPF attributes with a nested lwt-bpf-prog to support
lwt bpf prog options.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 Documentation/netlink/specs/rt-route.yaml | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/Documentation/netlink/specs/rt-route.yaml b/Documentation/netlink/specs/rt-route.yaml
index 4b12a8a58652..4a3953c9e978 100644
--- a/Documentation/netlink/specs/rt-route.yaml
+++ b/Documentation/netlink/specs/rt-route.yaml
@@ -467,13 +467,16 @@ attribute-sets:
     attributes:
       -
         name: in
-        type: binary  # bpf prog
+        type: nest
+        nested-attributes: lwt-bpf-prog
       -
         name: out
-        type: binary
+        type: nest
+        nested-attributes: lwt-bpf-prog
       -
         name: xmit
-        type: binary
+        type: nest
+        nested-attributes: lwt-bpf-prog
       -
         name: xmit-headroom
         type: u32
@@ -508,7 +511,8 @@ attribute-sets:
         type: u32
       -
         name: bpf
-        type: binary
+        type: nest
+        nested-attributes: lwt-bpf-prog
       -
         name: vrftable
         type: u32
@@ -618,6 +622,17 @@ attribute-sets:
       -
         name: hwid
         type: u8
+  -
+    name: lwt-bpf-prog
+    name-prefix: lwt-bpf-prog-
+    header: linux/lwtunnel.h
+    attributes:
+      -
+        name: fd
+        type: u32
+      -
+        name: name
+        type: string
 
 operations:
   enum-model: directional

-- 
2.55.0


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

* [PATCH net-next v2 6/6] netlink: specs: rt-route: describe seg6-local actions, counters and flavors
  2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
                   ` (4 preceding siblings ...)
  2026-09-20 10:06 ` [PATCH net-next v2 5/6] netlink: specs: rt-route: describe lwt BPF program options Hangbin Liu
@ 2026-09-20 10:06 ` Hangbin Liu
  5 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-09-20 10:06 UTC (permalink / raw)
  To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Donald Hunter
  Cc: Hangbin Liu, netdev, linux-kernel, bpf, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

Add SEG6 local actions enum. Replace binary counters/flavors in seg6-local
with nested seg6-local-cnt and seg6-local-flv.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 Documentation/netlink/specs/rt-route.yaml | 59 +++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/Documentation/netlink/specs/rt-route.yaml b/Documentation/netlink/specs/rt-route.yaml
index 4a3953c9e978..711c667bbc43 100644
--- a/Documentation/netlink/specs/rt-route.yaml
+++ b/Documentation/netlink/specs/rt-route.yaml
@@ -116,6 +116,29 @@ definitions:
       - rpl
       - ioam6
       - xfrm
+  -
+    name: seg6-local-actions
+    type: enum
+    name-prefix: seg6-local-action-
+    enum-name:
+    entries:
+      - unspec
+      - end
+      - end-x
+      - end-t
+      - end-dx2
+      - end-dx6
+      - end-dx4
+      - end-dt6
+      - end-dt4
+      - end-b6
+      - end-b6-encap
+      - end-bm
+      - end-s
+      - end-as
+      - end-am
+      - end-bpf
+      - end-dt46
 
 sub-messages:
   -
@@ -488,6 +511,7 @@ attribute-sets:
       -
         name: action
         type: u32
+        enum: seg6-local-actions
       -
         name: srh
         type: binary
@@ -518,10 +542,12 @@ attribute-sets:
         type: u32
       -
         name: counters
-        type: binary
+        type: nest
+        nested-attributes: seg6-local-cnt
       -
         name: flavors
-        type: binary
+        type: nest
+        nested-attributes: seg6-local-flv
   -
     name: rpl-iptunnel
     name-prefix: rpl-iptunnel-
@@ -633,6 +659,35 @@ attribute-sets:
       -
         name: name
         type: string
+  -
+    name: seg6-local-cnt
+    name-prefix: seg6-local-cnt-
+    attributes:
+      -
+        name: pad
+        type: pad
+      -
+        name: packets
+        type: u64
+      -
+        name: bytes
+        type: u64
+      -
+        name: errors
+        type: u64
+  -
+    name: seg6-local-flv
+    name-prefix: seg6-local-flv-
+    attributes:
+      -
+        name: operation
+        type: u32
+      -
+        name: lcblock-bits
+        type: u8
+      -
+        name: lcnode-fn-bits
+        type: u8
 
 operations:
   enum-model: directional

-- 
2.55.0


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

* Re: [PATCH net-next v2 2/6] tools: ynl: convert enum selector to string for sub-message parsing
  2026-09-20 10:06 ` [PATCH net-next v2 2/6] tools: ynl: convert enum selector to string for sub-message parsing Hangbin Liu
@ 2026-09-24  1:14   ` Jakub Kicinski
  0 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2026-09-24  1:14 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, Donald Hunter, netdev, linux-kernel,
	bpf, Hangbin Liu

On Sun, 20 Sep 2026 18:06:37 +0800 Hangbin Liu wrote:
> 	const char *encap_type_str;
> 	encap_type_str = rt_route_encap_type_str(dst->encap_type);
> 	if (!encap_type_str)
> 		return ynl_submsg_failed(yarg, "encap", "encap-type");
> 	if (rt_route_encap_data_parse(&parg, encap_type_str, attr))
> 		return YNL_PARSE_CB_ERROR;

Please squash this in:

diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 785e747e5865..3b95e5d31638 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -954,14 +954,13 @@ from lib import SpecSubMessage
 
         parse_sel = sel_var
         get_lines = []
-        if not self.selector.is_external() and self.selector.attr and \
-           "enum" in self.selector.attr.attr:
-            enum_name = self.selector.attr.attr["enum"]
-            str_fn = c_lower(self.family.ident_name + "-" + enum_name) + "_str"
-            sel_str_var = f"{sel}_str"
-            get_lines += [f'const char *{sel_str_var};',
-                          f'{sel_str_var} = {str_fn}({sel_var});']
-            parse_sel = sel_str_var
+        local_vars = None
+
+        if self.selector.is_enum_val():
+            parse_sel = f"{sel}_str"
+            local_vars = [f'const char *{parse_sel};']
+            enum = self.family.consts[self.selector.get_enum_name()]
+            get_lines += [f'{parse_sel} = {enum.render_name}_str({sel_var});']
 
         get_lines += [f'if (!{parse_sel})',
                       f'return ynl_submsg_failed(yarg, "{self.name}", "{selector}");',
@@ -969,7 +968,7 @@ from lib import SpecSubMessage
                       "return YNL_PARSE_CB_ERROR;"]
         init_lines = [f"parg.rsp_policy = &{self.nested_render_name}_nest;",
                       f"parg.data = &{var}->{self.c_name};"]
-        return get_lines, init_lines, None
+        return get_lines, init_lines, local_vars
 
 
 class Selector:
@@ -991,6 +990,12 @@ from lib import SpecSubMessage
     def is_external(self):
         return self._external
 
+    def is_enum_val(self):
+        return self.get_enum_name() is not None
+
+    def get_enum_name(self):
+        return self.attr and self.attr.attr.get("enum")
+
 
 class Struct:
     def __init__(self, family, space_name, type_list=None, fixed_header=None,

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

* Re: [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support
  2026-09-20 10:06 ` [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support Hangbin Liu
@ 2026-09-24  1:14   ` Jakub Kicinski
  2026-09-24  3:13     ` Hangbin Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Jakub Kicinski @ 2026-09-24  1:14 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, Donald Hunter, netdev, linux-kernel,
	bpf, Hangbin Liu

On Sun, 20 Sep 2026 18:06:38 +0800 Hangbin Liu wrote:
> -CFLAGS_rt-route:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h)
> +CFLAGS_rt-route:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
> +	$(call get_hdr_inc,_LINUX_IOAM6_IPTUNNEL_H,ioam6_iptunnel.h) \
> +	$(call get_hdr_inc,_LINUX_MPLS_IPTUNNEL_H,mpls_iptunnel.h) \
> +	$(call get_hdr_inc,_LINUX_SEG6_IPTUNNEL_H,seg6_iptunnel.h) \
> +	$(call get_hdr_inc,_LINUX_RPL_IPTUNNEL_H,rpl_iptunnel.h) \
> +	$(call get_hdr_inc,_LINUX_SEG6_LOCAL_H,seg6_local.h) \
> +	$(call get_hdr_inc,_LWTUNNEL_H_,lwtunnel.h) \
> +	$(call get_hdr_inc,_LINUX_ILA_H,ila.h)

alphabetic sort, please

Please look at clashiko review on the web, it won't be emailed out due
toe kernel.org outage:

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260920-ynl_rt_encap-v2-5-c664a3e726f6@kylinos.cn
-- 
pw-bot: cr

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

* Re: [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support
  2026-09-24  1:14   ` Jakub Kicinski
@ 2026-09-24  3:13     ` Hangbin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-09-24  3:13 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, Donald Hunter, netdev, linux-kernel,
	bpf, Hangbin Liu

Hi Jakub,
On Wed, Sep 23, 2026 at 06:14:56PM -0700, Jakub Kicinski wrote:
> On Sun, 20 Sep 2026 18:06:38 +0800 Hangbin Liu wrote:
> > -CFLAGS_rt-route:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h)
> > +CFLAGS_rt-route:=$(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
> > +	$(call get_hdr_inc,_LINUX_IOAM6_IPTUNNEL_H,ioam6_iptunnel.h) \
> > +	$(call get_hdr_inc,_LINUX_MPLS_IPTUNNEL_H,mpls_iptunnel.h) \
> > +	$(call get_hdr_inc,_LINUX_SEG6_IPTUNNEL_H,seg6_iptunnel.h) \
> > +	$(call get_hdr_inc,_LINUX_RPL_IPTUNNEL_H,rpl_iptunnel.h) \
> > +	$(call get_hdr_inc,_LINUX_SEG6_LOCAL_H,seg6_local.h) \
> > +	$(call get_hdr_inc,_LWTUNNEL_H_,lwtunnel.h) \
> > +	$(call get_hdr_inc,_LINUX_ILA_H,ila.h)
> 
> alphabetic sort, please

OK. Just to make sure, when sort the order, we don't touch the first
rtnetlink.h, right?

> 
> Please look at clashiko review on the web, it won't be emailed out due
> toe kernel.org outage:
> 
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260920-ynl_rt_encap-v2-5-c664a3e726f6@kylinos.cn

Thanks, I will review the feed back and fix the issues.

Hangbin

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

end of thread, other threads:[~2026-09-24  3:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-20 10:06 [PATCH net-next v2 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
2026-09-20 10:06 ` [PATCH net-next v2 1/6] net: lwtunnel: change encap fill order Hangbin Liu
2026-09-20 10:06 ` [PATCH net-next v2 2/6] tools: ynl: convert enum selector to string for sub-message parsing Hangbin Liu
2026-09-24  1:14   ` Jakub Kicinski
2026-09-20 10:06 ` [PATCH net-next v2 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support Hangbin Liu
2026-09-24  1:14   ` Jakub Kicinski
2026-09-24  3:13     ` Hangbin Liu
2026-09-20 10:06 ` [PATCH net-next v2 4/6] netlink: specs: rt-route: describe lwtunnel IP options Hangbin Liu
2026-09-20 10:06 ` [PATCH net-next v2 5/6] netlink: specs: rt-route: describe lwt BPF program options Hangbin Liu
2026-09-20 10:06 ` [PATCH net-next v2 6/6] netlink: specs: rt-route: describe seg6-local actions, counters and flavors Hangbin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®