From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks
Date: Fri, 15 Dec 2023 11:50:08 +0800 [thread overview]
Message-ID: <20231215035009.498049-3-liuhangbin@gmail.com> (raw)
In-Reply-To: <20231215035009.498049-1-liuhangbin@gmail.com>
Support using defines in checks so we don't need to use hard code
number for the string, binary length.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
Documentation/netlink/genetlink-c.yaml | 2 +-
Documentation/netlink/genetlink-legacy.yaml | 2 +-
Documentation/netlink/genetlink.yaml | 2 +-
Documentation/netlink/netlink-raw.yaml | 2 +-
tools/net/ynl/ynl-gen-c.py | 7 +++++++
5 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml
index 66083cdbf43e..82a891e6ed68 100644
--- a/Documentation/netlink/genetlink-c.yaml
+++ b/Documentation/netlink/genetlink-c.yaml
@@ -11,7 +11,7 @@ $defs:
minimum: 0
len-or-define:
type: [ string, integer ]
- pattern: ^[0-9A-Za-z_]+( - 1)?$
+ pattern: ^[0-9A-Za-z_-]+( - 1)?$
minimum: 0
len-or-limit:
# literal int or limit based on fixed-width type e.g. u8-min, u16-max, etc.
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 9a9ab7468469..28317b1818ad 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -11,7 +11,7 @@ $defs:
minimum: 0
len-or-define:
type: [ string, integer ]
- pattern: ^[0-9A-Za-z_]+( - 1)?$
+ pattern: ^[0-9A-Za-z_-]+( - 1)?$
minimum: 0
len-or-limit:
# literal int or limit based on fixed-width type e.g. u8-min, u16-max, etc.
diff --git a/Documentation/netlink/genetlink.yaml b/Documentation/netlink/genetlink.yaml
index 9be071a622cf..813cd4eb47df 100644
--- a/Documentation/netlink/genetlink.yaml
+++ b/Documentation/netlink/genetlink.yaml
@@ -11,7 +11,7 @@ $defs:
minimum: 0
len-or-define:
type: [ string, integer ]
- pattern: ^[0-9A-Za-z_]+( - 1)?$
+ pattern: ^[0-9A-Za-z_-]+( - 1)?$
minimum: 0
len-or-limit:
# literal int or limit based on fixed-width type e.g. u8-min, u16-max, etc.
diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
index 2c393b234511..d59670743d10 100644
--- a/Documentation/netlink/netlink-raw.yaml
+++ b/Documentation/netlink/netlink-raw.yaml
@@ -11,7 +11,7 @@ $defs:
minimum: 0
len-or-define:
type: [ string, integer ]
- pattern: ^[0-9A-Za-z_]+( - 1)?$
+ pattern: ^[0-9A-Za-z_-]+( - 1)?$
minimum: 0
# Schema for specs
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 88a2048d668d..fba65ba2c716 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -85,9 +85,16 @@ class Type(SpecAttr):
delattr(self, "enum_name")
def get_limit(self, limit, default=None):
+ defines = []
+ for const in self.family['definitions']:
+ if const['type'] == 'const':
+ defines.append(const['name'])
+
value = self.checks.get(limit, default)
if value is None:
return value
+ elif value in defines:
+ return c_upper(f"{self.family['name']}-{value}")
if not isinstance(value, int):
value = limit_to_number(value)
return value
--
2.43.0
next prev parent reply other threads:[~2023-12-15 3:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 3:50 [PATCH net-next 0/3] ynl-gen: update check format Hangbin Liu
2023-12-15 3:50 ` [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary Hangbin Liu
2023-12-16 2:06 ` Jakub Kicinski
2023-12-16 8:35 ` Hangbin Liu
2023-12-18 22:22 ` Jakub Kicinski
2023-12-19 10:01 ` Hangbin Liu
2023-12-15 3:50 ` Hangbin Liu [this message]
2023-12-16 2:08 ` [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks Jakub Kicinski
2023-12-16 8:44 ` Hangbin Liu
2023-12-18 22:23 ` Jakub Kicinski
2023-12-15 3:50 ` [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr Hangbin Liu
2023-12-16 2:09 ` Jakub Kicinski
2023-12-16 8:48 ` Hangbin Liu
2023-12-18 22:24 ` Jakub Kicinski
2023-12-18 11:40 ` Davide Caratti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231215035009.498049-3-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.