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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241113181023.2030098-2-sdf@fomichev.me>
Date: Wed, 13 Nov 2024 10:10:17 -0800
From: Stanislav Fomichev <sdf@...ichev.me>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	linux-kernel@...r.kernel.org,
	horms@...nel.org,
	donald.hunter@...il.com,
	andrew+netdev@...n.ch,
	kory.maincent@...tlin.com,
	sdf@...ichev.me,
	nicolas.dichtel@...nd.com
Subject: [PATCH net-next 1/7] ynl: support attr-cnt-name attribute in legacy definitions

This is similar to existing attr-cnt-name in the attributes
to allow changing the name of the 'count' enum entry.

Signed-off-by: Stanislav Fomichev <sdf@...ichev.me>
---
 Documentation/netlink/genetlink-legacy.yaml | 3 +++
 tools/net/ynl/ynl-gen-c.py                  | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 8db0e22fa72c..83f874ae7198 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -119,6 +119,9 @@ additionalProperties: False
           type: string
         # End genetlink-c
         # Start genetlink-legacy
+        attr-cnt-name:
+          description: Name of the render-max counter enum entry.
+          type: string
         members:
           description: List of struct members. Only scalars and strings members allowed.
           type: array
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index c48b69071111..210972b4796a 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -798,6 +798,7 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
             self.user_type = 'int'
 
         self.value_pfx = yaml.get('name-prefix', f"{family.ident_name}-{yaml['name']}-")
+        self.attr_cnt_name = yaml.get('attr-cnt-name', None)
 
         super().__init__(family, yaml)
 
@@ -2468,9 +2469,12 @@ _C_KW = {
                     max_val = f' = {enum.get_mask()},'
                     cw.p(max_name + max_val)
                 else:
+                    cnt_name = enum.attr_cnt_name
                     max_name = c_upper(name_pfx + 'max')
-                    cw.p('__' + max_name + ',')
-                    cw.p(max_name + ' = (__' + max_name + ' - 1)')
+                    if not cnt_name:
+                        cnt_name = '__' + c_upper(name_pfx + 'max')
+                    cw.p(cnt_name + ',')
+                    cw.p(max_name + ' = (' + cnt_name + ' - 1)')
             cw.block_end(line=';')
             cw.nl()
         elif const['type'] == 'const':
-- 
2.47.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ