1. 23 Apr, 2024 6 commits
    • Jakub Kicinski's avatar
      Merge branch 'netlink-add-nftables-spec-w-multi-messages' · 2557e2ec
      Jakub Kicinski authored
      Donald Hunter says:
      
      ====================
      netlink: Add nftables spec w/ multi messages
      
      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.
      ====================
      
      Link: https://lore.kernel.org/r/20240418104737.77914-1-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2557e2ec
    • Donald Hunter's avatar
      netfilter: nfnetlink: Handle ACK flags for batch messages · bf2ac490
      Donald Hunter authored
      The NLM_F_ACK flag is ignored for nfnetlink batch begin and end
      messages. This is a problem for ynl which wants to receive an ack for
      every message it sends, not just the commands in between the begin/end
      messages.
      
      Add processing for ACKs for begin/end messages and provide responses
      when requested.
      
      I have checked that iproute2, pyroute2 and systemd are unaffected by
      this change since none of them use NLM_F_ACK for batch begin/end.
      Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
      Link: https://lore.kernel.org/r/20240418104737.77914-5-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      bf2ac490
    • Donald Hunter's avatar
      tools/net/ynl: Add multi message support to ynl · ba8be00f
      Donald Hunter authored
      Add a "--multi <do-op> <json>" command line to ynl that makes it
      possible to add several operations to a single netlink request payload.
      The --multi command line option is repeated for each operation.
      
      This is used by the nftables family for transaction batches. For
      example:
      
      ./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}]
      Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
      Link: https://lore.kernel.org/r/20240418104737.77914-4-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      ba8be00f
    • Donald Hunter's avatar
      tools/net/ynl: Fix extack decoding for directional ops · 0a966d60
      Donald Hunter authored
      NetlinkProtocol.decode() was looking up ops by response value which breaks
      when it is used for extack decoding of directional ops. Instead, pass
      the op to decode().
      Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
      Link: https://lore.kernel.org/r/20240418104737.77914-3-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      0a966d60
    • Donald Hunter's avatar
      doc/netlink/specs: Add draft nftables spec · 1ee73168
      Donald Hunter authored
      Add a spec for nftables that has nearly complete coverage of the ops,
      but limited coverage of rule types and subexpressions.
      Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
      Link: https://lore.kernel.org/r/20240418104737.77914-2-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      1ee73168
    • Jakub Kicinski's avatar
      Merge branch 'for-uring-ubufops' into HEAD · af046fd1
      Jakub Kicinski authored
      Pavel Begunkov says:
      
      ====================
      implement io_uring notification (ubuf_info) stacking (net part)
      
      To have per request buffer notifications each zerocopy io_uring send
      request allocates a new ubuf_info. However, as an skb can carry only
      one uarg, it may force the stack to create many small skbs hurting
      performance in many ways.
      
      The patchset implements notification, i.e. an io_uring's ubuf_info
      extension, stacking. It attempts to link ubuf_info's into a list,
      allowing to have multiple of them per skb.
      
      liburing/examples/send-zerocopy shows up 6 times performance improvement
      for TCP with 4KB bytes per send, and levels it with MSG_ZEROCOPY. Without
      the patchset it requires much larger sends to utilise all potential.
      
      bytes  | before | after (Kqps)
      1200   | 195    | 1023
      4000   | 193    | 1386
      8000   | 154    | 1058
      ====================
      
      Link: https://lore.kernel.org/all/cover.1713369317.git.asml.silence@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      af046fd1
  2. 22 Apr, 2024 22 commits
  3. 20 Apr, 2024 12 commits