summaryrefslogtreecommitdiffstats
path: root/tools/net (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski13 days1-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 Kicinski13 days1-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-141-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-141-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-081-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-082-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-081-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-081-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-191-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-191-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-191-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-191-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-191-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>
| * xdrgen: XDR width for a stringChuck Lever2024-11-111-0/+15
| | | | | | | | | | | | | | A string works like a variable-length opaque. See Section 4.11 of RFC 4506. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for variable-length opaqueChuck Lever2024-11-111-0/+15
| | | | | | | | | | | | | | | | The byte size of a variable-length opaque is conveyed in an unsigned integer. If there is a specified maximum size, that is included in the type's widths list. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR width for fixed-length opaqueChuck Lever2024-11-111-0/+22
| | | | | | | | | | | | | | The XDR width for a fixed-length opaque is the byte size of the opaque rounded up to the next XDR_UNIT, divided by XDR_UNIT. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: XDR widths for enum typesChuck Lever2024-11-111-0/+12
| | | | | | | | | | | | | | RFC 4506 says that an XDR enum is represented as a signed integer on the wire; thus its width is 1 XDR_UNIT. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Keep track of on-the-wire data type widthsChuck Lever2024-11-111-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The generic parts of the RPC layer need to know the widths (in XDR_UNIT increments) of the XDR data types defined for each protocol. As a first step, add dictionaries to keep track of the symbolic and actual maximum XDR width of XDR types. This makes it straightforward to look up the width of a type by its name. The built-in dictionaries are pre-loaded with the widths of the built-in XDR types as defined in RFC 4506. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Track constant valuesChuck Lever2024-11-111-0/+10
| | | | | | | | | | | | | | | | | | In order to compute the numeric on-the-wire width of XDR types, xdrgen needs to keep track of the numeric value of constants that are defined in the input specification so it can perform calculations with those values. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Refactor transformer armsChuck Lever2024-11-111-24/+33
| | | | | | | | | | | | | | Clean up: Add a __post_init__ function to the data classes that need to update the "structs" and "pass_by_reference" sets. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Implement big-endian enumsChuck Lever2024-11-1110-14/+96
| | | | | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Rename "enum yada" types as just "yada"Chuck Lever2024-11-115-8/+5
| | | | | | | | | | | | | | This simplifies the generated C code and makes way for supporting big-endian XDR enums. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Rename enum's declaration Jinja2 templateChuck Lever2024-11-112-1/+1
| | | | | | | | | | | | "close.j2" is a confusing name. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Rename "variable-length strings"Chuck Lever2024-11-1116-19/+19
| | | | | | | | | | | | | | I misread RFC 4506. The built-in data type is called simply "string", as there is no fixed-length variety. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Clean up type_specifierChuck Lever2024-11-111-2/+2
| | | | | | | | | | | | | | Clean up: Make both arms of the type_specifier AST transformer match. No behavior change is expected. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * xdrgen: Exit status should be zero on successChuck Lever2024-11-111-1/+3
| | | | | | | | | | | | | | | | To use xdrgen in Makefiles, it needs to exit with a zero status if the compilation worked. Otherwise the make command fails with an error. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* | tools: ynl-gen: allow uapi headers in sub-dirsJakub Kicinski2024-11-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Binder places its headers under include/uapi/linux/android/ Make sure replace / with _ in the uAPI header guard, the c_upper() is more strict and only converts - to _. This is likely a good constraint to have, to enforce sane naming in enums etc. But paths may include /. Signed-off-by: Li Li <dualli@google.com> Link: https://patch.msgid.link/20241113193239.2113577-2-dualli@chromium.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools/net/ynl: add async notification handlingDonald Hunter2024-11-152-10/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The notification handling in ynl is currently very simple, using sleep() to wait a period of time and then handling all the buffered messages in a single batch. This patch adds async notification handling so that messages can be processed as they are received. This makes it possible to use ynl as a library that supplies notifications in a timely manner. - Add poll_ntf() to be a generator that yields 1 notification at a time and blocks until a notification is available. - Add a --duration parameter to the CLI, with --sleep as an alias. ./tools/net/ynl/cli.py \ --spec <SPEC> --subscribe <TOPIC> [ --duration <SECS> ] The cli will report any notifications for duration seconds and then exit. If duration is not specified, then it will poll forever, until interrupted. Here is an example python snippet that shows how to use ynl as a library for receiving notifications: ynl = YnlFamily(f"{dir}/rt_route.yaml") ynl.ntf_subscribe('rtnlgrp-ipv4-route') for event in ynl.poll_ntf(): handle(event) Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20241113090843.72917-3-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | Revert "tools/net/ynl: improve async notification handling"Donald Hunter2024-11-152-36/+23
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 1bf70e6c3a5346966c25e0a1ff492945b25d3f80. This modification to check_ntf() is being reverted so that its behaviour remains equivalent to ynl_ntf_check() in the C YNL. Instead a new poll_ntf() will be added in a separate patch. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20241113090843.72917-2-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>