mbox series

[net-next,v4,0/4] netlink: Add nftables spec w/ multi messages

Message ID 20240418104737.77914-1-donald.hunter@gmail.com
Headers show
Series netlink: Add nftables spec w/ multi messages | expand

Message

Donald Hunter April 18, 2024, 10:47 a.m. UTC
This series adds a ynl spec for nftables and extends ynl with a --multi
command line option that makes it possible to send transactional batches
for nftables.

This series includes a patch for nfnetlink which adds ACK processing for
batch begin/end messages. If you'd prefer that to be sent separately to
nf-next then I can do so, but I included it here so that it gets seen in
context.

An example of usage is:

./tools/net/ynl/cli.py \
 --spec Documentation/netlink/specs/nftables.yaml \
 --multi batch-begin '{"res-id": 10}' \
 --multi newtable '{"name": "test", "nfgen-family": 1}' \
 --multi newchain '{"name": "chain", "table": "test", "nfgen-family": 1}' \
 --multi batch-end '{"res-id": 10}'
[None, None, None, None]

It can also be used for bundling get requests:

./tools/net/ynl/cli.py \
 --spec Documentation/netlink/specs/nftables.yaml \
 --multi gettable '{"name": "test", "nfgen-family": 1}' \
 --multi getchain '{"name": "chain", "table": "test", "nfgen-family": 1}' \
 --output-json
[{"name": "test", "use": 1, "handle": 1, "flags": [],
 "nfgen-family": 1, "version": 0, "res-id": 2},
 {"table": "test", "name": "chain", "handle": 1, "use": 0,
 "nfgen-family": 1, "version": 0, "res-id": 2}]

There are 2 issues that may be worth resolving:

 - ynl reports errors by raising an NlError exception so only the first
   error gets reported. This could be changed to add errors to the list
   of responses so that multiple errors could be reported.

 - If any message does not get a response (e.g. batch-begin w/o patch 2)
   then ynl waits indefinitely. A recv timeout could be added which
   would allow ynl to terminate.

v3 -> v4:
 - fix the underlying extack decoding bug and drop the
   workaround patch

v2 -> v3:
 - update the ynl multi code to match the latest return value
   semantics of ynl
 - add a ynl patch to handle acks that use req_value
 - update the nfnetlink patch based on feedback from Pablo
 - move nfnetlink patch to end of series

v1 -> v2:
 - add a patch to nfnetlink to process ACKs for batch begin/end
 - handle multiple responses correctly

Donald Hunter (4):
  doc/netlink/specs: Add draft nftables spec
  tools/net/ynl: Fix extack decoding for directional ops
  tools/net/ynl: Add multi message support to ynl
  netfilter: nfnetlink: Handle ACK flags for batch messages

 Documentation/netlink/specs/nftables.yaml | 1264 +++++++++++++++++++++
 net/netfilter/nfnetlink.c                 |    5 +
 tools/net/ynl/cli.py                      |   25 +-
 tools/net/ynl/lib/ynl.py                  |   82 +-
 4 files changed, 1346 insertions(+), 30 deletions(-)
 create mode 100644 Documentation/netlink/specs/nftables.yaml

Comments

patchwork-bot+netdevbpf@kernel.org April 23, 2024, 12:53 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 18 Apr 2024 11:47:33 +0100 you wrote:
> This series adds a ynl spec for nftables and extends ynl with a --multi
> command line option that makes it possible to send transactional batches
> for nftables.
> 
> This series includes a patch for nfnetlink which adds ACK processing for
> batch begin/end messages. If you'd prefer that to be sent separately to
> nf-next then I can do so, but I included it here so that it gets seen in
> context.
> 
> [...]

Here is the summary with links:
  - [net-next,v4,1/4] doc/netlink/specs: Add draft nftables spec
    https://git.kernel.org/netdev/net-next/c/1ee731687137
  - [net-next,v4,2/4] tools/net/ynl: Fix extack decoding for directional ops
    https://git.kernel.org/netdev/net-next/c/0a966d606c68
  - [net-next,v4,3/4] tools/net/ynl: Add multi message support to ynl
    https://git.kernel.org/netdev/net-next/c/ba8be00f68f5
  - [net-next,v4,4/4] netfilter: nfnetlink: Handle ACK flags for batch messages
    https://git.kernel.org/netdev/net-next/c/bf2ac490d28c

You are awesome, thank you!