Commit dd4f33b4 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'tools-ynl-c-basic-netlink-raw-support'

Jakub Kicinski says:

====================
tools: ynl: c: basic netlink-raw support

Basic support for netlink-raw AKA classic netlink in user space C codegen.
This series is enough to read routes and addresses from the kernel
(see the samples in patches 12 and 13).

Specs need to be slightly adjusted and decorated with the c naming info.

In terms of codegen this series includes just the basic plumbing required
to skip genlmsghdr and handle request types which may technically also
be legal in genetlink-legacy but are very uncommon there.

Subsequent series will add support for:
 - handling CRUD-style notifications
 - code gen for array types classic netlink uses
 - sub-message support

v1: https://lore.kernel.org/20250409000400.492371-1-kuba@kernel.org
====================

Link: https://patch.msgid.link/20250410014658.782120-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4145f002 54d79085
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

name: rt-addr
protocol: netlink-raw
uapi-header: linux/rtnetlink.h
protonum: 0

doc:
@@ -49,6 +50,8 @@ definitions:
  -
    name: ifa-flags
    type: flags
    name-prefix: ifa-f-
    enum-name:
    entries:
      -
        name: secondary
@@ -124,6 +127,7 @@ attribute-sets:
operations:
  fixed-header: ifaddrmsg
  enum-model: directional
  name-prefix: rtm-
  list:
    -
      name: newaddr
@@ -133,11 +137,6 @@ operations:
        request:
          value: 20
          attributes: &ifaddr-all
            - ifa-family
            - ifa-flags
            - ifa-prefixlen
            - ifa-scope
            - ifa-index
            - address
            - label
            - local
@@ -150,11 +149,6 @@ operations:
        request:
          value: 21
          attributes:
            - ifa-family
            - ifa-flags
            - ifa-prefixlen
            - ifa-scope
            - ifa-index
            - address
            - local
    -
@@ -164,8 +158,7 @@ operations:
      dump:
        request:
          value: 22
          attributes:
            - ifa-index
          attributes: []
        reply:
          value: 20
          attributes: *ifaddr-all
@@ -177,9 +170,7 @@ operations:
      do:
        request:
          value: 58
          attributes:
            - ifa-family
            - ifa-index
          attributes: []
        reply:
          value: 58
          attributes: &mcaddr-attrs
@@ -188,8 +179,7 @@ operations:
      dump:
        request:
          value: 58
          attributes:
            - ifa-family
          attributes: []
        reply:
          value: 58
          attributes: *mcaddr-attrs
+5 −17
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

name: rt-route
protocol: netlink-raw
uapi-header: linux/rtnetlink.h
protonum: 0

doc:
@@ -11,6 +12,7 @@ definitions:
  -
    name: rtm-type
    name-prefix: rtn-
    enum-name:
    type: enum
    entries:
      - unspec
@@ -245,21 +247,19 @@ attribute-sets:

operations:
  enum-model: directional
  fixed-header: rtmsg
  name-prefix: rtm-
  list:
    -
      name: getroute
      doc: Dump route information.
      attribute-set: route-attrs
      fixed-header: rtmsg
      do:
        request:
          value: 26
          attributes:
            - rtm-family
            - src
            - rtm-src-len
            - dst
            - rtm-dst-len
            - iif
            - oif
            - ip-proto
@@ -271,15 +271,6 @@ operations:
        reply:
          value: 24
          attributes: &all-route-attrs
            - rtm-family
            - rtm-dst-len
            - rtm-src-len
            - rtm-tos
            - rtm-table
            - rtm-protocol
            - rtm-scope
            - rtm-type
            - rtm-flags
            - dst
            - src
            - iif
@@ -311,8 +302,7 @@ operations:
      dump:
        request:
          value: 26
          attributes:
            - rtm-family
          attributes: []
        reply:
          value: 24
          attributes: *all-route-attrs
@@ -320,7 +310,6 @@ operations:
      name: newroute
      doc: Create a new route
      attribute-set: route-attrs
      fixed-header: rtmsg
      do:
        request:
          value: 24
@@ -329,7 +318,6 @@ operations:
      name: delroute
      doc: Delete an existing route
      attribute-set: route-attrs
      fixed-header: rtmsg
      do:
        request:
          value: 25
Loading