• 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
cli.py 3.42 KB