[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240225174619.18990-4-donald.hunter@gmail.com>
Date: Sun, 25 Feb 2024 17:46:18 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: netdev@...r.kernel.org,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Jacob Keller <jacob.e.keller@...el.com>,
Jiri Pirko <jiri@...nulli.us>,
Stanislav Fomichev <sdf@...gle.com>
Cc: donald.hunter@...hat.com,
Donald Hunter <donald.hunter@...il.com>
Subject: [RFC net-next 3/4] tools/net/ynl: Add batch message encoding for nftables
The nftables families use batch operations for create, update and delete
operations. For ops that have 'is-batch: true' wrap them in begin-batch
and end-batch messages.
Signed-off-by: Donald Hunter <donald.hunter@...il.com>
---
tools/net/ynl/lib/ynl.py | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index c6fc9588c235..3a4af3c5a6a7 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -841,6 +841,12 @@ class YnlFamily(SpecFamily):
msg = _genl_msg_finalize(msg)
return msg
+ def _encode_batch_message(self, name, nl_flags, req_seq):
+ msg = self.yaml.get('operations').get(name)
+ op = self.ops[msg['operation']]
+ params = msg['parameters']
+ return self._encode_message(op, params, nl_flags, req_seq)
+
def _op(self, method, vals, flags=None, dump=False):
op = self.ops[method]
@@ -851,7 +857,16 @@ class YnlFamily(SpecFamily):
nl_flags |= Netlink.NLM_F_DUMP
req_seq = random.randint(1024, 65535)
- msg = self._encode_message(op, vals, nl_flags, req_seq)
+ msg = b''
+
+ is_batch = op['do']['request'].get('is-batch', False)
+ if is_batch:
+ msg += self._encode_batch_message('begin-batch', nl_flags, req_seq)
+
+ msg += self._encode_message(op, vals, nl_flags, req_seq)
+
+ if is_batch:
+ msg += self._encode_batch_message('end-batch', nl_flags, req_seq)
self.sock.send(msg, 0)
--
2.42.0
Powered by blists - more mailing lists