Merge branch 'netlink-specs-rtnetlink-adjust-specs-for-c-codegen'

Jakub Kicinski says:

====================
netlink: specs: rtnetlink: adjust specs for C codegen

The first patch brings a schema extension allowing specifying
"header" (as in .h file) properties in attribute sets.
This is used for rare cases where we carry attributes from
another family in a nest - we need to include the extra
headers. If we were to generate kernel code we'd also
need to skip it in the uAPI output.

The remaining 11 patches are pretty boring schema adjustments.
====================

Link: https://patch.msgid.link/20250418021706.1967583-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski
2025-04-23 16:07:22 -07:00
7 changed files with 69 additions and 23 deletions

View File

@@ -148,6 +148,9 @@ properties:
attr-max-name:
description: The explicit name for last member of attribute enum.
type: string
header:
description: For C-compatible languages, header which already defines this attribute set.
type: string
# End genetlink-c
attributes:
description: List of attributes in the space.

View File

@@ -193,6 +193,9 @@ properties:
attr-max-name:
description: The explicit name for last member of attribute enum.
type: string
header:
description: For C-compatible languages, header which already defines this attribute set.
type: string
# End genetlink-c
attributes:
description: List of attributes in the space.

View File

@@ -207,6 +207,9 @@ properties:
attr-max-name:
description: The explicit name for last member of attribute enum.
type: string
header:
description: For C-compatible languages, header which already defines this attribute set.
type: string
# End genetlink-c
attributes:
description: List of attributes in the space.

View File

@@ -2,6 +2,7 @@
name: rt-link
protocol: netlink-raw
uapi-header: linux/rtnetlink.h
protonum: 0
doc:
@@ -11,6 +12,9 @@ definitions:
-
name: ifinfo-flags
type: flags
header: linux/if.h
enum-name: net-device-flags
name-prefix: iff-
entries:
-
name: up
@@ -53,6 +57,7 @@ definitions:
-
name: vlan-protocols
type: enum
enum-name:
entries:
-
name: 8021q
@@ -754,6 +759,7 @@ definitions:
-
name: vlan-flags
type: flags
enum-name:
entries:
- reorder-hdr
- gvrp
@@ -840,6 +846,7 @@ definitions:
-
name: ifla-vf-link-state-enum
type: enum
enum-name:
entries:
- auto
- enable
@@ -906,6 +913,7 @@ definitions:
-
name: rtext-filter
type: flags
enum-name:
entries:
- vf
- brvlan
@@ -918,6 +926,7 @@ definitions:
-
name: netkit-policy
type: enum
enum-name:
entries:
-
name: forward
@@ -928,6 +937,7 @@ definitions:
-
name: netkit-mode
type: enum
enum-name: netkit-mode
entries:
- name: l2
- name: l3
@@ -935,6 +945,7 @@ definitions:
-
name: netkit-scrub
type: enum
enum-name:
entries:
- name: none
- name: default
@@ -1177,24 +1188,27 @@ attribute-sets:
multi-attr: true
-
name: af-spec-attrs
name-prefix: af-
attr-max-name: af-max
attributes:
-
name: "inet"
name: inet
type: nest
value: 2
nested-attributes: ifla-attrs
-
name: "inet6"
name: inet6
type: nest
value: 10
nested-attributes: ifla6-attrs
-
name: "mctp"
name: mctp
type: nest
value: 45
nested-attributes: mctp-attrs
-
name: vfinfo-list-attrs
name-prefix: ifla-vf-
attributes:
-
name: info
@@ -1203,6 +1217,7 @@ attribute-sets:
multi-attr: true
-
name: vfinfo-attrs
name-prefix: ifla-vf-
attributes:
-
name: mac
@@ -1257,6 +1272,7 @@ attribute-sets:
type: binary
-
name: vf-stats-attrs
name-prefix: ifla-vf-stats-
attributes:
-
name: rx-packets
@@ -1288,6 +1304,8 @@ attribute-sets:
type: u64
-
name: vf-vlan-attrs
name-prefix: ifla-vf-vlan-
attr-max-name: ifla-vf-vlan-info-max
attributes:
-
name: info
@@ -1296,12 +1314,15 @@ attribute-sets:
multi-attr: true
-
name: vf-ports-attrs
name-prefix: ifla-
attributes: []
-
name: port-self-attrs
name-prefix: ifla-
attributes: []
-
name: linkinfo-attrs
name-prefix: ifla-info-
attributes:
-
name: kind
@@ -1426,6 +1447,8 @@ attribute-sets:
type: indexed-array
sub-type: binary
display-hint: ipv6
checks:
exact-len: 16
-
name: coupled-control
type: u8
@@ -1855,6 +1878,7 @@ attribute-sets:
-
name: linkinfo-vti-attrs
name-prefix: ifla-vti-
header: linux/if_tunnel.h
attributes:
-
name: link
@@ -2107,7 +2131,7 @@ attribute-sets:
byte-order: big-endian
-
name: ifla-vlan-qos
name-prefix: ifla-vlan-qos
name-prefix: ifla-vlan-qos-
attributes:
-
name: mapping
@@ -2123,6 +2147,7 @@ attribute-sets:
type: u32
-
name: xdp-attrs
name-prefix: ifla-xdp-
attributes:
-
name: fd
@@ -2150,6 +2175,7 @@ attribute-sets:
type: s32
-
name: ifla-attrs
name-prefix: ifla-inet-
attributes:
-
name: conf
@@ -2157,6 +2183,7 @@ attribute-sets:
struct: ipv4-devconf
-
name: ifla6-attrs
name-prefix: ifla-inet6-
attributes:
-
name: flags
@@ -2222,6 +2249,7 @@ attribute-sets:
type: binary
-
name: link-offload-xstats
name-prefix: ifla-offload-xstats-
attributes:
-
name: cpu-hit
@@ -2236,6 +2264,7 @@ attribute-sets:
type: binary
-
name: hw-s-info-one
name-prefix: ifla-offload-xstats-hw-s-info-
attributes:
-
name: request
@@ -2245,6 +2274,8 @@ attribute-sets:
type: u8
-
name: link-dpll-pin-attrs
name-prefix: dpll-a-
header: linux/dpll.h
attributes:
-
name: id
@@ -2357,6 +2388,7 @@ sub-messages:
operations:
enum-model: directional
name-prefix: rtm-
list:
-
name: newlink
@@ -2367,7 +2399,6 @@ operations:
request:
value: 16
attributes: &link-new-attrs
- ifi-index
- ifname
- net-ns-pid
- net-ns-fd
@@ -2383,13 +2414,18 @@ operations:
- txqlen
- operstate
- linkmode
- group
- gso-max-size
- gso-max-segs
- gro-max-size
- gso-ipv4-max-size
- gro-ipv4-max-size
- af-spec
-
name: newlink-ntf
doc: Notify that a link has been created
value: 16
notify: getlink
fixed-header: ifinfomsg
-
name: dellink
doc: Delete an existing link.
@@ -2399,7 +2435,6 @@ operations:
request:
value: 17
attributes:
- ifi-index
- ifname
-
name: getlink
@@ -2410,7 +2445,6 @@ operations:
request:
value: 18
attributes:
- ifi-index
- ifname
- alt-ifname
- ext-mask
@@ -2418,11 +2452,6 @@ operations:
reply:
value: 16
attributes: &link-all-attrs
- ifi-family
- ifi-type
- ifi-index
- ifi-flags
- ifi-change
- address
- broadcast
- ifname
@@ -2468,7 +2497,6 @@ operations:
- xdp
- event
- new-netnsid
- if-netnsid
- target-netnsid
- carrier-up-count
- carrier-down-count
@@ -2515,14 +2543,9 @@ operations:
do:
request:
value: 94
attributes:
- ifindex
reply:
value: 92
attributes: &link-stats-attrs
- family
- ifindex
- filter-mask
- link-64
- link-xstats
- link-xstats-slave

View File

@@ -2,6 +2,7 @@
name: rt-neigh
protocol: netlink-raw
uapi-header: linux/rtnetlink.h
protonum: 0
doc:
@@ -48,6 +49,7 @@ definitions:
-
name: nud-state
type: flags
enum-name:
entries:
- incomplete
- reachable
@@ -60,6 +62,7 @@ definitions:
-
name: ntf-flags
type: flags
enum-name:
entries:
- use
- self
@@ -72,12 +75,14 @@ definitions:
-
name: ntf-ext-flags
type: flags
enum-name:
entries:
- managed
- locked
-
name: rtm-type
type: enum
enum-name:
entries:
- unspec
- unicast
@@ -179,6 +184,7 @@ definitions:
attribute-sets:
-
name: neighbour-attrs
name-prefix: nda-
attributes:
-
name: unspec
@@ -241,6 +247,7 @@ attribute-sets:
type: u8
-
name: ndt-attrs
name-prefix: ndta-
attributes:
-
name: name
@@ -274,6 +281,7 @@ attribute-sets:
type: pad
-
name: ndtpa-attrs
name-prefix: ndtpa-
attributes:
-
name: ifindex
@@ -335,6 +343,7 @@ attribute-sets:
operations:
enum-model: directional
name-prefix: rtm-
list:
-
name: newneigh
@@ -372,7 +381,7 @@ operations:
name: delneigh-ntf
doc: Notify a neighbour deletion
value: 29
notify: delneigh
notify: getneigh
fixed-header: ndmsg
-
name: getneigh
@@ -393,6 +402,7 @@ operations:
- ifindex
- master
reply:
value: 28
attributes: *neighbour-all
-
name: newneigh-ntf

View File

@@ -2,6 +2,7 @@
name: rt-rule
protocol: netlink-raw
uapi-header: linux/fib_rules.h
protonum: 0
doc:
@@ -56,6 +57,7 @@ definitions:
-
name: fr-act
type: enum
enum-name:
entries:
- unspec
- to-tbl
@@ -90,6 +92,7 @@ definitions:
attribute-sets:
-
name: fib-rule-attrs
name-prefix: fra-
attributes:
-
name: dst
@@ -198,6 +201,7 @@ attribute-sets:
operations:
enum-model: directional
fixed-header: fib-rule-hdr
name-prefix: rtm-
list:
-
name: newrule
@@ -234,7 +238,7 @@ operations:
name: newrule-ntf
doc: Notify a rule creation
value: 32
notify: newrule
notify: getrule
-
name: delrule
doc: Remove an existing FIB rule
@@ -247,7 +251,7 @@ operations:
name: delrule-ntf
doc: Notify a rule deletion
value: 33
notify: delrule
notify: getrule
-
name: getrule
doc: Dump all FIB rules

View File

@@ -2909,7 +2909,7 @@ def main():
cw.p(f'#include "{hdr_file}"')
cw.p('#include "ynl.h"')
headers = []
for definition in parsed['definitions']:
for definition in parsed['definitions'] + parsed['attribute-sets']:
if 'header' in definition:
headers.append(definition['header'])
if args.mode == 'user':