[PATCH wireguard v4 00/10] wireguard: netlink: ynl conversion

Asbjørn Sloth Tønnesen posted 10 patches 5 days, 4 hours ago
Documentation/netlink/specs/wireguard.yaml | 298 +++++++++++++++++++++
MAINTAINERS                                |   2 +
drivers/net/wireguard/Makefile             |   2 +-
drivers/net/wireguard/generated/netlink.c  |  73 +++++
drivers/net/wireguard/generated/netlink.h  |  30 +++
drivers/net/wireguard/netlink.c            |  67 +----
include/uapi/linux/wireguard.h             | 191 +++----------
tools/net/ynl/Makefile.deps                |   2 +
tools/net/ynl/samples/.gitignore           |   1 +
tools/net/ynl/samples/wireguard.c          | 104 +++++++
10 files changed, 556 insertions(+), 214 deletions(-)
create mode 100644 Documentation/netlink/specs/wireguard.yaml
create mode 100644 drivers/net/wireguard/generated/netlink.c
create mode 100644 drivers/net/wireguard/generated/netlink.h
create mode 100644 tools/net/ynl/samples/wireguard.c
[PATCH wireguard v4 00/10] wireguard: netlink: ynl conversion
Posted by Asbjørn Sloth Tønnesen 5 days, 4 hours ago
This series completes the implementation of YNL for WireGuard,
as previously announced[1].

This series consist of 5 parts:
1) Patch 01-04 - Misc. changes
2) Patch    05 - Add YNL specification for wireguard
3) Patch 06-08 - Transition to a generated UAPI header
4) Patch    09 - Adds a sample program for the generated C library
5) Patch    10 - Transition to generated netlink policy code

The main benefit of having a YNL specification is unlocked after the
first 2 parts, the RFC version seems to already have spawned a new
Rust netlink binding[2] using wireguard as it's main example.

Part 3 and 5 validates that the specification is complete and aligned,
the generated code might have a few warts, but they don't matter too
much, and are mostly a transitional problem[3].

Part 4 is possible after part 2, but is ordered after part 3,
as it would otherwise have to update the header guard in Makefile.deps.

For the UAPI and non-generated kernel C code the diff stat looks like this:

$ git diff --stat wg-devel..wg-ynl include/ drivers/ \
	':(exclude)*generated/*'
 drivers/net/wireguard/Makefile  |   2 +-
 drivers/net/wireguard/netlink.c |  67 +++---------
 include/uapi/linux/wireguard.h  | 191 ++++++--------------------------
 3 files changed, 46 insertions(+), 214 deletions(-)

[1] [PATCH net 0/4] tools: ynl-gen: misc fixes + wireguard ynl plan
    https://lore.kernel.org/r/20250901145034.525518-1-ast@fiberby.net/
[2] https://github.com/one-d-wide/netlink-bindings/
[3] https://lore.kernel.org/r/20251014123201.6ecfd146@kernel.org/

---
v4:
- Thanks Jason and Jakub for all the feedback.
- Old patch 03 has been accepted into Jason's tree.
- Old patch 09 split_ops conversion has been moved to new 03.
- Old patch 10 function renaming was merged into old patch 11 (new 10).
- Patch 04 has been added to adjust .maxattr for GET_DEVICE.
- The old patches 04-08 and 11 was renumbered to patch 05-10.
- Changes to the spec:
  - Re-wrap the documentation lines in the spec.
  - Reword the index/type documentation.
  - get-device now have a more strict request attribute list.
  - The pre/post functions now avoids renaming.
- Changes to patch 10 (was 10+11):
  - The generated kernel code now uses YNL-ARG --function-prefix,
    to reduce the function renaming.
  - The generated files have been moved to their own sub-directory.
- The commit messages have in general been tweaked a bit.

v3: https://lore.kernel.org/r/20251105183223.89913-1-ast@fiberby.net/
- Spec: Make flags-mask checks implicit (thanks Jakub).
- Sample: Add header to Makefile.deps, and avoid copy (thanks Jakub).

v2: https://lore.kernel.org/r/20251031160539.1701943-1-ast@fiberby.net/
- Add missing forward declaration

v1: https://lore.kernel.org/r/20251029205123.286115-1-ast@fiberby.net/
- Policy arguement to nla_parse_nested() changed to NULL (thanks Johannes).
- Added attr-cnt-name to the spec, to reduce the diff a bit.
- Refined the doc in the spec a bit.
- Reword commit messages a bit.
- Reordered the patches, and reduced the series from 14 to 11 patches.

RFC: https://lore.kernel.org/r/20250904-wg-ynl-rfc@fiberby.net/

Asbjørn Sloth Tønnesen (10):
  wireguard: netlink: validate nested arrays in policy
  wireguard: netlink: use WG_KEY_LEN in policies
  wireguard: netlink: convert to split ops
  wireguard: netlink: lower .maxattr for WG_CMD_GET_DEVICE
  netlink: specs: add specification for wireguard
  wireguard: uapi: move enum wg_cmd
  wireguard: uapi: move flag enums
  wireguard: uapi: generate header with ynl-gen
  tools: ynl: add sample for wireguard
  wireguard: netlink: generate netlink code

 Documentation/netlink/specs/wireguard.yaml | 298 +++++++++++++++++++++
 MAINTAINERS                                |   2 +
 drivers/net/wireguard/Makefile             |   2 +-
 drivers/net/wireguard/generated/netlink.c  |  73 +++++
 drivers/net/wireguard/generated/netlink.h  |  30 +++
 drivers/net/wireguard/netlink.c            |  67 +----
 include/uapi/linux/wireguard.h             | 191 +++----------
 tools/net/ynl/Makefile.deps                |   2 +
 tools/net/ynl/samples/.gitignore           |   1 +
 tools/net/ynl/samples/wireguard.c          | 104 +++++++
 10 files changed, 556 insertions(+), 214 deletions(-)
 create mode 100644 Documentation/netlink/specs/wireguard.yaml
 create mode 100644 drivers/net/wireguard/generated/netlink.c
 create mode 100644 drivers/net/wireguard/generated/netlink.h
 create mode 100644 tools/net/ynl/samples/wireguard.c

-- 
2.51.0

Re: [PATCH wireguard v4 00/10] wireguard: netlink: ynl conversion
Posted by Jason A. Donenfeld 5 days, 4 hours ago
Hi Asbjorn,

Thank you for this! I've merged this to the wireguard devel tree, and
I'll send this up to net-next after letting it cook there for a little
while.

I really appreciate all the work you've put into this and the large
amounts of feedback you've incorporated.

Jason