lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251013165005.83659-7-ast@fiberby.net>
Date: Mon, 13 Oct 2025 16:50:03 +0000
From: Asbjørn Sloth Tønnesen <ast@...erby.net>
To: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Cc: Asbjørn Sloth Tønnesen <ast@...erby.net>,
	Alexei Starovoitov <ast@...nel.org>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>,
	Daniel Borkmann <daniel@...earbox.net>,
	Daniel Zahka <daniel.zahka@...il.com>,
	Donald Hunter <donald.hunter@...il.com>,
	Jacob Keller <jacob.e.keller@...el.com>,
	Jesper Dangaard Brouer <hawk@...nel.org>,
	Jiri Pirko <jiri@...nulli.us>,
	Joe Damato <jdamato@...tly.com>,
	John Fastabend <john.fastabend@...il.com>,
	Jonathan Corbet <corbet@....net>,
	Simon Horman <horms@...nel.org>,
	Stanislav Fomichev <sdf@...ichev.me>,
	Toke Høiland-Jørgensen <toke@...hat.com>,
	Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
	Willem de Bruijn <willemb@...gle.com>,
	bpf@...r.kernel.org,
	netdev@...r.kernel.org,
	linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH net-next 6/6] tools: ynl-gen: allow custom naming of render-max definitions

When `render-max` is set for an enum, then it generates either
(`__$pfx-MAX` and `$pfx-MAX`) or (`$pfx-MASK` for flags).

The count definition `__$pfx-MAX` can already be overridden via
`enum-cnt-name` in the spec.

This patch adds a new `enum-max-name` attribute which can be used
to override the names for either `$pfx-MAX` or `$pfx-MASK`.

The existing `enum-cnt-name` is only described for the genetlink-c
and genetlink-legacy protocols, so I have only added `enum-max-name`
for those protocols.

This doesn't change the generated output.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@...erby.net>
---

Alternatively `enum-max-name` should be added to all protocols, so
that genetlink families can also choose to eg. have these private
variables prefixed with "__". As NETDEV_XDP_ACT_MASK leaked into
xdp-tools [v1.4.0..v1.5.7], then if we want to change the default
names[1], then we would still need to be able to use an override
to keep the current NETDEV_XDP_ACT_MASK name in the netdev family.

[1] https://lore.kernel.org/netdev/20230614211715.01940bbd@kernel.org/
---
 Documentation/netlink/genetlink-c.yaml             | 3 +++
 Documentation/netlink/genetlink-legacy.yaml        | 3 +++
 Documentation/userspace-api/netlink/c-code-gen.rst | 7 +++++--
 tools/net/ynl/pyynl/ynl_gen_c.py                   | 6 ++++--
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml
index 5a234e9b5fa2e..755b24fb0c319 100644
--- a/Documentation/netlink/genetlink-c.yaml
+++ b/Documentation/netlink/genetlink-c.yaml
@@ -110,6 +110,9 @@ properties:
         enum-cnt-name:
           description: Name of the render-max counter enum entry.
           type: string
+        enum-max-name:
+          description: Name of the render-max max or mask enum entry.
+          type: string
         # End genetlink-c
 
   attribute-sets:
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 66fb8653a3442..ad4d69be6294e 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -124,6 +124,9 @@ properties:
         enum-cnt-name:
           description: Name of the render-max counter enum entry.
           type: string
+        enum-max-name:
+          description: Name of the render-max max or mask enum entry.
+          type: string
         # End genetlink-c
         # Start genetlink-legacy
         members:
diff --git a/Documentation/userspace-api/netlink/c-code-gen.rst b/Documentation/userspace-api/netlink/c-code-gen.rst
index 46415e6d646d2..413a56424012a 100644
--- a/Documentation/userspace-api/netlink/c-code-gen.rst
+++ b/Documentation/userspace-api/netlink/c-code-gen.rst
@@ -57,8 +57,11 @@ portion of the entry name.
 
 Boolean ``render-max`` controls creation of the max values
 (which are enabled by default for attribute enums). These max
-values are named ``__$pfx-MAX`` and ``$pfx-MAX``. The name
-of the first value can be overridden via ``enum-cnt-name`` property.
+values are named ``__$pfx-MAX`` and ``$pfx-MAX``, and can be
+overwritten via the properties ``enum-cnt-name`` and
+``enum-max-name`` respectively.
+For flags ``render-max`` will generate a mask with all flags set,
+which by default will be named ``$pfx-MASK``.
 
 Attributes
 ==========
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 5e1c702143d86..a1a0b559b431b 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -1067,8 +1067,10 @@ class EnumSet(SpecEnumSet):
         self.value_pfx = yaml.get('name-prefix', f"{family.ident_name}-{yaml['name']}-")
         self.header = yaml.get('header', None)
         self.enum_cnt_name = yaml.get('enum-cnt-name', f'--{self.value_pfx}max')
-        suffix = yaml['type'] == 'flags' and 'mask' or 'max'
-        self.enum_max_name = f'{self.value_pfx}{suffix}'
+        self.enum_max_name = yaml.get('enum-max-name', None)
+        if not self.enum_max_name:
+            suffix = yaml['type'] == 'flags' and 'mask' or 'max'
+            self.enum_max_name = f'{self.value_pfx}{suffix}'
 
         super().__init__(family, yaml)
 
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ