diff options
author | Donald Hunter <donald.hunter@gmail.com> | 2023-08-25 13:27:52 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-08-27 17:17:10 -0700 |
commit | 1768d8a767f8e7049407fe467364e7ea56f0bdce (patch) | |
tree | 6347e7422b0e439bfa14553746d557a82e631d2a /tools/net/ynl/lib | |
parent | 0493e56d021d371d3511159a38facbc92969c0f6 (diff) |
tools/net/ynl: Add support for create flags
Add support for using NLM_F_REPLACE, _EXCL, _CREATE and _APPEND flags
in requests.
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230825122756.7603-10-donald.hunter@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net/ynl/lib')
-rw-r--r-- | tools/net/ynl/lib/__init__.py | 4 | ||||
-rw-r--r-- | tools/net/ynl/lib/ynl.py | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/tools/net/ynl/lib/__init__.py b/tools/net/ynl/lib/__init__.py index 4b3797fe784b..f7eaa07783e7 100644 --- a/tools/net/ynl/lib/__init__.py +++ b/tools/net/ynl/lib/__init__.py @@ -2,7 +2,7 @@ from .nlspec import SpecAttr, SpecAttrSet, SpecEnumEntry, SpecEnumSet, \ SpecFamily, SpecOperation -from .ynl import YnlFamily +from .ynl import YnlFamily, Netlink __all__ = ["SpecAttr", "SpecAttrSet", "SpecEnumEntry", "SpecEnumSet", - "SpecFamily", "SpecOperation", "YnlFamily"] + "SpecFamily", "SpecOperation", "YnlFamily", "Netlink"] diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index cab84c407ba2..13c4b019a881 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -35,6 +35,10 @@ class Netlink: NLM_F_ACK = 4 NLM_F_ROOT = 0x100 NLM_F_MATCH = 0x200 + + NLM_F_REPLACE = 0x100 + NLM_F_EXCL = 0x200 + NLM_F_CREATE = 0x400 NLM_F_APPEND = 0x800 NLM_F_CAPPED = 0x100 @@ -654,10 +658,12 @@ class YnlFamily(SpecFamily): return op['do']['request']['attributes'].copy() - def _op(self, method, vals, dump=False): + def _op(self, method, vals, flags, dump=False): op = self.ops[method] nl_flags = Netlink.NLM_F_REQUEST | Netlink.NLM_F_ACK + for flag in flags or []: + nl_flags |= flag if dump: nl_flags |= Netlink.NLM_F_DUMP @@ -716,8 +722,8 @@ class YnlFamily(SpecFamily): return rsp[0] return rsp - def do(self, method, vals): - return self._op(method, vals) + def do(self, method, vals, flags): + return self._op(method, vals, flags) def dump(self, method, vals): - return self._op(method, vals, dump=True) + return self._op(method, vals, [], dump=True) |