Commit Graph

655 Commits

Author SHA1 Message Date
Linus Torvalds
47439bb163 NFSD 7.4 Release Notes
Jeff Layton extended the netlink listener-set operation so that a
 management daemon can register NFSD's programs with rpcbind itself.
 This prevents an unresponsive rpcbind from stalling NFSD adminis-
 tration for a minute at a time.
 
 Bulk delegation recall now adjusts the number of delegations it
 wants returned, based on memory pressure. The previous mechanism
 was spec-conformant, but it requested all delegations to be
 returned at once. Clients are free to return few or none in such
 cases, but requesting smaller batches of delegations is more
 neighborly.
 
 In preparation for handling TLS KeyUpdate, the server's TCP receive
 path has been reworked to handle control records. In the process,
 the use of sock_recvmsg was replaced with ->read_sock, which contends
 less with other holders of the socket lock.
 
 NFSv2 XDR code is now generated by xdrgen, which mechanically
 generates the encoders and decoders from the RPC language
 specification for the protocol. Replacing hand-built XDR code
 makes prototyping new protocol elements faster, reduces errors, and
 improves memory safety. Replacement of XDR code for newer NFS
 versions will continue in subsequent releases of NFSD.
 
 The remaining bulk of changes in v7.4 is bug fixes, clean-ups, and
 small optimizations. Sincere thanks to all contributors, reviewers,
 testers, and bug reporters who participated in the v7.4 NFSD
 development cycle.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEKLLlsBKG3yQ88j7+M2qzM29mf5cFAmrWH4UACgkQM2qzM29m
 f5fXERAAh9q+yWcSAFxYC4KcG08QEFZcTCXre0C0/EhjQI0KEJBv+8yd3ffUZrfM
 157ZuQeFFiTMnAqpW2nf3odhOC8B9OZj8JV+D1Ov7de5r/S0F7Aqg7NDjDzVdQg1
 PFKElow/3jgECNiU5eQhKJQoJ2PTQmO74JeoZ2KTqM/JrGzzSXaqcp03+93GJoaK
 XUsjN6mJB4P4s27SqCJlf+ouALHtvULOul4rzYIIvI445oIt5Gz3CgsIvoTBU4cj
 qOoToVFvlx6CQnohuGcR+H+HmG1+d4ygwhHL+4XkJTtLwbNPa+31FrRNLy+P5OXz
 QM9iots9X2UIl09StUsmSUfQNztCr+SWNu1l1kJOO+OQam1xFvqri8p6BxKUC5YM
 JZvn6QRvbmLPh3CzLyOQdhzqbYSENZsfob20Sd9C2V7d6V+D/95AB3pnxwwakvZ8
 5WBoo358cA7dJBIpYQ22jkQzyYzt5cNrWCBemDF/OOLauR9UZnLTgo9+q7VNYWu/
 nvRZ8Bkg0mPYWKmduJLeVVbOFwIr5zbfpGPInatdqiWyl5SWFeYK+vvgnbEnRNqt
 iMHDB6MNw7ItAb+jCgFteMVtx4w6umJLLcwzhiewqgGkmMZ8gwxBuu2BSgtkbfQW
 ZqEZSVHlYY1H0YkWM/p8YdyMs0nA5I9mCcxDc+rC2cMCMlYUULM=
 =AQBo
 -----END PGP SIGNATURE-----

Merge tag 'nfsd-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux

Pull nfsd updates from Chuck Lever:
 "Jeff Layton extended the netlink listener-set operation so that
  a management daemon can register NFSD's programs with rpcbind
  itself. This prevents an unresponsive rpcbind from stalling NFSD
  administration for a minute at a time.

  Bulk delegation recall now adjusts the number of delegations it
  wants returned, based on memory pressure. The previous mechanism
  was spec-conformant, but it requested all delegations to be
  returned at once. Clients are free to return few or none in such
  cases, but requesting smaller batches of delegations is more
  neighborly.

  In preparation for handling TLS KeyUpdate, the server's TCP
  receive path has been reworked to handle control records. In the
  process, the use of sock_recvmsg was replaced with ->read_sock,
  which contends less with other holders of the socket lock.

  NFSv2 XDR code is now generated by xdrgen, which mechanically
  generates the encoders and decoders from the RPC language
  specification for the protocol. Replacing hand-built XDR code
  makes prototyping new protocol elements faster, reduces errors,
  and improves memory safety. Replacement of XDR code for newer NFS
  versions will continue in subsequent releases of NFSD.

  The remaining bulk of changes in v7.4 is bug fixes, clean-ups, and
  small optimizations. Sincere thanks to all contributors,
  reviewers, testers, and bug reporters who participated in the v7.4
  NFSD development cycle"

* tag 'nfsd-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (184 commits)
  SUNRPC: use assign_bit() where applicable
  nfsd: Fix id-to-name cache entry leak in idtoname_parse()
  NFSD: Use xdrgen XDR functions for NFSv2 READDIR results
  NFSD: Refactor NFSv2 directory cookie encoding
  NFSD: Add a streaming directory reader
  NFSD: Use xdrgen XDR functions for NFSv2 READDIR arguments
  NFSD: Use xdrgen XDR functions for the NFSv2 STATFS procedure
  NFSD: Use xdrgen XDR functions for NFSv2 RMDIR procedure
  NFSD: Use xdrgen XDR functions for NFSv2 MKDIR procedure
  NFSD: Use xdrgen XDR functions for NFSv2 SYMLINK procedure
  NFSD: Use xdrgen XDR functions for the NFSv2 LINK procedure
  NFSD: Use xdrgen XDR functions for the NFSv2 RENAME procedure
  NFSD: Use xdrgen XDR functions for the NFSv2 REMOVE procedure
  NFSD: Use xdrgen XDR functions for NFSv2 CREATE procedure
  NFSD: Refactor nfsd_proc_create()
  NFSD: Use xdrgen XDR functions for NFSv2 WRITE procedure
  NFSD: Use xdrgen XDR functions for the NFSv2 WRITECACHE procedure
  NFSD: Use xdrgen XDR functions for NFSv2 READ procedure
  NFSD: Use xdrgen XDR functions for NFSv2 READLINK procedure
  NFSD: Use xdrgen XDR functions for the NFSv2 LOOKUP procedure
  ...
2026-10-25 15:12:41 -10:00
Anil Kaushik
8a2f9964fc netlink: specs: add genetlink-legacy spec for GTP
The GTP (GPRS Tunnelling Protocol, user plane) generic netlink family
has no YAML specification under Documentation/netlink/specs/, so it
cannot be consumed by the ynl tooling used for user-space clients,
documentation and selftests.

Add a genetlink-legacy spec describing the existing family: the PDP
context management commands (NEWPDP, DELPDP, GETPDP) and the GTP-U echo
request (ECHOREQ), the GTPA_* attribute set, and the "gtp" multicast
group. Command and attribute values are taken from
include/uapi/linux/gtp.h and match it one-to-one. The request
attributes of each command are the ones its handler in
drivers/net/gtp.c reads, and the reply attributes the ones
gtp_genl_fill_info() emits.

The notifications sent on the "gtp" group are not described: they reuse
the command values of the NEWPDP, DELPDP and ECHOREQ requests, which
the ynl code generator cannot express with the existing uapi header.
The family doc says so.

Add the matching CFLAGS_gtp entry to tools/net/ynl/Makefile.deps, so
the generated code is built against the tree's gtp.h instead of an
older one installed on the host.

This only adds the description; there is no kernel code or uapi change.

Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
Link: https://patch.msgid.link/20261016093225.1036375-4-anilkaushikwireless@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-10-21 11:37:08 +02:00
Demos Ra
457dc9fefe netlink: specs: Add a spec for nexthops in rtnetlink
Add a YNL spec for nexthop objects and nexthop buckets in rtnetlink.

./tools/net/ynl/pyynl/cli.py \
    --spec Documentation/netlink/specs/rt-nexthop.yaml \
    --dump getnexthop

Exclude newnexthopbucket-ntf from the C code generation. ynl_gen_c.py
looks up a classic notification by the request of the same message
type, and no request uses RTM_NEWNEXTHOPBUCKET. The spec keeps the
notification, so the Python tools can still subscribe to it.

Signed-off-by: Demos Ra <demosthenes.ra@gmail.com>
Link: https://patch.msgid.link/20261019-rt-nexthop-spec-v1-1-9c586edf86ab@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-20 19:40:16 -07:00
Hangbin Liu
24d11a5586 netlink: specs: rt-route: add lwtunnel encap sub-message support
Define encap-type enum (LWTUNNEL_ENCAP_*) and add encap-data sub-message
keyed by encap-type. Add tunnel attribute sets (mpls, ip, ila, ip6, seg6,
bpf, seg6-local, rpl, ioam6, xfrm). This spec update depends on the kernel
side encap-type/data reorder patch.

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>
Link: https://patch.msgid.link/20261008-ynl_rt_encap-v4-3-4ed2ccf7f949@kylinos.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-15 16:59:58 -07:00
Hangbin Liu
05d3030eff tools: ynl: convert enum selector to string for sub-message parsing
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 the change, if there is no encap_type (e.g. previous ordering on
older kernels), or a new encap_type is missing from the spec file in
future kernel, the code will report "Sub-message key not set", the same
with string lookup fails. With the subsequent rt-route encap spec update,
the newly generated code will look like:

	if (!dst->_present.encap_type)
		return ynl_submsg_failed(yarg, "encap", "encap-type");
	encap_type_str = rt_route_encap_type_str(dst->encap_type);
	if (!encap_type_str)
		return ynl_submsg_failed(yarg, "encap", "enum-lookup-failed");
	if (rt_route_encap_data_parse(&parg, encap_type_str, attr))
		return YNL_PARSE_CB_ERROR;

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20261008-ynl_rt_encap-v4-2-4ed2ccf7f949@kylinos.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-15 16:59:58 -07:00
Chuck Lever
a11fb8f725 xdrgen: Update the aggregate_members comment for optional-data lists
check_aggregate_directives() records an optional-data list member
in aggregate_members alongside a variable-length array member, but
the comment on the set still describes only the array form.

Name both member forms.

Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
e44471d1d0 xdrgen: Document that aggregate members of a struct share an element type
check_aggregate_directives() rejects a second marked member whose
element type differs from the first, because one hook set serves
every marked member of a struct and its item hook takes a single
element type. The README says the members share a hook set but
never states the restriction that follows from it, so a spec
author learns of it only from the diagnostic.

State the restriction where the shared hook set is described.

Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
f10ffc2433 xdrgen: Report unsupported client-side directives without a traceback
The struct and union emitters raise NotImplementedError when a
"pragma pages" or "pragma aggregate" member is generated for the
client peer. The source subcommand catches the parse and semantic
errors but not that one, so a client generation request for such a
specification emits partial output and then a Python traceback,
which buries the one line that says what is unsupported.

Catch the exception in the source subcommand and report its message
on stderr the way the other diagnostics are reported.

Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
aa41b1bc75 xdrgen: Reject a "pragma pages" union arm declared as an opaque
check_pages_directives() rejects a union arm declared directly as
a string, with a diagnostic pointing at the directive, but accepts
one declared directly as a variable-length opaque. The union
generator has no arm representation for a direct opaque, so
generation fails with an AttributeError from
emit_union_case_spec_definition() instead. A direct opaque arm was
never generated correctly, marked or not, but the pages validation
exists to report such a directive at its source position.

Extend the union-arm check to a direct variable-length opaque, so
both forms draw the same diagnostic.

Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
1e7f9d30d5 xdrgen: Stream optional-data aggregate lists during encode
The optional-data aggregate encoder loops cursor.count times, so the
begin hook must report the element count before the first element is
written.  A producer that reads its elements while the reply is
encoded -- NFSv2 READDIR streaming directory entries straight into the
send buffer -- does not know that count in advance, and would have to
materialize the whole list just to satisfy the loop bound.

An optional-data list carries no count on the wire, so nothing forces
one on the encoder.  Drive it from the item hook instead: a false
return ends the list, and the framing writes the terminator.

The counted-array form and its hook contract are unchanged.  No
in-tree spec marks an optional-data member yet, so no generated code
changes here.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260908134234.512312-11-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
9ebc61dfe9 xdrgen: Extend the aggregate codec to optional-data list members
The hook-driven aggregate codec emits only the counted-array wire
form. XDR list types built on the optional-data idiom ("type *name")
carry no count and cannot be expressed that way. NFSv2 READDIR's
entry list is one such type.

Accept an optional-data member under "pragma aggregate" and emit
value-follows framing in place of the counted array. The element
type's existing single-node encoder already writes its own
value-follows boolean, so the loop calls it once per element and
once more with a NULL element to write the terminator. The struct C
definitions are untouched; only the marked member's framing changes.

The generated decoder fails outright. Decoding a value-follows list
needs a presence-reporting element decoder, which this change does
not add, and a decoder that consumed nothing would leave the stream
at the list data for the next member to misread. NFSv2 READDIR only
encodes its entry list, so the decode path is never exercised.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260908134234.512312-10-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
2f5c8429a9 xdrgen: Add hook-driven aggregate codec for variable-length arrays
A generated variable-length array codec stages the wire array
as a C array and walks it. When the in-kernel object is not that
array, building that array is wasted memory traffic. The NFS_ACLv2
secattr aclent<> list is one such case: it is a Solaris wire form of
the kernel's posix_acl. The hand-rolled codec that performs that
transform forces its containing types to keep external linkage
(pragma public), and that linkage collides at link time with the
same generated types in a sibling program.

Add a per-member "pragma aggregate <struct> <member>" directive. For
a marked member the generated code owns only the wire framing and
calls hand-written begin, item, and end hooks that handle one
element at a time. Interior codec signatures do not change.

The framing-owned loop follows xdr_encode_array2(), whose only
remaining user is fs/nfs_common/nfsacl.c, and seq_file's
start/show/stop, where a guaranteed stop() releases what start()
took. Those APIs take an ops vtable because one loop serves
consumers chosen at run time. Here the consumer is known at
generation time, so the hooks bind by name at link time, as the
ASN.1 compiler's actions do. A missing hook is a link error, the
emitted prototypes enforce the element type, and no indirect call
is added per element.

The item hooks return only success or failure, with no early "no
more elements" return, so that the same hook contract can later
frame the RFC 4506 optional-data idiom, where the application
pushes entries into generated framing.

The front end resolves each marker against the specification and
reports one it cannot honor against its own source position, rather
than degrading silently to the array-walking codec or surfacing as a
traceback from whichever emitter reached it. Absent the marker the
generator emits byte-identical output.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260908134234.512312-9-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
08989c3e55 xdrgen: Extend the pages directive to page-resident arguments
The pages directive so far drives only the encoder. A bulk argument
such as the payload of an NFS WRITE arrives in the pages of the
server's Receive buffer, but the generated opaque decoder copies it
into a contiguous data pointer. The copy wastes memory bandwidth and
forces the containing procedure decoder to be hand-rolled.

Let the directive drive the decoder as well. Whether a marked member
is decoded in place or encoded by reference follows from whether its
containing type is reachable from an RPC procedure argument. Record
that set during parsing, then close it over nested aggregates and
typedef aliases before the directives are checked. A decoded
page-resident member is represented as a struct xdr_buf so that the
payload can be handed on without a copy. A marked union arm of an
argument type is rejected, since the union generator still emits
only the copying decoder. A marked type reachable from both an
argument and a result is rejected as well: the two representations
differ, and a type carries only one.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260908134234.512312-8-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
9ac56a0573 xdrgen: Add a "pragma pages" directive
The generated encoder for a variable-length opaque or string
member copies its content into the Reply buffer via
xdr_stream_encode_opaque(). A bulk payload such as an NFS READ
result never resides at the member's data pointer: the server
deposits it directly in the pages of the Reply buffer. Until now
the containing procedure encoder had to be hand-rolled.

Add a per-member directive that makes the emitted encoder call
svcxdr_encode_opaque_payload() for the marked member. The README
documents its syntax and the members it may name. Beyond the
struct and union cases described there, the directive also applies
to a member of a self-referential struct, which xdrgen generates
as an XDR pointer type.

A directive that binds to nothing would degrade silently to the
copying encoder, so the front end rejects one that names an
undeclared type or member, or a member that cannot carry a
payload. It also rejects a second marked member of the same type,
and a type whose members reach more than one marked member:
svcxdr_encode_opaque_payload() consumes the whole page vector and
moves the stream into the tail, so one encoder carries at most one
payload. An array of a marked type counts as reaching it more than
once, since the array encoder emits the element once per entry.

Generated code is unchanged until a specification applies the
directive.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260908134234.512312-6-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Chuck Lever
d61e221c61 xdrgen: Pass the containing struct name to member codec emitters
A per-member code generation directive keyed on the (struct, member)
pair needs the name of the containing struct, but
emit_struct_member_encoder() and emit_struct_member_decoder()
receive only the member declaration.

Pass the containing struct's name to emit_struct_member_encoder() and
emit_struct_member_decoder(), and to the matching emitters in
pointer.py, as a required argument. A struct whose last field refers
to its own type is an _XdrPointer rather than an _XdrStruct, so
pointer.py takes the same argument. No emitter renders the new value
yet, so generated output is byte-identical. A subsequent patch keys
the "pragma pages" encoder on it.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260908134234.512312-5-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-10-04 21:15:29 -04:00
Jakub Kicinski
c20d84c6de tools: ynl-gen-c: keep the type values of a nest in spec order
Family._load_nested_set_nest() collects the type-value names of a
nest-type-value attribute into a set and Struct.set_inherited() renders
them sorted, while TypeNestTypeValue._attr_get() passes them to the
parse helper in the order the spec lists them.  For nlctrl's

  type-value: [policy-id, attr-id]

that makes the generated helper take (attr_id, policy_id) and the caller
pass (policy_id, attr_id).  Both are __u32 so nothing complains, and
every C YNL user of the nlctrl policy dump gets the two swapped.

Two attributes nesting the same attribute set with the type values in
a different order now fail set_inherited() instead of comparing equal.
No spec does that today, but better safe than sorry.

Nesting an attribute set which is also used as a sub-message gets its own
check: it used to be caught by the list-versus-set type mismatch, which
the ordering fix removes, and without it the generator emits a call
to the sub-message parser with the selector argument missing.
Again, no spec does this today.

nlctrl is the only spec affected, discovered by an LLM scan of the spec.

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20260924223245.530132-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 18:12:06 -07:00
Jakub Kicinski
b785f5c56f netlink: policy: report the big endian attributes
Paolo pointed out an issue flagged at low priority by Sashiko -
we're currently not handling BE{16,32} attributes in policy dumps.

Commit 3f4285d741 ("netlink: specs: fou: local-v4 and peer-v4 are big
endian") flipped two fou attributes from NLA_U32 to NLA_BE32.
This made them vanish from the policy dump.

Follow the YAML spec format and treat byte order as a property of
a u16 / u32 rather than a type of its own. I don't have a strong
preference either way. The YNL format "feels cleaner" but the
kernel's separate type is easier when handling decoding.
I don't think that the policy type is actually usable for decoding
(since it only contains input types) so I went with YNL and added
the separate attr.

A missing byte order means host order, again like in the YAML specs.

Link: https://lore.kernel.org/ab90f970-0ebb-4c07-b7b1-db3f91395116@redhat.com
Link: https://patch.msgid.link/20260912202401.141336-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-15 16:49:32 -07:00
Maxime Chevallier (Netdev Foundation)
c0bb05f2d1 tools: ynl: Fix out-of-tree build for ynltool
After the blamed commit, running a out-of-tree build for ynltool fails :

  # make -C tools/net/ynl/ynltool O=/tmp/o1
  make: Entering directory 'tools/net/ynl/ynltool'
  make: *** No rule to make target '/tmp/o1/json_writer.o', needed by '/tmp/o1/ynltool'.  Stop.

ynltool's Makefile correctly accounts for $(OUTPUT) to get the list of
object files to generate :

OBJS := $(patsubst %.c,$(OUTPUT)%.o,$(SRCS))

but it never actually set $(OUTPUT) before the blamed commit, meaning
that out-of-tree buils of ynltool were always actually in-tree.

Now, the O= parameter is correctly accounted for, and the %o: %c rule fails.

Let's update the %o: %c rule to also use $(OUTPUT), as well as the .d
file expansion so that any header change is taken into account.

Reported-by: Bobby Eshleman <bobbyeshleman@gmail.com>
Closes: https://lore.kernel.org/all/aqCyWQxqKDuQnZYR@devvm29614.prn0.facebook.com/
Fixes: 917f713b4e ("tools: ynl: Allow cross-compiling ynl and associated tools")
Signed-off-by: Maxime Chevallier (Netdev Foundation) <maxime.chevallier@bootlin.com>
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20260911164135.1428140-1-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-14 17:09:18 -07:00
Maxime Chevallier (Netdev Foundation)
917f713b4e tools: ynl: Allow cross-compiling ynl and associated tools
The ynl tool and libraries may be built standalone or through the
drivers/net/hw selftest machinery. This may target a different arch, so
we need to take the CROSS_COMPILE variable into account for LLVM and
gcc.

Let's include the tools/scripts/Makefile.include that deals with the
CC/AR resolution.

Fixup the ynltool CFLAGS handling to use +=, so that we don't override
the ones set in Makefile.include.

Makefile.include also sets the Q variable for verbose mode, so we can
drop it from the ynltool Makefile. This will allow properly selection
the verbosity of ynltool builds with the V=1 make flag.

Reviewed-by: Matthieu Baerts (Netdev Foundation) <matttbe@kernel.org>
Signed-off-by: Maxime Chevallier (Netdev Foundation) <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260907161438.755125-2-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-08 17:26:52 -07:00
Linus Torvalds
1b78070aae Including fixes from Bluetooth, IPSec and Netfilter.
Current release - fix to a fix:
 
  - netfilter: ipset: remove need to allocate memory on delete operations
 
 Current release - regressions:
 
  - macb: drop CONFIG_OF #if block, fix build
 
 Previous releases - always broken:
 
  - stream of fixes for SCTP continues
 
  - inet: frags: strip GSO state from fragments before reassembly
 
  - virtio-net: ensure that TCP packets don't overflow gso_segs
 
  - tcp-ao: fix use-after-free of current_key on reconnect to another peer
 
  - page_pool: remove zone/policy GFP flags when allocating XArray entries
 
  - Bluetooth: L2CAP: reject accept queue add unless BT_LISTEN
 
  - tls: device: fix out-of-bounds write in tls_append_frag()
 
  - eth: bnxt:
    - ring the doorbell when SW USO exits early, avoid packets stuck in Tx
    - gate TPH enablement behind BNXT_SUPPORTS_QUEUE_API check, avoid users
      of older NICs seeing non-actionable warning messages
 
  - eth: qede: fix NULL pointer dereference in TPA fragment processing
 
 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE6jPA+I1ugmIBA4hXMUZtbf5SIrsFAmqQojwACgkQMUZtbf5S
 Irv2kg//anC58qIya/Tx3BZkpPgtbS+ki0bqb+J0a8axbItgSGEdclVtiLJn/ex0
 zz9AR4Pt2DSbSUHPa7nRpdMQ2x7ZmNwNR2zqs1xClgOm5QD/2JAc53Pv81GaEKa4
 O4A4TDJZfyTDsk6c0cjI3yz9uMqBt2U6pyAT6JMBIPy7/MgV+as0ETAWQlezL0sF
 ZnXVg9tM3hG/8a3M88+/S1VODVJYLMucXS6pD1mqlry01SUj91elEXKiac5vCaHI
 DAZaiCOmv4WV3hs7941VijPchLO64L0J+0qjGRpXiPJXQEAn4XU8QX/YNc1njgZH
 tmjRWEEtLoBFcLRDUPAK9niuB5F9N3/6nnydLPLu16+exKQuCB8Bh78YHLmlrJIW
 utY5ek7GtPOl31M9a5TdEGLUg5wPHSO62FhiBmTiIG4PKQym616TmOHbYJWBqFry
 EPNtZ1vEJoPFNOsT1VdeD4DKVBq2UDnj/3fnphUhfvU5z+dEDdIn03+kQykwmVQT
 kTuMaW4/zxR3VFjHalsI+4bvhFOEmu+/KZE07aKKm99jssDsewQHGXgYJkCPWQUk
 gpnN8IVNw16ex9sfrvqje6/tshiPJJn9y/b/nGt5mq9ofgwXGmpzCPwcDgyzZKQ5
 y+zVPJ0/XILHAHOBxdCklim5xiaPDYKdEI+zcEXrx/g6FraZZuI=
 =1DXR
 -----END PGP SIGNATURE-----

Merge tag 'net-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Jakub Kicinski:
 "Including fixes from Bluetooth, IPSec and Netfilter.

  Current release - fix to a fix:

   - netfilter: ipset: remove need to allocate memory on delete operations

  Current release - regressions:

   - macb: drop CONFIG_OF #if block, fix build

  Previous releases - always broken:

   - stream of fixes for SCTP continues

   - inet: frags: strip GSO state from fragments before reassembly

   - virtio-net: ensure that TCP packets don't overflow gso_segs

   - tcp-ao: fix use-after-free of current_key on reconnect to another
     peer

   - page_pool: remove zone/policy GFP flags when allocating XArray
     entries

   - Bluetooth: L2CAP: reject accept queue add unless BT_LISTEN

   - tls: device: fix out-of-bounds write in tls_append_frag()

   - eth: bnxt:
      - ring the doorbell when SW USO exits early, avoid packets stuck
        in Tx
      - gate TPH enablement behind BNXT_SUPPORTS_QUEUE_API check, avoid
        users of older NICs seeing non-actionable warning messages

   - eth: qede: fix NULL pointer dereference in TPA fragment processing"

* tag 'net-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (216 commits)
  inet: frags: strip GSO state from fragments before reassembly
  net/sched: sch_htb: limit htb_classify inner-class filter hops
  selftests/net: packetdrill: add tcp_urg_ptr_retransmit
  tcp: fix corruption of urgent data on multi-segment retransmit
  usb: atm: usbatm: fix invalid ci_range initialization
  net: fec: only stop PTP if it was initialized
  slip: remove slip_hangup() to fix use-after-free in slip_receive_buf()
  net: bridge: mcast: fix use-after-free of a master VLAN's multicast context
  net/sched: bound qdisc_pkt_len to prevent qdisc soft lockup
  net: dsa: mxl862xx: enable assisted learning on CPU port
  net: stmmac: restore NET_IP_ALIGN in the RX DMA offset
  net: stmmac: drop gso_enabled_types and rely on netdev features
  net: stmmac: selftests: Don't test flow control for small rx fifos
  net: stmmac: selftests: Account for the UC filter list for filtering tests
  net: stmmac: dwxgmac: Account for the primary MAC address for UC filtering
  net: stmmac: dwmac4: Account for the primary MAC address for UC filtering
  net: stmmac: dwmac1000: Account for the primary MAC address for UC filtering
  net: stmmac: selftests: Check multiple MMC counters
  selftests: net: Fix slow configurations in big_tcp_tunnels.sh
  selftests: net: Lower threshold with csum offload off in big_tcp_tunnels.sh
  ...
2026-08-27 13:53:43 -07:00
Triet Hoang
25b863cd6d tools: ynl: handle calloc failure in ynl_ntf_parse
Check the return value of calloc() before dereferencing the allocated
response structure in ynl_ntf_parse().

Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com>
Link: https://patch.msgid.link/20260818132739.469624-1-triet.hoang.dev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-20 13:29:36 -07:00
Linus Torvalds
d141ec2825 NFSD 7.3 Release Notes
Jeff Layton contributed CB_NOTIFY support to NFSD's NFSv4.1
 directory delegations. The server used to recall a delegation as
 soon as the directory changed. NFSD now watches delegated
 directories through fsnotify and reports adds, removes, renames,
 and directory attribute changes, carrying the filehandle and
 attributes of the affected entry, so clients can keep their
 caches. Some of the NOTIFY4 flags come from RFC 8881bis.
 
 Jeff Layton also continued the netlink work that started in v7.2.
 A new server-stats-get operation reports what /proc/net/rpc/nfsd
 publishes, plus NFSv4 callback counts, and SUNRPC now keeps its
 per-procedure call counts per network namespace, so a container
 sees its own numbers. nfsstat reads all of this over netlink, with
 a procfs fallback for older kernels.
 
 SUNRPC's service thread pool mode selection is gone. Pernode is
 the right choice on any host we run today, so the auto, global,
 and percpu modes have been removed. A single-node host still gets
 one pool. A multi-NUMA host now gets a pool per node.
 sunrpc.pool_mode accepts the old names but no longer selects
 anything.
 
 The rest is bug fixes, clean-ups, and small optimizations: an
 async COPY offload rework from Jeff Layton, more use-after-free
 fixes in the NFSv4 state revocation paths, percpu counter
 contention removed from the reply cache and IO accounting, and a
 long list of hardening fixes from Chris Mason. Sincere thanks to
 all contributors, reviewers, testers, and bug reporters who
 participated in the v7.3 NFSD development cycle.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEKLLlsBKG3yQ88j7+M2qzM29mf5cFAmqDDs4ACgkQM2qzM29m
 f5eUTQ/+NgtZZ93ssYPbu5vW1lnxI0zVMPwBw+jvdF4YShaLUTVD3AYN/wOn2n2v
 Y0ULB2QOyz5zXq+9e9sL/zWJNPsGucx4G4pfcXzn96e3zPkZPChaJUKRQd347kPc
 gkaExMxQBwqU7xDIaBF+g1vh4pogORfhc4xi0zE0j4kqiYJOQCJIUg33SNLrqeSa
 DG7IbTuS+nvFBalbUQiWaL7DMxO2N2JlYbpU15kzBuJ8GLK7I3kPPTDGKEbEaUuF
 m8krI6Drdrwb1puiZnjUO+OHvalC5JzKcLkHG9Ps1KlUgfYDZ546waPIcpCT0KjM
 JFG3Avg2Zu9o+cz1AZB9Kq7epPQgHzNea3h48DOLvJP9r97cvObkg2ZocMzlHe0/
 yy2qRCBpX41MWDgckB6hCVP1l/l0u7EatpXxMtdBm4Jnv6a6Em39RLX4MzFVcJ5t
 cYROdLEAfwblIeJyOJm197LjjhKb7minPWRWaYwnGMe05VXUXSh7MZI/Rw7NkJev
 P8p+bt1CEv1pEM0ArrDmcjPvsX2JJXMsspHovf/ymbTYLdDf9I/7NFLE/Jc6c9BT
 h9/oMBcw7lumlB5aq3L/NOlXQmjtoGTQVjyMrKDwtRQXjQgFo8gaB5nXSIlB4ik+
 DFz2ajp+F07VATS89Dc2m7ALO08pdNwzn4p8jq/IKnqlGWlxNIE=
 =g1IS
 -----END PGP SIGNATURE-----

Merge tag 'nfsd-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux

Pull nfsd updates from Chuck Lever:

 - CB_NOTIFY support for NFSD's NFSv4.1 directory delegations

   The server used to recall a delegation as soon as the directory
   changed. NFSD now watches delegated directories through fsnotify and
   reports adds, removes, renames, and directory attribute changes,
   carrying the filehandle and attributes of the affected entry, so
   clients can keep their caches. Some of the NOTIFY4 flags come from
   RFC 8881bis (Jeff Layton)

 - Continued netlink work

   A new server-stats-get operation reports what /proc/net/rpc/nfsd
   publishes, plus NFSv4 callback counts, and SUNRPC now keeps its
   per-procedure call counts per network namespace, so a container sees
   its own numbers. nfsstat reads all of this over netlink, with a
   procfs fallback for older kernels (Jeff Layton)

 - Remove SUNRPC service thread pool mode selection

   Per node is the right choice on any host we run today, so the auto,
   global, and percpu modes have been removed. A single-node host still
   gets one pool. A multi-NUMA host now gets a pool per node.

   sunrpc.pool_mode accepts the old names but no longer selects
   anything.

 - Bug fixes, clean-ups, and small optimizations:
    - async COPY offload rework (Jeff Layton)
    - more use-after-free fixes in the NFSv4 state revocation paths
    - percpu counter contention removed from the reply cache and IO
      accounting
    - a long list of hardening fixes (Chris Mason)

Sincere thanks to all contributors, reviewers, testers, and bug
reporters who participated in the v7.3 NFSD development cycle.

* tag 'nfsd-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (182 commits)
  nfsd: export NFSv4 callback op stats via netlink
  nfsd: count NFSv4 callback operations per netns
  sunrpc: remove unused svc_version vs_count field
  nfsd: implement server-stats-get netlink handler
  sunrpc: use per-net counts in svc_seq_show()
  sunrpc: add per-netns per-procedure call counts to svc_stat
  NFSD: Document reply_cache_stats ABI
  NFSD: Eliminate percpu counter contention in IO byte accounting
  NFSD: Eliminate percpu counter contention in reply cache statistics
  NFSD: Eliminate percpu counter contention in DRC memory accounting
  NFSD: Fix off-by-one in DRC bucket pruning limit
  NFSD: Relocate NFSv4 "supported attributes" to new header
  NFSD: Relocate nfsd4_set_netaddr()
  NFSD: Relocate nfsd_user_namespace()
  NFSD: Move struct readdir_cd
  NFSD: Move the export.h include from nfsd.h to auth.c
  NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h
  NFSD: include "netns.h"
  NFSD: Explicitly include "stats.h"
  NFSD: Make "stats.h" self-contained
  ...
2026-08-20 12:39:56 -07:00
Thaison Phan
153f709c86 tools: ynl: check alloc fails in generated getter code
Generated YNL getter code does not check the return value of malloc() and
calloc() before passing the resulting pointer to memcpy(). This could lead
to a NULL pointer dereference on memory allocation failure.

Updated the C code generator to check for allocation failures and to return
an error code in getters.

Signed-off-by: Thaison Phan <thaisonphan@google.com>
Link: https://patch.msgid.link/20260807171500.7188-3-thaisonphan@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-10 18:23:11 -07:00
Thaison Phan
7c62c481bb tools: ynl: check for null ptr on dump free
Static analysis detected code paths where freeing a dump list after early
errors when creating the corresponding dump list like in ynl_exec_dump()
can result in a null pointer dereference since the first node in the
ynl_dump_state would still be zero initialized. To prevent this potential
problem updated the ynl c generation script to check for a NULL pointer
before continuing to free the nodes in a dump list.

Signed-off-by: Thaison Phan <thaisonphan@google.com>
Link: https://patch.msgid.link/20260807171500.7188-2-thaisonphan@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-10 18:23:11 -07:00
Chuck Lever
1663ea5b24 xdrgen: Reject out-of-range program, version, and procedure numbers
RFC 5531 assigns only unsigned constants to program, version, and
procedure numbers (Section 12.3) and encodes each as an unsigned
32-bit integer (Section 9), so a valid number falls within
[0, 2**32 - 1]. RFC 4506 Section 6.2 permits a signed decimal constant
for XDR constants in general and sets no ceiling on magnitude, so the
grammar accepts an out-of-range value without complaint. It reaches
generated code -- a negative procedure number emerges as an enumerator
such as "FOO = -5", valid C that compiles cleanly even though the wire
field is an unsigned 32-bit integer. Thus the xdrgen front end is the
only place that can reject the malformed value.

Extend the semantic checks to require each program, version, and
procedure number to fall within [0, 2**32 - 1].

Link: https://patch.msgid.link/20260712203451.124902-6-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
69b89515b1 xdrgen: Enforce RFC 5531 name and number scoping for RPC programs
The duplicate-identifier check enforces the RFC 4506 name space
for XDR type and constant identifiers but ignores what an RPC
program definition adds. RFC 5531 Section 12.3 completes the
model: a program identifier shares the specification-wide name
space with constant and type identifiers, a version name and
number are unique within their program, and a procedure name and
number are unique within their version.

xdrgen currently accepts a specification that breaks any of these
rules, and the symptom depends on which rule. A duplicate procedure
name reaches the generated header as a redeclared enumerator,
which the C compiler rejects. A duplicate procedure number is
more dangerous because it is silent: the two procedures emit
enumerators of equal value -- valid C that compiles cleanly --
leaving a dispatch collision to surface only at run time. A
duplicate program name shares the specification-wide name space
with constants and types and is caught alongside them.

Extend the check to enforce RFC 5531 scoping in full.

Link: https://patch.msgid.link/20260712203451.124902-5-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
b75e1a256d xdrgen: Reject specifications that define a name twice
When an RPC specification defines the same type or constant name
more than once, currently xdrgen emits every definition without
complaint. The duplication surfaces later as a C compiler error
about a redefined struct or function that points at generated code
instead of the actual offending line in the .x source.

RFC 4506 Section 6.4 places constant and type identifiers in a
single name space that must be unique within a specification. Add
a semantic check that enforces this rule.

Link: https://patch.msgid.link/20260712203451.124902-4-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
e1391920c6 xdrgen: Record the source position of each declared identifier
In preparation for semantic checks that reject a malformed
specification, record where each declared identifier appears in the
source so a diagnostic can point at the name in error.

The transformer keeps each identifier's spelling but discards its
position, retaining only the position of the enclosing definition.
A caret built from that position falls on the definition keyword
rather than on the identifier, because the definition production
begins at the keyword.

Store the identifier's own line and column on every named
construct: constants, enumerated types and their enumerators,
structs, unions, pointers, typedef declarations, and RPC program,
version, and procedure names. The fields live on the AST base node
and are keyword-only, so lark's positional construction of each
node is unaffected; a construct whose position is not recorded
leaves them zero.

Link: https://patch.msgid.link/20260712203451.124902-3-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
883fe9a7ac xdrgen: Align the error caret under tab-indented source
When xdrgen reports a parse or transform error, it prints the
offending source line followed by a caret marking the column. The
source line is emitted with its tab characters intact, but the caret
offset is computed from a tab-expanded copy of the text ahead of the
column. A terminal expands the line's leading tabs relative to the
four-space output indent, while the caret math expands the same tabs
from column zero, so the two disagree whenever the line is indented
with tabs and the caret lands past the token it should mark.

Render the displayed line with its tabs already expanded so the line
and the caret share one tab origin and the four-space indent cancels.
Fold the now-identical line-and-caret formatting out of both error
handlers into a single helper, so every caller reports the same
aligned output.

Link: https://patch.msgid.link/20260712203451.124902-2-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
daa52e3785 xdrgen: Fix opaque and string encoders for unbounded members
The variable-length opaque and string encoder templates emit an
unconditional bound check, "if (value->NAME.len > MAXSIZE) return
false". XDR represents an unbounded specifier (opaque foo<>, string
foo<>) as a maxsize of 0, so for an unbounded member the check
degenerates to "len > 0" and the generated encoder refuses every
non-empty value.

The decoder does not share this defect. It delegates to
xdrgen_decode_opaque() and xdrgen_decode_string(), which treat a
maxlen of 0 as unbounded and skip the length check. The sibling
variable-length array templates already guard their bound check
with maxsize != "0".

Guard the bound check the same way in each affected template -- the
struct and pointer forms of both the opaque and string encoders --
so an unbounded member encodes a payload of any length while a
bounded member keeps its limit.

An explicit zero-length bound (foo<0>) parses to the same maxsize of
0 and so also skips the check; xdrgen does not distinguish it from
the unbounded form, matching the decoder and the array encoders.

Fixes: 4b132aacb0 ("tools: Add xdrgen")
Link: https://patch.msgid.link/20260712193122.116845-6-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
d4ca0b0a6c xdrgen: Do not declare union XDR functions in the definitions header
Unlike the struct, enum, typedef, and pointer templates, the union
definitions template also emits xdrgen_decode_*() and
xdrgen_encode_*() prototypes for a public union into that header.
Those prototypes name struct xdr_stream, which the definitions
header neither includes nor forward-declares, so any translation
unit that includes the definitions header without xdr.h already in
scope draws -Wvisibility warnings. The same public prototypes are
emitted into the declarations header, which does include
<linux/sunrpc/xdr.h>, making the definitions-header copies
redundant.

Drop the prototype emission from the union definitions template so
it matches the other type templates. Public unions keep their
encode and decode prototypes through the declarations header.

Fixes: 4b132aacb0 ("tools: Add xdrgen")
Link: https://patch.msgid.link/20260712193122.116845-4-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
0cfead4c11 xdrgen: Share void RPC procedure handlers across programs
The generated server-side decoder and encoder for a void procedure
argument or result are named after the RPC program (for example,
nfs_svc_decode_void). xdrgen derives that prefix from the program
name alone, not the version, so two versions of one program built
into the same module emit the identical symbol. NFSv2 and NFSv3
both declare program NFS_PROGRAM; once both are converted, fs/nfsd
fails to link with multiple definitions of nfs_svc_decode_void and
nfs_svc_encode_void.

A void handler carries no program- or version-specific behavior:
each merely forwards to xdrgen_decode_void() or xdrgen_encode_void().
Define one shared pair, xdrgen_svc_decode_void() and
xdrgen_svc_encode_void(), in the xdrgen builtins, and stop the
program generator from emitting a per-program void handler.

lockd is the one in-tree consumer that already emits per-program
void handlers, so regenerate the NLMv3 and NLMv4 XDR code to drop
nlm_svc_{decode,encode}_void() and nlm4_svc_{decode,encode}_void()
and point both procedure tables at the shared handlers. The shared
handlers are identical to the generated ones they replace, so no
wire behavior changes.

Only the server (svc) handlers are affected. The client-side void
stubs remain static and per-program, so they do not collide.

Link: https://patch.msgid.link/20260712193122.116845-3-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Chuck Lever
ec5a7c2dce xdrgen: Emit a blank line ahead of enum declarations
Clean up.

The declaration templates for structs, pointers, and typedefs each
begin with a blank line, which keeps successive declarations and the
include block above them visually separated. The enum declaration
template omits that blank line. trim_blocks collapses the template's
lone comment line to nothing, so the omission stayed invisible as
long as every generated header happened to lead with a non-enum
declaration.

Fixes: 4329010ad9 ("xdrgen: Address some checkpatch whitespace complaints")
Link: https://patch.msgid.link/20260712193122.116845-2-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10 09:54:35 -04:00
Jakub Kicinski
edabb0da73 tools/ynl: add ovs_packet uapi header in Makefile.deps
ovs_packet spec needs to fetch the right uAPI header,
like other ovs specs already do. Otherwise build breaks
on very old distros (Ubuntu 22.04).

Spec was added by commit b82bfddc46 ("netlink: specs: add OVS packet
family specification").

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260807001918.61957-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07 18:26:16 -07:00
Jakub Kicinski
10c90f1bba tools: ynl: pyynl: pull the --family resolution logic into the lib
When packaging YNL as a system level utility we added a --family
argument which auto-resolves the full spec path from a well known
path in /usr/share. Spelling out full YAML spec files is at this
point only done in-tree, for example in the selftests which need
the very latest YAML. But the selftests have their own wrapping
classes for each family so test authors aren't really bothered
by having to spell the paths out.

Afford the same ease of use to the Python library users.
Move the path resolution from the CLI code to the library.
This simplifies the pyynl use by a lot:

  from pyynl import YnlFamily

  ynl = YnlFamily(family="netdev")

Unless I'm missing a trick, resolving the /usr/share path
is hard enough for most users to lean towards shelling out
to ynl CLI with --output-json, which is sad.

The ethtool script can now use family= instead of
resolving the path (the helpers are removed from cli.py
so this isn't just a cleanup).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20260701021751.3234681-3-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-07-03 08:57:15 +02:00
Jakub Kicinski
df87e5c4e9 tools: ynl: pyynl: re-export the library API from the package root
The public classes live in pyynl.lib, so users had to spell out

  from pyynl.lib import YnlFamily

which I forget at least once a month. Re-export lib's API from
the package __init__ so that

  from pyynl import YnlFamily

works as well. I don't think there was a real reason not to do
this?

Acked-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260701021751.3234681-2-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-07-03 08:57:15 +02:00
Thorsten Leemhuis
636838ebb7 tools/ynl: add missing uapi header deps in Makefile.deps
drm_ras includes drm/drm_ras.h, which is a relatively new header not yet
shipped in most distro kernel-header packages. Without the explicit
entry, the build might fail with a message like this:

  drm_ras-user.c:19:10: error: ‘DRM_RAS_CMD_CLEAR_ERROR_COUNTER’ \
   undeclared here (not in a function); did you mean \
  ‘DRM_RAS_CMD_GET_ERROR_COUNTER’

Signed-off-by: Thorsten Leemhuis <linux@leemhuis.info>
Link: https://patch.msgid.link/20260623070818.2161810-1-linux@leemhuis.info
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-24 19:30:55 -07:00
Greg Thelen
8c37e76f96 tools: ynl: build archives with $(AR)
Use $(AR) to allow build system to override the archiver tool (e.g.,
when cross-compiling for a different architecture) by setting the AR
environment variable.

GNU Make defaults AR to ar, so this change will not break existing build
environments that do not explicitly set AR.

Fixes: 07c3cc51a0 ("tools: net: package libynl for use in selftests")
Fixes: 86878f14d7 ("tools: ynl: user space helpers")
Signed-off-by: Greg Thelen <gthelen@google.com>
Link: https://patch.msgid.link/20260622161659.145047-1-gthelen@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-24 19:22:42 -07:00
Jakub Kicinski
07c4bca9d9 tools: ynl: try to avoid the very slow YAML loader
Turns out Python YAML defaults to a pure Python loader for YAML
files which is a lot slower than the C loader (using libyaml).
Try to use the C one whenever possible.

The avg time to run:
  $ tools/net/ynl/pyynl/cli.py --family tc --no-schema
drops from 300+ ms to 115 ms with this change (40 samples).

We could drop the load time further to 85 ms if we "compiled"
the specs to JSON. Slightly tricky parts are that we don't
currently install the specs at all on make install, so it's
unclear where to put the conversion. Also JSON has questionable
support for comments and we need an SPDX line.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20260603210810.2636193-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-04 15:36:12 -07:00
Minxi Hou
b74e71b6a9 tools: ynl: add unicast notification receive support
Add ntf_bind() method to YnlFamily for binding the netlink
socket without joining a multicast group. This enables receiving
unicast notifications through the existing poll_ntf/check_ntf
path.

The OVS packet family sends MISS and ACTION upcalls via
genlmsg_unicast() to a per-vport PID rather than through a
multicast group. The existing ntf_subscribe() couples bind()
with setsockopt(ADD_MEMBERSHIP), which does not fit the unicast
case. ntf_bind() provides the bind-only alternative, with the
address defaulting to (0, 0) but exposed as an explicit argument.

Signed-off-by: Minxi Hou <houminxi@gmail.com>
Link: https://patch.msgid.link/20260522174154.720293-3-houminxi@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-26 17:17:42 -07:00
Jakub Kicinski
6a20b34fe3 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR (net-7.1-rc5).

No conflicts, adjacent changes:

drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
  cc199cd1b9 ("net/mlx5e: Reduce branches in napi poll")
  c326f9c689 ("net/mlx5e: xsk: Fix unlocked writing to ICOSQ")

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
  c6df9a65cb ("net/mlx5: Skip disabled vports when setting max TX speed")
  1fba57c914 ("net/mlx5: Add VHCA_ID page management mode support")

net/mac80211/mlme.c
  a6e6ccd5bd ("wifi: mac80211: consume only present negotiated TTLM maps")
  49e62ec6eb ("wifi: mac80211: move frame RX handling to type files")

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-21 15:09:02 -07:00
Ilya Maximets
3287e81292 tools: ynl: support listening on all nsids
A new method ntf_listen_all_nsid() to enable listening on events from
all namespaces.  Useful for testing cross-namespace functionality.

recv() replaced with recvmsg() to be able to receive NSID through the
ancillary data.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Link: https://patch.msgid.link/20260520172317.175168-4-i.maximets@ovn.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-21 08:23:50 -07:00
Jakub Kicinski
878492af7d Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR (net-7.1-rc4).

No conflicts, or adjacent changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-14 10:08:06 -07:00
Jakub Kicinski
fbf5df34a4 tools: ynl: add scope qualifier for definitions
Using definitions in kernel policies is awkward right now.
On one hand we want defines for max values and such.
On the other we don't have a way of adding kernel-only defines.
Adding unnecessary defines to uAPI is a bad idea, we won't
be able to delete them. And when it comes to policy user
space should just query it via the policy dump, not use
hard coded defines.

Add a "scope" property to definitions, which will let us tell
the codegen that a definition is for kernel use only. Support
following values:
  - uapi: render into the uAPI header (default, today's behavior)
  - kernel: render to kernel header only
  - user: same as kernel but for the user-side generated header

Definitions may have a header property (definition is "external",
provided by existing header). Extend the scope to headers, too.
If definition has both scope and header properties we will only
generate the includes in the right scope.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260510192904.3987113-8-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-05-12 16:15:00 +02:00
Stanislav Fomichev
46e9b02244 tools/ynl: add missing uapi header deps in Makefile.deps
ethtool.h includes linux/typelimits.h which is a relatively new header
not yet shipped in most distro kernel-header packages. Without the
explicit entry, the build silently falls through to -idirafter.

dev_energymodel.h is a new YNL family whose uapi header is not in
system paths at all and was missing a CFLAGS entry entirely.

Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260508204114.205896-2-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-10 08:37:33 -07:00
Jakub Kicinski
c93799de1b net: page_pool: support dumping pps of a specific ifindex via Netlink
NIPA tries to make sure that HW tests don't modify system state.
It saves the state of page pools, too. Now that I write this commit
message I realize that this is impractical since page pool IDs and
state will get legitimately changed by the tests. But I already
spent a couple of hours implementing the filtering, so..

Link: https://patch.msgid.link/20260506034821.1710113-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-08 14:54:55 -07:00
Asbjørn Sloth Tønnesen
121f416756 tools: ynl: add sample for wireguard
Add a sample application for WireGuard, using the generated C library.

The main benefit of this is to exercise the generated library,
which might be useful for future self-tests.

Example:
  $ make -C tools/net/ynl/lib
  $ make -C tools/net/ynl/generated
  $ make -C tools/net/ynl/tests wireguard
  $ ./tools/net/ynl/tests/wireguard
  usage: ./tools/net/ynl/tests/wireguard <ifindex|ifname>
  $ sudo ./tools/net/ynl/tests/wireguard wg-test
  Interface 3: wg-test
      Peer 6adfb183a4a2c94a2f92dab5ade762a4788[...]:
          Data: rx: 42 / tx: 42 bytes
          Allowed IPs:
              0.0.0.0/0
              ::/0

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link: https://patch.msgid.link/20260414153944.2742252-3-Jason@zx2c4.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-14 11:48:04 -07:00
Daniel Borkmann
4a6fe5fe60 tools/ynl: Make YnlFamily closeable as a context manager
YnlFamily opens an AF_NETLINK socket in __init__ but has no way
to release it other than leaving it to the GC. YnlFamily holds a
self reference cycle through SpecFamily's self.family = self
in its super().__init__() call, so refcount GC cannot reclaim
it and the socket stays open until the cyclic GC runs.

If a test creates a guest netns, instantiates a YnlFamily inside
it via NetNSEnter(), performs some test case work via Ynl, and
then deletes the netns, then the 'ip netns del' only drops the
mount binding and cleanup_net in the kernel never runs, so any
subsequent test case assertions that objects got cleaned up would
fail given this only gets triggered later via cyclic GC run.

Add an explicit close() that closes the netlink socket and wire
up the __enter__/__exit__ so callers can scope the instance
deterministically via 'with YnlFamily(...) as ynl: ...'.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20260413220809.604592-2-daniel@iogearbox.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-14 08:17:01 -07:00
Hangbin Liu
594ba44771 tools: ynl: ethtool: add --dbg-small-recv option
Add a --dbg-small-recv debug option to control the recv() buffer size
used by YNL, matching the same option already present in cli.py. This
is useful if user need to get large netlink message.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/20260408-b4-ynl_ethtool-v2-3-7623a5e8f70b@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-12 11:23:49 -07:00
Hangbin Liu
1c43d471a5 tools: ynl: ethtool: use doit instead of dumpit for per-device GET
Rename the local helper doit() to do_set() and dumpit() to do_get() to
better reflect their purpose.

Convert do_get() to use ynl.do() with an explicit device header instead
of ynl.dump() followed by client-side filtering. This is more efficient
as the kernel only processes and returns data for the requested device,
rather than dumping all devices across the netns.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/20260408-b4-ynl_ethtool-v2-2-7623a5e8f70b@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-12 11:23:49 -07:00