summaryrefslogtreecommitdiff
path: root/tools/net
AgeCommit message (Collapse)Author
16 hoursMerge branch 'main' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
11 daysxdrgen: Update the aggregate_members comment for optional-data listsChuck Lever
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>
11 daysxdrgen: Document that aggregate members of a struct share an element typeChuck Lever
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>
11 daysxdrgen: Report unsupported client-side directives without a tracebackChuck Lever
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>
11 daysxdrgen: Reject a "pragma pages" union arm declared as an opaqueChuck Lever
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>
11 daysxdrgen: Stream optional-data aggregate lists during encodeChuck Lever
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>
11 daysxdrgen: Extend the aggregate codec to optional-data list membersChuck Lever
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>
11 daysxdrgen: Add hook-driven aggregate codec for variable-length arraysChuck Lever
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>
11 daysxdrgen: Extend the pages directive to page-resident argumentsChuck Lever
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>
11 daysxdrgen: Add a "pragma pages" directiveChuck Lever
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>
11 daysxdrgen: Pass the containing struct name to member codec emittersChuck Lever
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-09-28tools: ynl-gen-c: keep the type values of a nest in spec orderJakub Kicinski
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-15netlink: policy: report the big endian attributesJakub Kicinski
Paolo pointed out an issue flagged at low priority by Sashiko - we're currently not handling BE{16,32} attributes in policy dumps. Commit 3f4285d741b4 ("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-14tools: ynl: Fix out-of-tree build for ynltoolMaxime Chevallier (Netdev Foundation)
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: 917f713b4ec4 ("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-08tools: ynl: Allow cross-compiling ynl and associated toolsMaxime Chevallier (Netdev Foundation)
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-08-27Merge tag 'net-7.3-rc1' of ↵Linus Torvalds
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-20tools: ynl: handle calloc failure in ynl_ntf_parseTriet Hoang
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-20Merge tag 'nfsd-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linuxLinus Torvalds
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-10tools: ynl: check alloc fails in generated getter codeThaison Phan
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-10tools: ynl: check for null ptr on dump freeThaison Phan
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-10xdrgen: Reject out-of-range program, version, and procedure numbersChuck Lever
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-10xdrgen: Enforce RFC 5531 name and number scoping for RPC programsChuck Lever
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-10xdrgen: Reject specifications that define a name twiceChuck Lever
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-10xdrgen: Record the source position of each declared identifierChuck Lever
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-10xdrgen: Align the error caret under tab-indented sourceChuck Lever
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-10xdrgen: Fix opaque and string encoders for unbounded membersChuck Lever
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: 4b132aacb076 ("tools: Add xdrgen") Link: https://patch.msgid.link/20260712193122.116845-6-cel@kernel.org Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10xdrgen: Do not declare union XDR functions in the definitions headerChuck Lever
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: 4b132aacb076 ("tools: Add xdrgen") Link: https://patch.msgid.link/20260712193122.116845-4-cel@kernel.org Signed-off-by: Chuck Lever <cel@kernel.org>
2026-08-10xdrgen: Share void RPC procedure handlers across programsChuck Lever
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-10xdrgen: Emit a blank line ahead of enum declarationsChuck Lever
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: 4329010ad9c3 ("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-07tools/ynl: add ovs_packet uapi header in Makefile.depsJakub Kicinski
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 b82bfddc46e2 ("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-07-03tools: ynl: pyynl: pull the --family resolution logic into the libJakub Kicinski
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-03tools: ynl: pyynl: re-export the library API from the package rootJakub Kicinski
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-06-24tools/ynl: add missing uapi header deps in Makefile.depsThorsten Leemhuis
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-24tools: ynl: build archives with $(AR)Greg Thelen
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: 07c3cc51a085 ("tools: net: package libynl for use in selftests") Fixes: 86878f14d71a ("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-04tools: ynl: try to avoid the very slow YAML loaderJakub Kicinski
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-05-26tools: ynl: add unicast notification receive supportMinxi Hou
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-21Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski
Cross-merge networking fixes after downstream PR (net-7.1-rc5). No conflicts, adjacent changes: drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c cc199cd1b912 ("net/mlx5e: Reduce branches in napi poll") c326f9c68921 ("net/mlx5e: xsk: Fix unlocked writing to ICOSQ") drivers/net/ethernet/mellanox/mlx5/core/eswitch.c c6df9a65cbb0 ("net/mlx5: Skip disabled vports when setting max TX speed") 1fba57c91416 ("net/mlx5: Add VHCA_ID page management mode support") net/mac80211/mlme.c a6e6ccd5bd07 ("wifi: mac80211: consume only present negotiated TTLM maps") 49e62ec6eb06 ("wifi: mac80211: move frame RX handling to type files") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-21tools: ynl: support listening on all nsidsIlya Maximets
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-14Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski
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-12tools: ynl: add scope qualifier for definitionsJakub Kicinski
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-10tools/ynl: add missing uapi header deps in Makefile.depsStanislav Fomichev
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-08net: page_pool: support dumping pps of a specific ifindex via NetlinkJakub Kicinski
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-04-14tools: ynl: add sample for wireguardAsbjørn Sloth Tønnesen
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-14tools/ynl: Make YnlFamily closeable as a context managerDaniel Borkmann
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-12tools: ynl: ethtool: add --dbg-small-recv optionHangbin Liu
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-12tools: ynl: ethtool: use doit instead of dumpit for per-device GETHangbin Liu
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-12tools: ynl: move ethtool.py to selftestHangbin Liu
We have converted all the samples to selftests. This script is the last piece of random "PoC" code we still have lying around. Let's move it to tests. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://patch.msgid.link/20260408-b4-ynl_ethtool-v2-1-7623a5e8f70b@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-09tools: ynl: tests: fix leading space on Makefile targetHangbin Liu
The ../generated/protos.a rule had a spurious leading space before the target name. In make, target rules must start at column 0; only recipe lines are indented with a tab. The extra space caused make to misparse the rule. Remove the leading space to match the style of the adjacent ../lib/ynl.a rule. Fixes: e0aa0c61758f ("tools: ynl: move samples to tests") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://patch.msgid.link/20260408-ynl_makefile-v1-1-f9624acc2ad9@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-03-18tools: ynl: rework policy access to support recursionJakub Kicinski
Donald points out that the current naive implementation using dicts breaks if policy is recursive (child nest uses policy idx already used by its parent). Lean more into the NlPolicy class. This lets us "render" the policy on demand, when user accesses it. If someone wants to do an infinite walk that's on them :) Show policy info as attributes of the class and use dict format to descend into sub-policies for extra neatness. Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20260313232047.2068518-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-03-10tools: ynl: cli: add --policy supportJakub Kicinski
Add --policy flag which can be combined with --do or --dump to query the kernel's netlink policy for an operation instead of executing it. Examples: $ ynl --family netdev --do dev-get --policy {'ifindex': {'max-value': 4294967295, 'min-value': 1, 'type': 'u32'}} $ ynl --family ethtool --do channels-get --policy --output-json {"header": {"type": "nested", "policy": {"dev-index": ...}}} $ ynl --family netdev --dump dev-get --policy {} Link: https://patch.msgid.link/20260310005337.3594225-6-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>