summaryrefslogtreecommitdiffstats
path: root/tools/net
Commit message (Collapse)AuthorAgeFilesLines
* tools: ynl-gen: make sure we validate subtype of array-nestJakub Kicinski10 days1-2/+5
| | | | | | | | | | | | | ArrayNest AKA indexed-array support currently skips inner type validation. We count the attributes and then we parse them, make sure we call validate, too. Otherwise buggy / unexpected kernel response may lead to crashes. Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250414211851.602096-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: individually free previous values on double setJakub Kicinski10 days1-17/+45
| | | | | | | | | | | | | | | | | | | | | | | | When user calls request_attrA_set() multiple times (for the same attribute), and attrA is of type which allocates memory - we try to free the previously associated values. For array types (including multi-attr) we have only freed the array, but the array may have contained pointers. Refactor the code generation for free attr and reuse the generated lines in setters to flush out the previous state. Since setters are static inlines in the header we need to add forward declarations for the free helpers of pure nested structs. Track which types get used by arrays and include the right forwad declarations. At least ethtool string set and bit set would not be freed without this. Tho, admittedly, overriding already set attribute twice is likely a very very rare thing to do. Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250414211851.602096-4-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: move local vars after the opening bracketJakub Kicinski10 days1-1/+1
| | | | | | | | | | | | The "function writing helper" tries to put local variables between prototype and the opening bracket. Clearly wrong, but up until now nothing actually uses it to write local vars so it wasn't noticed. Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250414211851.602096-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: don't declare loop iterator in placeJakub Kicinski10 days1-4/+21
| | | | | | | | | | | The codegen tries to follow the "old" C style and declare loop iterators at the start of the block / function. Only nested request handling breaks this style, so adjust it. Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250414211851.602096-2-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* netlink: specs: wireless: add a spec for nl80211Donald Hunter2025-02-121-0/+1
| | | | | | | | | | | | | | | | | | | | Add a rudimentary YNL spec for nl80211 that covers get-wiphy, get-interface and get-protocol-features. ./tools/net/ynl/pyynl/cli.py --family nl80211 \ --do get-protocol-features {'protocol-features': {'split-wiphy-dump'}} ./tools/net/ynl/pyynl/cli.py --family nl80211 \ --dump get-wiphy --json '{ "split-wiphy-dump": true }' ./tools/net/ynl/pyynl/cli.py --family nl80211 \ --dump get-interface Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Link: https://patch.msgid.link/20250211120127.84858-11-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: add indexed-array scalar support to ynl-gen-cDonald Hunter2025-02-121-6/+18
| | | | | | | | | Extend ynl-gen-c.py with support for indexed-array that has a scalar sub-type. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-8-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: sanitise enums with leading digits in ynl-gen-cDonald Hunter2025-02-121-0/+2
| | | | | | | | | Turn attribute names with leading digits into valid C names by prepending an underscore, e.g. 5ghz -> _5ghz Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-7-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: add s8, s16 to valid scalars in ynl-gen-cDonald Hunter2025-02-121-1/+1
| | | | | | | | | Add the missing s8 and s16 scalar types to the list of recognised scalars in ynl-gen-c. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-6-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: accept IP string inputsDonald Hunter2025-02-121-4/+21
| | | | | | | | | | The ynl tool uses display-hint to know when to format IP addresses in printed output, but not to parse IP addresses from --json input. Add support for parsing ipv4 and ipv6 strings. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-5-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: support rendering C array members to stringsDonald Hunter2025-02-121-0/+5
| | | | | | | | | | The nl80211 family encodes the list of supported ciphers as a C array of u32 values. Add support for translating arrays of scalars into strings for enum names and display hints. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-4-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: support decoding indexed arrays as enumsDonald Hunter2025-02-121-1/+3
| | | | | | | | | | When decoding an indexed-array with a scalar subtype, it is currently only possible to add a display-hint. Add support for decoding each value as an enum. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-3-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools/net/ynl: remove extraneous plural from variable namesDonald Hunter2025-02-121-6/+6
| | | | | | | | | | | | _decode_array_attr() uses variable subattrs in every branch when only one branch decodes more than a single attribute. Change the variable name to subattr in the branches that only decode a single attribute so that the intent is more obvious. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250211120127.84858-2-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: add all headers to makefile depsJakub Kicinski2025-02-061-1/+3
| | | | | | | | | | | | | | | | | | | The Makefile.deps lists uAPI headers to make the build work when system headers are older than in-tree headers. The problem doesn't occur for new headers, because system headers are not there at all. But out-of-tree YNL clone on GH also uses this header to identify header dependencies, and one day the system headers will exist, and will get out of date. So let's add the headers we missed. I don't think this is a fix, but FWIW the commits which added the missing headers are: commit 04e65df94b31 ("netlink: spec: add shaper YAML spec") commit 49922401c219 ("ethtool: separate definitions that are gonna be generated") Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250205173352.446704-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: support limits using definitionsJakub Kicinski2025-02-061-1/+4
| | | | | | | | | | | | Support using defines / constants in integer checks. Carolina will need this for rate API extensions. Reported-by: Carolina Jubran <cjubran@nvidia.com> Link: https://lore.kernel.org/1e886aaf-e1eb-4f1a-b7ef-f63b350a3320@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Link: https://patch.msgid.link/20250203215510.1288728-2-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
* tools: ynl-gen: don't output external constantsJakub Kicinski2025-02-061-0/+3
| | | | | | | | | | | | | A definition with a "header" property is an "external" definition for C code, as in it is defined already in another C header file. Other languages will need the exact value but C codegen should not recreate it. So don't output those definitions in the uAPI header. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Link: https://patch.msgid.link/20250203215510.1288728-1-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
* tools: ynl: c: correct reverse decode of empty attrsJakub Kicinski2025-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | netlink reports which attribute was incorrect by sending back an attribute offset. Offset points to the address of struct nlattr, but to interpret the type we also need the nesting path. Attribute IDs have different meaning in different nests of the same message. Correct the condition for "is the offset within current attribute". ynl_attr_data_len() does not include the attribute header, so the end offset was off by 4 bytes. This means that we'd always skip over flags and empty nests. The devmem tests, for example, issues an invalid request with empty queue nests, resulting in the following error: YNL failed: Kernel error: missing attribute: .queues.ifindex The message is incorrect, "queues" nest does not have an "ifindex" attribute defined. With this fix we decend correctly into the nest: YNL failed: Kernel error: missing attribute: .queues.id Fixes: 86878f14d71a ("tools: ynl: user space helpers") Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250124012130.1121227-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2025-01-161-3/+13
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cross-merge networking fixes after downstream PR (net-6.13-rc8). Conflicts: drivers/net/ethernet/realtek/r8169_main.c 1f691a1fc4be ("r8169: remove redundant hwmon support") 152d00a91396 ("r8169: simplify setting hwmon attribute visibility") https://lore.kernel.org/20250115122152.760b4e8d@canb.auug.org.au Adjacent changes: drivers/net/ethernet/broadcom/bnxt/bnxt.c 152f4da05aee ("bnxt_en: add support for rx-copybreak ethtool command") f0aa6a37a3db ("eth: bnxt: always recalculate features after XDP clearing, fix null-deref") drivers/net/ethernet/intel/ice/ice_type.h 50327223a8bb ("ice: add lock to protect low latency interface") dc26548d729e ("ice: Fix quad registers read on E825") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * netdev: avoid CFI problems with sock priv helpersJakub Kicinski2025-01-161-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Li Li reports that casting away callback type may cause issues for CFI. Let's generate a small wrapper for each callback, to make sure compiler sees the anticipated types. Reported-by: Li Li <dualli@chromium.org> Link: https://lore.kernel.org/CANBPYPjQVqmzZ4J=rVQX87a9iuwmaetULwbK_5_3YWk2eGzkaA@mail.gmail.com Fixes: 170aafe35cb9 ("netdev: support binding dma-buf to netdevice") Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Mina Almasry <almasrymina@google.com> Link: https://patch.msgid.link/20250115161436.648646-1-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
* | tools/net/ynl: ethtool: support spec load from install locationDonald Hunter2025-01-131-4/+3
| | | | | | | | | | | | | | | | | | Replace hard-coded paths for spec and schema with lookup functions so that ethtool.py will work in-tree or when installed. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250111154803.7496-2-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools/net/ynl: add support for --family and --list-familiesDonald Hunter2025-01-131-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | Add a --family option to ynl to specify the spec by family name instead of file path, with support for searching in-tree and system install location and a --list-families option to show the available families. ./tools/net/ynl/pyynl/cli.py --family rt_addr --dump getaddr Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250111154803.7496-1-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: add main install targetJan Stancek2025-01-091-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will install C library, specs, rsts and pyynl. The initial structure is: $ mkdir /tmp/myroot $ make DESTDIR=/tmp/myroot install /usr /usr/lib64 /usr/lib64/libynl.a /usr/lib/python3.XX/site-packages/pyynl/* /usr/lib/python3.XX/site-packages/pyynl-0.0.1.dist-info/* /usr/bin /usr/bin/ynl /usr/bin/ynl-ethtool /usr/include/ynl/*.h /usr/share /usr/share/doc /usr/share/doc/ynl /usr/share/doc/ynl/*.rst /usr/share/ynl /usr/share/ynl/genetlink-c.yaml /usr/share/ynl/genetlink-legacy.yaml /usr/share/ynl/genetlink.yaml /usr/share/ynl/netlink-raw.yaml /usr/share/ynl/specs /usr/share/ynl/specs/devlink.yaml /usr/share/ynl/specs/dpll.yaml /usr/share/ynl/specs/ethtool.yaml /usr/share/ynl/specs/fou.yaml /usr/share/ynl/specs/handshake.yaml /usr/share/ynl/specs/mptcp_pm.yaml /usr/share/ynl/specs/netdev.yaml /usr/share/ynl/specs/net_shaper.yaml /usr/share/ynl/specs/nfsd.yaml /usr/share/ynl/specs/nftables.yaml /usr/share/ynl/specs/nlctrl.yaml /usr/share/ynl/specs/ovs_datapath.yaml /usr/share/ynl/specs/ovs_flow.yaml /usr/share/ynl/specs/ovs_vport.yaml /usr/share/ynl/specs/rt_addr.yaml /usr/share/ynl/specs/rt_link.yaml /usr/share/ynl/specs/rt_neigh.yaml /usr/share/ynl/specs/rt_route.yaml /usr/share/ynl/specs/rt_rule.yaml /usr/share/ynl/specs/tcp_metrics.yaml /usr/share/ynl/specs/tc.yaml /usr/share/ynl/specs/team.yaml Signed-off-by: Jan Stancek <jstancek@redhat.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Joe Damato <jdamato@fastly.com> Link: https://patch.msgid.link/c882688d751295c7f35c7d4eba104cd5174a0861.1736343575.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: add install target for generated contentJan Stancek2025-01-092-7/+43
| | | | | | | | | | | | | | | | | | | | | | | | Generate docs using ynl_gen_rst and add install target for headers, specs and generates rst files. Factor out SPECS_DIR since it's repeated many times. Signed-off-by: Jan Stancek <jstancek@redhat.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/645c68e3d201f1ef4276e3daddfe06262a0c2804.1736343575.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: add initial pyproject.toml for packagingJan Stancek2025-01-091-0/+24
| | | | | | | | | | | | | | | | | | | | | | Add pyproject.toml and define authors, dependencies and user-facing scripts. This will be used later by pip to install python code. Signed-off-by: Jan Stancek <jstancek@redhat.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/b184b43340f08aef97387bfd7f2b2cd9b015c343.1736343575.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: move python code to separate sub-directoryJan Stancek2025-01-0914-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Move python code to a separate directory so it can be packaged as a python module. Updates existing references in selftests and docs. Also rename ynl-gen-[c|rst] to ynl_gen_[c|rst], avoid dashes as these prevent easy imports for entrypoints. Signed-off-by: Jan Stancek <jstancek@redhat.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/a4151bad0e6984e7164d395125ce87fd2e048bf1.1736343575.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl-gen-c: improve support for empty nestsJakub Kicinski2025-01-091-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Empty nests are the same size as a flag at the netlink level (just a 4 byte nlattr without a payload). They are sometimes useful in case we want to only communicate a presence of something but may want to add more details later. This may be the case in the upcoming io_uring ZC patches, for example. Improve handling of nested empty structs. We already support empty structs since a lot of netlink replies are empty, but for nested ones we need minor tweaks to avoid pointless empty lines and unused variables. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Link: https://patch.msgid.link/20250108200758.2693155-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: print some information about attribute we can't parseJakub Kicinski2025-01-071-35/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When parsing throws an exception one often has to figure out which attribute couldn't be parsed from first principles. For families with large message parsing trees like rtnetlink guessing the attribute can be hard. Print a bit of information as the exception travels out, e.g.: # when dumping rt links Error decoding 'flags' from 'linkinfo-ip6tnl-attrs' Error decoding 'data' from 'linkinfo-attrs' Error decoding 'linkinfo' from 'link-attrs' Traceback (most recent call last): File "/home/kicinski/linux/./tools/net/ynl/cli.py", line 119, in <module> main() File "/home/kicinski/linux/./tools/net/ynl/cli.py", line 100, in main reply = ynl.dump(args.dump, attrs) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 1064, in dump return self._op(method, vals, dump=True) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 1058, in _op return self._ops(ops)[0] File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 1045, in _ops rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 738, in _decode subdict = self._decode(NlAttrs(attr.raw), attr_spec['nested-attributes'], search_attrs) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 763, in _decode decoded = self._decode_sub_msg(attr, attr_spec, search_attrs) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 714, in _decode_sub_msg subdict = self._decode(NlAttrs(attr.raw, offset), msg_format.attr_set) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 749, in _decode decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order) File "/home/kicinski/linux/tools/net/ynl/lib/ynl.py", line 147, in as_scalar return format.unpack(self.raw)[0] struct.error: unpack requires a buffer of 2 bytes The Traceback is what we would previously see, the "Error..." messages are new. We print a message per level (in the stack order). Printing single combined message gets tricky quickly given sub-messages etc. Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250107022820.2087101-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: correctly handle overrides of fields in subsetJakub Kicinski2025-01-072-5/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We stated in documentation [1] and previous discussions [2] that the need for overriding fields in members of subsets is anticipated. Implement it. Since each attr is now a new object we need to make sure that the modifications are propagated. Specifically C codegen wants to annotate which attrs are used in requests and replies to generate the right validation artifacts. [1] https://docs.kernel.org/next/userspace-api/netlink/specs.html#subset-of [2] https://lore.kernel.org/netdev/20231004171350.1f59cd1d@kernel.org/ Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250107022820.2087101-2-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2024-12-191-3/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Cross-merge networking fixes after downstream PR (net-6.13-rc4). No conflicts. Adjacent changes: drivers/net/ethernet/renesas/rswitch.h 32fd46f5b69e ("net: renesas: rswitch: remove speed from gwca structure") 922b4b955a03 ("net: renesas: rswitch: rework ts tags management") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * tools/net/ynl: fix sub-message key lookup for nested attributesDonald Hunter2024-12-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the correct attribute space for sub-message key lookup in nested attributes when adding attributes. This fixes rt_link where the "kind" key and "data" sub-message are nested attributes in "linkinfo". For example: ./tools/net/ynl/cli.py \ --create \ --spec Documentation/netlink/specs/rt_link.yaml \ --do newlink \ --json '{"link": 99, "linkinfo": { "kind": "vlan", "data": {"id": 4 } } }' Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Fixes: ab463c4342d1 ("tools/net/ynl: Add support for encoding sub-messages") Link: https://patch.msgid.link/20241213130711.40267-1-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl-gen-c: don't require -o argumentJohannes Berg2024-12-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | Without -o the tool currently crashes, but it's not marked as required. The only thing we can't do without it is to generate the correct #include for user source files, but we can put a placeholder instead. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://patch.msgid.link/20241206113100.89d35bf124d6.I9228fb704e6d5c9d8e046ef15025a47a48439c1e@changeid Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl-gen-c: annotate valid choices for --modeJohannes Berg2024-12-071-1/+2
| | | | | | | | | | | | | | | | | | This makes argparse validate the input and helps users understand which modes are possible. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://patch.msgid.link/20241206113100.e2ab5cf6937c.Ie149a0ca5df713860964b44fe9d9ae547f2e1553@changeid Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | ynl: include uapi header after all dependenciesStanislav Fomichev2024-12-051-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Essentially reverse the order of headers for userspace generated files. Before (make -C tools/net/ynl/; cat tools/net/ynl/ethtool-user.h): #include <linux/ethtool_netlink_generated.h> #include <linux/ethtool.h> #include <linux/ethtool.h> #include <linux/ethtool.h> After: #include <linux/ethtool.h> #include <linux/ethtool_netlink_generated.h> While at it, make sure we track which headers we've already included and include the headers only once. Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20241204155549.641348-6-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | ynl: support directional specs in ynl-gen-c.pyStanislav Fomichev2024-12-051-31/+87
| | | | | | | | | | | | | | | | | | | | | | The intent is to generate ethtool uapi headers. For now, some of the things are hard-coded: - <FAMILY>_MSG_{USER,KERNEL}_MAX - the split between USER and KERNEL messages Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20241204155549.641348-4-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | ynl: skip rendering attributes with header property in uapi modeStanislav Fomichev2024-12-051-0/+4
| | | | | | | | | | | | | | | | To allow omitting some of the attributes in the final generated file. Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20241204155549.641348-3-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | ynl: support enum-cnt-name attribute in legacy definitionsStanislav Fomichev2024-12-051-2/+6
|/ | | | | | | | | This is similar to existing attr-cnt-name in the attributes to allow changing the name of the 'count' enum entry. Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20241204155549.641348-2-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* Merge tag 'nfsd-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linuxLinus Torvalds2024-11-2645-86/+541
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull nfsd updates from Chuck Lever: "Jeff Layton contributed a scalability improvement to NFSD's NFSv4 backchannel session implementation. This improvement is intended to increase the rate at which NFSD can safely recall NFSv4 delegations from clients, to avoid the need to revoke them. Revoking requires a slow state recovery process. A wide variety of bug fixes and other incremental improvements make up the bulk of commits in this series. As always I am grateful to the NFSD contributors, reviewers, testers, and bug reporters who participated during this cycle" * tag 'nfsd-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (72 commits) nfsd: allow for up to 32 callback session slots nfs_common: must not hold RCU while calling nfsd_file_put_local nfsd: get rid of include ../internal.h nfsd: fix nfs4_openowner leak when concurrent nfsd4_open occur NFSD: Add nfsd4_copy time-to-live NFSD: Add a laundromat reaper for async copy state NFSD: Block DESTROY_CLIENTID only when there are ongoing async COPY operations NFSD: Handle an NFS4ERR_DELAY response to CB_OFFLOAD NFSD: Free async copy information in nfsd4_cb_offload_release() NFSD: Fix nfsd4_shutdown_copy() NFSD: Add a tracepoint to record canceled async COPY operations nfsd: make nfsd4_session->se_flags a bool nfsd: remove nfsd4_session->se_bchannel nfsd: make use of warning provided by refcount_t nfsd: Don't fail OP_SETCLIENTID when there are too many clients. svcrdma: fix miss destroy percpu_counter in svc_rdma_proc_init() xdrgen: Remove program_stat_to_errno() call sites xdrgen: Update the files included in client-side source code xdrgen: Remove check for "nfs_ok" in C templates xdrgen: Remove tracepoint call site ...
| * xdrgen: Remove program_stat_to_errno() call sitesChuck Lever2024-11-181-2/+0
| | | | | | | | | | | | | | Refactor: Translating an on-the-wire value to a local host errno is architecturally a job for the proc function, not the XDR decoder. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Update the files included in client-side source codeChuck Lever2024-11-181-2/+7
| | | | | | | | | | | | | | | | In particular, client-side source code needs the definition of "struct rpc_procinfo" and does not want header files that pull in "struct svc_rqst". Otherwise, the source does not compile. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Remove check for "nfs_ok" in C templatesChuck Lever2024-11-181-1/+1
| | | | | | | | | | | | | | Obviously, "nfs_ok" is defined only for NFS protocols. Other XDR protocols won't know "nfs_ok" from Adam. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Remove tracepoint call siteChuck Lever2024-11-181-3/+1
| | | | | | | | | | | | | | | | | | This tracepoint was a "note to self" and is not operational. It is added only to client-side code, which so far we haven't needed. It will cause immediate breakage once we start generating client code, though, so remove it now. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Add a utility for extracting XDR from RFCsChuck Lever2024-11-181-0/+11
| | | | | | | | | | | | | | For convenience, copy the XDR extraction script from RFC Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: emit maxsize macrosChuck Lever2024-11-112-5/+22
| | | | | | | | | | | | | | Add "definitions" subcommand logic to emit maxsize macros in generated code. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Add generator code for XDR width macrosChuck Lever2024-11-1115-6/+107
| | | | | | | | | | | | | | Introduce logic in the code generators to emit maxsize (XDR width) definitions. In C, these are pre-processor macros. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for union typesChuck Lever2024-11-111-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not yet complete. The tool doesn't do any math yet. Thus, even though the maximum XDR width of a union is the width of the union enumerator plus the width of its largest arm, we're using the sum of all the elements of the union for the moment. This means that buffer size requirements are overestimated, and that the generated maxsize macro cannot yet be used for determining data element alignment in the XDR buffer. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for pointer typesChuck Lever2024-11-111-0/+17
| | | | | | | | | | | | | | | | The XDR width of a pointer type is the sum of the widths of each of the struct's fields, except for the last field. The width of the implicit boolean "value follows" field is added as well. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for struct typesChuck Lever2024-11-111-0/+16
| | | | | | | | | | | | | | The XDR width of a struct type is the sum of the widths of each of the struct's fields. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for typedefChuck Lever2024-11-111-7/+27
| | | | | | | | | | | | The XDR width of a typedef is the same as the width of the base type. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for optional_data typeChuck Lever2024-11-111-0/+10
| | | | | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for variable-length arrayChuck Lever2024-11-111-0/+16
| | | | | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for fixed-length arrayChuck Lever2024-11-111-0/+13
| | | | | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>