summaryrefslogtreecommitdiff
path: root/tools/net
Commit message (Collapse)AuthorAgeFilesLines
* tools: ynl: Rename ethtool to ethtool.pyRahul Rameshbabu2023-04-131-0/+0
| | | | | | | | | | | Make it explicit that this tool is not a drop-in replacement for ethtool. This tool is intended for testing ethtool functionality implemented in the kernel and should use a name that differentiates it from the ethtool utility. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Link: https://lore.kernel.org/r/20230413012252.184434-2-rrameshbabu@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: Remove absolute paths to yaml files from ethtool testing toolRahul Rameshbabu2023-04-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Absolute paths for the spec and schema files make the ethtool testing tool unusable with freshly checked-out source trees. Replace absolute paths with relative paths for both files in the Documentation/ directory. Issue seen before the change Traceback (most recent call last): File "/home/binary-eater/Documents/mlx/linux/tools/net/ynl/./ethtool", line 424, in <module> main() File "/home/binary-eater/Documents/mlx/linux/tools/net/ynl/./ethtool", line 158, in main ynl = YnlFamily(spec, schema) File "/home/binary-eater/Documents/mlx/linux/tools/net/ynl/lib/ynl.py", line 342, in __init__ super().__init__(def_path, schema) File "/home/binary-eater/Documents/mlx/linux/tools/net/ynl/lib/nlspec.py", line 333, in __init__ with open(spec_path, "r") as stream: FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/google/home/sdf/src/linux/Documentation/netlink/specs/ethtool.yaml' Fixes: f3d07b02b2b8 ("tools: ynl: ethtool testing tool") Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Link: https://lore.kernel.org/r/20230413012252.184434-1-rrameshbabu@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: throw a more meaningful exception if family not supportedJakub Kicinski2023-04-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cli.py currently throws a pure KeyError if kernel doesn't support a netlink family. Users who did not write ynl (hah) may waste their time investigating what's wrong with the Python code. Improve the error message: Traceback (most recent call last): File "/home/kicinski/devel/linux/tools/net/ynl/lib/ynl.py", line 362, in __init__ self.family = GenlFamily(self.yaml['name']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kicinski/devel/linux/tools/net/ynl/lib/ynl.py", line 331, in __init__ self.genl_family = genl_family_name_to_id[family_name] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ KeyError: 'netdev' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/kicinski/devel/linux/./tools/net/ynl/cli.py", line 52, in <module> main() File "/home/kicinski/devel/linux/./tools/net/ynl/cli.py", line 31, in main ynl = YnlFamily(args.spec, args.schema) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kicinski/devel/linux/tools/net/ynl/lib/ynl.py", line 364, in __init__ raise Exception(f"Family '{self.yaml['name']}' not supported by the kernel") Exception: Family 'netdev' not supported by the kernel Signed-off-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/r/20230407145609.297525-1-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
* tools: ynl: ethtool testing toolStanislav Fomichev2023-03-303-0/+444
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is what I've been using to see whether the spec makes sense. A small subset of getters (mostly the unprivileged ones) is implemented. Some setters (channels) also work. Setters for messages with bitmasks are not implemented. Initially I was trying to make this tool look 1:1 like real ethtool, but eventually gave up :-) Sample output: $ ./tools/net/ynl/ethtool enp0s31f6 Settings for enp0s31f6: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: no Supports auto-negotiation: yes Supported FEC modes: Not reported Speed: Unknown! Duplex: Unknown! (255) Auto-negotiation: on Port: Twisted Pair PHYAD: 2 Transceiver: Internal MDI-X: Unknown (auto) Current message level: drv probe link Link detected: no Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: replace print with NlErrorStanislav Fomichev2023-03-301-3/+9
| | | | | | | | | Instead of dumping the error on the stdout, make the callee and opportunity to decide what to do with it. This is mostly for the ethtool testing. Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: support byte-order in cliStanislav Fomichev2023-03-302-12/+24
| | | | | | | Used by ethtool spec. Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: Add fixed-header support to ynlDonald Hunter2023-03-282-12/+33
| | | | | | | | | | Add support for netlink families that add an optional fixed header structure after the genetlink header and before any attributes. The fixed-header can be specified on a per op basis, or once for all operations, which serves as a default value that can be overridden. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: Add struct attr decoding to ynlDonald Hunter2023-03-282-1/+16
| | | | | | | Add support for decoding attributes that contain C structs. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: Add C array attribute decoding to ynlDonald Hunter2023-03-282-3/+22
| | | | | | | | | Add support for decoding C arrays from binay blobs in genetlink-legacy messages. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: Add struct parsing to nlspecDonald Hunter2023-03-281-0/+43
| | | | | | | | Add python classes for struct definitions to nlspec Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: default to treating enums as flags for mask generationJakub Kicinski2023-03-272-5/+6
| | | | | | | | | | | | | | I was a bit too optimistic in commit bf51d27704c9 ("tools: ynl: fix get_mask utility routine"), not every mask we use is necessarily coming from an enum of type "flags". We also allow flipping an enum into flags on per-attribute basis. That's done by the 'enum-as-flags' property of an attribute. Restore this functionality, it's not currently used by any in-tree family. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: ynl: Add missing types to encode/decodeMichal Michalik2023-03-271-0/+6
| | | | | | | | | | | | While testing the tool I noticed we miss the u16 type on payload create. On the code inspection it turned out we miss also u64 - add them. We also miss the decoding of u16 despite the fact `NlAttr` class supports it - add it. Signed-off-by: Michal Michalik <michal.michalik@intel.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: ynl: add the Python requirements.txt fileMichal Michalik2023-03-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is a good practice to state explicitly which are the required Python packages needed in a particular project to run it. The most commonly used way is to store them in the `requirements.txt` file*. *URL: https://pip.pypa.io/en/stable/reference/requirements-file-format/ Currently user needs to figure out himself that Python needs `PyYAML` and `jsonschema` (and theirs requirements) packages to use the tool. Add the `requirements.txt` for user convenience. How to use it: 1) (optional) Create and activate empty virtual environment: python3.X -m venv venv3X source ./venv3X/bin/activate 2) Install all the required packages: pip install -r requirements.txt or python -m pip install -r requirements.txt 3) Run the script! The `requirements.txt` file was tested for: * Python 3.6 * Python 3.8 * Python 3.10 Signed-off-by: Michal Michalik <michal.michalik@intel.com> Link: https://lore.kernel.org/r/20230323190802.32206-1-michal.michalik@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2023-03-241-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 6e9d51b1a5cb ("net/mlx5e: Initialize link speed to zero") 1bffcea42926 ("net/mlx5e: Add devlink hairpin queues parameters") https://lore.kernel.org/all/20230324120623.4ebbc66f@canb.auug.org.au/ https://lore.kernel.org/all/20230321211135.47711-1-saeed@kernel.org/ Adjacent changes: drivers/net/phy/phy.c 323fe43cf9ae ("net: phy: Improved PHY error reporting in state machine") 4203d84032e2 ("net: phy: Ensure state transitions are processed from phy_stop()") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * tools: ynl: Fix genlmsg header encoding formatsDonald Hunter2023-03-221-3/+3
| | | | | | | | | | | | | | | | | | | | The pack strings use 'b' signed char for cmd and version but struct genlmsghdr defines them as unsigned char. Use 'B' instead. Fixes: 4e4480e89c47 ("tools: ynl: move the cli and netlink code around") Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://lore.kernel.org/r/20230319193803.97453-1-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | ynl: allow to encode u8 attrJiri Pirko2023-03-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Playing with dpll netlink, I came across following issue: $ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml --do pin-set --json '{"id": 0, "pin-idx": 1, "pin-state": 1}' Traceback (most recent call last): File "tools/net/ynl/cli.py", line 52, in <module> main() File "tools/net/ynl/cli.py", line 40, in main reply = ynl.do(args.do, attrs) File "tools/net/ynl/lib/ynl.py", line 520, in do return self._op(method, vals) File "tools/net/ynl/lib/ynl.py", line 476, in _op msg += self._add_attr(op.attr_set.name, name, value) File "tools/net/ynl/lib/ynl.py", line 344, in _add_attr raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}') Exception: Unknown type at dpll pin-state 1 u8 I'm not that familiar with ynl code, but from a quick peek, I suspect that couple other types are missing for both encoding and decoding. Ignoring those here as I'm scratching my local itch only. Fix the issue by adding u8 attr packing. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20230322154242.1739136-1-jiri@resnulli.us Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | tools: ynl: skip the explicit op array size when not neededJakub Kicinski2023-03-211-1/+3
|/ | | | | | | | | | Jiri suggests it reads more naturally to skip the explicit array size when possible. When we export the symbol we want to make sure that the size is right but for statics its not needed. Link: https://lore.kernel.org/r/20230321044159.1031040-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* ynl: make the tooling check the licenseJakub Kicinski2023-03-162-6/+15
| | | | | | | | | | | The (only recently documented) expectation is that all specs are under a certain license, but we don't actually enforce it. What's worse we then go ahead and assume the license was right, outputting the expected license into generated files. Fixes: 37d9df224d1e ("ynl: re-license uniformly under GPL-2.0 OR BSD-3-Clause") Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* ynl: broaden the license even moreJakub Kicinski2023-03-161-4/+4
| | | | | | | | | | | | | I relicensed Netlink spec code to GPL-2.0 OR BSD-3-Clause but we still put a slightly different license on the uAPI header than the rest of the code. Use the Linux-syscall-note on all the specs and all generated code. It's moot for kernel code, but should not hurt. This way the licenses match everywhere. Cc: Chuck Lever <chuck.lever@oracle.com> Fixes: 37d9df224d1e ("ynl: re-license uniformly under GPL-2.0 OR BSD-3-Clause") Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: make definitions optional againJakub Kicinski2023-03-161-1/+2
| | | | | | | | definitions are optional, commit in question breaks cli for ethtool. Fixes: 6517a60b0307 ("tools: ynl: move the enum classes to shared code") Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: fix get_mask utility routineLorenzo Bianconi2023-03-101-4/+2
| | | | | | | | | Fix get_mask utility routine in order to take into account possible gaps in the elements list. Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: fix render-max for flags definitionLorenzo Bianconi2023-03-101-3/+8
| | | | | | | | | | Properly manage render-max property for flags definition type introducing mask value and setting it to (last_element << 1) - 1 instead of adding max value set to last_element + 1 Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: fix enum-as-flags in the generic CLIJakub Kicinski2023-03-082-9/+7
| | | | | | | | | | | | Lorenzo points out that the generic CLI is broken for the netdev family. When I added the support for documentation of enums (and sparse enums) the client script was not updated. It expects the values in enum to be a list of names, now it can also be a dict (YAML object). Reported-by: Lorenzo Bianconi <lorenzo@kernel.org> Fixes: e4b48ed460d3 ("tools: ynl: add a completely generic client") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: move the enum classes to shared codeJakub Kicinski2023-03-083-89/+121
| | | | | | | | Move bulk of the EnumSet and EnumEntry code to shared code for reuse by cli. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* ynl: re-license uniformly under GPL-2.0 OR BSD-3-ClauseJakub Kicinski2023-03-076-8/+9
| | | | | | | | | | | | | | I was intending to make all the Netlink Spec code BSD-3-Clause to ease the adoption but it appears that: - I fumbled the uAPI and used "GPL WITH uAPI note" there - it gives people pause as they expect GPL in the kernel As suggested by Chuck re-license under dual. This gives us benefit of full BSD freedom while fulfilling the broad "kernel is under GPL" expectations. Link: https://lore.kernel.org/all/20230304120108.05dd44c5@kernel.org/ Link: https://lore.kernel.org/r/20230306200457.3903854-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: use 1 as the default for first entry in attrs/opsJakub Kicinski2023-03-032-5/+8
| | | | | | | | | | | Pretty much all families use value: 1 or reserve as unspec the first entry in attribute set and the first operation. Make this the default. Update documentation (the doc for values of operations just refers back to doc for attrs so updating only attrs). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: ynl: fully inherit attrs in subsetsJakub Kicinski2023-03-031-8/+15
| | | | | | | | | | To avoid having to repeat the entire definition of an attribute (including the value) use the Attr object from the original set. In fact this is already the documented expectation. Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: net: add __pycache__ to gitignoreJakub Kicinski2023-02-241-0/+1
| | | | | | | | | Python will generate its customary cache when running ynl scripts: ?? tools/net/ynl/lib/__pycache__/ Reported-by: Chuck Lever III <chuck.lever@oracle.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: re-raise the exception instead of printingJakub Kicinski2023-02-241-3/+1
| | | | | | | | | traceback.print_exception() seems tricky to call, we're missing some argument, so re-raise instead. Reported-by: Chuck Lever III <chuck.lever@oracle.com> Fixes: 3aacf8281336 ("tools: ynl: add an object hierarchy to represent parsed spec") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: fix single attribute structs with attr 0 onlyJakub Kicinski2023-02-241-1/+1
| | | | | | | | | | | | | Chuck run into an issue with a single-element attr-set which only has an attr with value of 0. The search for max attr in a struct records attrs with value larger than 0 only (max_val is set to 0 at the start). Adjust the comparison, alternatively max_val could be init'ed to -1. Somehow picking the last attr of a value seems like a good idea in general. Reported-by: Chuck Lever III <chuck.lever@oracle.com> Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: net: use python3 explicitlyJakub Kicinski2023-01-312-2/+2
| | | | | | | | The scripts require Python 3 and some distros are dropping Python 2 support. Reported-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: load jsonschema on demandJakub Kicinski2023-01-312-1/+14
| | | | | | | | | | | The CLI script tries to validate jsonschema by default. It's seems better to validate too many times than too few. However, when copying the scripts to random servers having to install jsonschema is tedious. Load jsonschema via importlib, and let the user opt out. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: use operation names from spec on the CLIJakub Kicinski2023-01-312-4/+11
| | | | | | | | | | | | | | | | | When I wrote the first version of the Python code I was quite excited that we can generate class methods directly from the spec. Unfortunately we need to use valid identifiers for method names (specifically no dashes are allowed). Don't reuse those names on the CLI, it's much more natural to use the operation names exactly as listed in the spec. Instead of: ./cli --do rings_get use: ./cli --do rings-get Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: support pretty printing bad attribute namesJakub Kicinski2023-01-311-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | One of my favorite features of the Netlink specs is that they make decoding structured extack a ton easier. Implement pretty printing bad attribute names in YNL. For example it will now say: 'bad-attr': '.header.flags' rather than the useless: 'bad-attr-offs': 32 Proof: $ ./cli.py --spec ethtool.yaml --do rings_get \ --json '{"header":{"dev-index":1, "flags":4}}' Netlink error: Invalid argument nl_len = 68 (52) nl_flags = 0x300 nl_type = 2 error: -22 extack: {'msg': 'reserved bit set', 'bad-attr': '.header.flags'} Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: support multi-attrJakub Kicinski2023-01-311-7/+14
| | | | | | | Ethtool uses mutli-attr, add the support to YNL. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: support directional enum-model in CLIJakub Kicinski2023-01-311-4/+4
| | | | | | | | Support families which use different IDs for messages to and from the kernel. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: add support for types needed by ethtoolJakub Kicinski2023-01-311-1/+10
| | | | | | | | Ethtool needs support for handful of extra types. It doesn't have the definitions section yet. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: use the common YAML loading and validation codeJakub Kicinski2023-01-312-232/+142
| | | | | | | Adapt the common object hierarchy in code gen and CLI. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: add an object hierarchy to represent parsed specJakub Kicinski2023-01-312-1/+304
| | | | | | | | | There's a lot of copy and pasting going on between the "cli" and code gen when it comes to representing the parsed spec. Create a library which both can use. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: move the cli and netlink code aroundJakub Kicinski2023-01-313-1/+6
| | | | | | | | | | | | | Move the CLI code out of samples/ and the library part of it into tools/net/ynl/lib/. This way we can start sharing some code with the code gen. Initially I thought that code gen is too C-specific to share anything but basic stuff like calculating values for enums can easily be shared. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl-gen: prevent do / dump reorderingJakub Kicinski2023-01-311-2/+2
| | | | | | | | | | An earlier fix tried to address generated code jumping around one code-gen run to another. Turns out dict()s are already ordered since Python 3.7, the problem is that we iterate over operation modes using a set(). Sets are unordered in Python. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: store ops in ordered dict to avoid random orderingJakub Kicinski2023-01-261-1/+2
| | | | | | | | | When rendering code we should walk the ops in the order in which they are declared in the spec. This is both more intuitive and prevents code from jumping around when hashing in the dict changes. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: rename ops_list -> msg_listJakub Kicinski2023-01-261-4/+6
| | | | | | | | | | | ops_list contains all the operations, but the main iteration use case is to walk only ops which define attrs. Rename ops_list to msg_list, because now it looks like the contents are the same, just the format is different. While at it convert from tuple to just keys, none of the users care about the name of the op. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: support kdocs for flags in code generationJakub Kicinski2023-01-261-17/+20
| | | | | | | | | | | Lorenzo reports that after switching from enum to flags netdev family lost ability to render kdoc (and the enum contents got generally garbled). Combine the flags and enum handling in uAPI handling. Reported-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* tools: ynl: add a completely generic clientJakub Kicinski2023-01-242-0/+581
| | | | | | | | | | | | | Add a CLI sample which can take in arbitrary request in JSON format, convert it to Netlink and do the inverse for output. It's meant as a development tool primarily and perhaps for selftests which need to tickle netlink in a special way. Acked-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
* net: add basic C code generators for NetlinkJakub Kicinski2023-01-242-0/+2403
| | | | | | | | | | | | | Code generators to turn Netlink specs into C code. I'm definitely not proud of it. The main generator is in Python, there's a bash script to regen all code-gen'ed files in tree after making spec changes. Acked-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
* tools: rename tools/net directory to tools/bpfJakub Kicinski2017-10-046-2656/+0
| | | | | | | | | | | | | | We currently only have BPF tools in the tools/net directory. We are about to add more BPF tools there, not necessarily networking related, rename the directory and related Makefile targets to bpf. Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: bpf_jit_disasm: Handle large images.David Daney2017-06-141-11/+26
| | | | | | | | | Dynamically allocate memory so that JIT images larger than the size of the statically allocated array can be handled. Signed-off-by: David Daney <david.daney@cavium.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: bpf_jit_disasm: Add option to dump JIT image to a file.David Daney2017-04-131-4/+36
| | | | | | | | | | | | | | | | | | When debugging the JIT on an embedded platform or cross build environment, libbfd may not be available, making it impossible to run bpf_jit_disasm natively. Add an option to emit a binary image of the JIT code to a file. This file can then be disassembled off line. Typical usage in this case might be (pasting mips64 dmesg output to cat command): $ cat > jit.raw $ bpf_jit_disasm -f jit.raw -O jit.bin $ mips64-linux-gnu-objdump -D -b binary -m mips:isa64r2 -EB jit.bin Signed-off-by: David Daney <david.daney@cavium.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* tools: bpf_jit_disasm: check for klogctl failureColin Ian King2016-05-081-0/+3
| | | | | | | | | klogctl can fail and return -ve len, so check for this and return NULL to avoid passing a (size_t)-1 to malloc. Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>