* [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary
2023-12-15 3:50 [PATCH net-next 0/3] ynl-gen: update check format Hangbin Liu
@ 2023-12-15 3:50 ` Hangbin Liu
2023-12-16 2:06 ` Jakub Kicinski
2023-12-15 3:50 ` [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks Hangbin Liu
2023-12-15 3:50 ` [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr Hangbin Liu
2 siblings, 1 reply; 15+ messages in thread
From: Hangbin Liu @ 2023-12-15 3:50 UTC (permalink / raw)
To: netdev; +Cc: Jakub Kicinski, Paolo Abeni, Hangbin Liu
As the description of 'struct nla_policy', the len means the maximum length
of string, binary. Or minimum length of attribute payload for others.
But most time we only use it for string and binary.
On the other hand, the NLA_POLICY_{EXACT_LEN, MIN_LEN, MAX_LEN} should only
be used for binary only.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
Documentation/netlink/genetlink-c.yaml | 7 ++++--
Documentation/netlink/genetlink-legacy.yaml | 7 ++++--
Documentation/netlink/genetlink.yaml | 7 ++++--
Documentation/netlink/netlink-raw.yaml | 7 ++++--
include/net/netlink.h | 1 +
tools/net/ynl/ynl-gen-c.py | 25 ++++++++++-----------
6 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml
index c58f7153fcf8..66083cdbf43e 100644
--- a/Documentation/netlink/genetlink-c.yaml
+++ b/Documentation/netlink/genetlink-c.yaml
@@ -199,14 +199,17 @@ properties:
max:
description: Max value for an integer attribute.
$ref: '#/$defs/len-or-limit'
+ len:
+ description: Max length for a string or a binary attribute.
+ $ref: '#/$defs/len-or-define'
min-len:
description: Min length for a binary attribute.
$ref: '#/$defs/len-or-define'
max-len:
- description: Max length for a string or a binary attribute.
+ description: Max length for a binary attribute.
$ref: '#/$defs/len-or-define'
exact-len:
- description: Exact length for a string or a binary attribute.
+ description: Exact length for a binary attribute.
$ref: '#/$defs/len-or-define'
sub-type: *attr-type
display-hint: &display-hint
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 938703088306..9a9ab7468469 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -242,14 +242,17 @@ properties:
max:
description: Max value for an integer attribute.
$ref: '#/$defs/len-or-limit'
+ len:
+ description: Max length for a string or a binary attribute.
+ $ref: '#/$defs/len-or-define'
min-len:
description: Min length for a binary attribute.
$ref: '#/$defs/len-or-define'
max-len:
- description: Max length for a string or a binary attribute.
+ description: Max length for a binary attribute.
$ref: '#/$defs/len-or-define'
exact-len:
- description: Exact length for a string or a binary attribute.
+ description: Exact length for a binary attribute.
$ref: '#/$defs/len-or-define'
sub-type: *attr-type
display-hint: *display-hint
diff --git a/Documentation/netlink/genetlink.yaml b/Documentation/netlink/genetlink.yaml
index 3283bf458ff1..9be071a622cf 100644
--- a/Documentation/netlink/genetlink.yaml
+++ b/Documentation/netlink/genetlink.yaml
@@ -166,14 +166,17 @@ properties:
max:
description: Max value for an integer attribute.
$ref: '#/$defs/len-or-limit'
+ len:
+ description: Max length for a string or a binary attribute.
+ $ref: '#/$defs/len-or-define'
min-len:
description: Min length for a binary attribute.
$ref: '#/$defs/len-or-define'
max-len:
- description: Max length for a string or a binary attribute.
+ description: Max length for a binary attribute.
$ref: '#/$defs/len-or-define'
exact-len:
- description: Exact length for a string or a binary attribute.
+ description: Exact length for a binary attribute.
$ref: '#/$defs/len-or-define'
sub-type: *attr-type
display-hint: &display-hint
diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
index ad5395040765..2c393b234511 100644
--- a/Documentation/netlink/netlink-raw.yaml
+++ b/Documentation/netlink/netlink-raw.yaml
@@ -241,14 +241,17 @@ properties:
min:
description: Min value for an integer attribute.
type: integer
+ len:
+ description: Max length for a string or a binary attribute.
+ $ref: '#/$defs/len-or-define'
min-len:
description: Min length for a binary attribute.
$ref: '#/$defs/len-or-define'
max-len:
- description: Max length for a string or a binary attribute.
+ description: Max length for a binary attribute.
$ref: '#/$defs/len-or-define'
exact-len:
- description: Exact length for a string or a binary attribute.
+ description: Exact length for a binary attribute.
$ref: '#/$defs/len-or-define'
sub-type: *attr-type
display-hint: *display-hint
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 28039e57070a..e7f6e22282d3 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -464,6 +464,7 @@ struct nla_policy {
.max = _len \
}
#define NLA_POLICY_MIN_LEN(_len) NLA_POLICY_MIN(NLA_BINARY, _len)
+#define NLA_POLICY_MAX_LEN(_len) NLA_POLICY_MAX(NLA_BINARY, _len)
/**
* struct nl_info - netlink source information
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 7fc1aa788f6f..88a2048d668d 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -427,13 +427,10 @@ class TypeString(Type):
return f'.type = YNL_PT_NUL_STR, '
def _attr_policy(self, policy):
- if 'exact-len' in self.checks:
- mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')'
- else:
- mem = '{ .type = ' + policy
- if 'max-len' in self.checks:
- mem += ', .len = ' + str(self.get_limit('max-len'))
- mem += ', }'
+ mem = '{ .type = ' + policy
+ if 'len' in self.checks:
+ mem += ', .len = ' + str(self.get_limit('len'))
+ mem += ', }'
return mem
def attr_policy(self, cw):
@@ -481,13 +478,15 @@ class TypeBinary(Type):
def _attr_policy(self, policy):
if 'exact-len' in self.checks:
mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')'
+ elif 'max-len' in self.checks:
+ mem = 'NLA_POLICY_MAX_LEN(' + str(self.checks['max-len']) + ')'
+ elif 'min-len' in self.checks:
+ mem = 'NLA_POLICY_MIN_LEN(' + str(self.checks['min-len']) + ')'
else:
- mem = '{ '
- if len(self.checks) == 1 and 'min-len' in self.checks:
- mem += '.len = ' + str(self.get_limit('min-len'))
- elif len(self.checks) == 0:
- mem += '.type = NLA_BINARY'
- else:
+ mem = '{ .type = ' + policy
+ if len(self.checks) == 1 and 'len' in self.checks:
+ mem += '.len = ' + str(self.get_limit('len'))
+ elif len(self.checks) > 1:
raise Exception('One or more of binary type checks not implemented, yet')
mem += ', }'
return mem
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary
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
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2023-12-16 2:06 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Paolo Abeni
On Fri, 15 Dec 2023 11:50:07 +0800 Hangbin Liu wrote:
> As the description of 'struct nla_policy', the len means the maximum length
> of string, binary. Or minimum length of attribute payload for others.
> But most time we only use it for string and binary.
The meaning of 'len' in nla_policy is confusing to people writing new
families. IIRC I used max-len / min-len / extact-len and not len on
purpose in the YAML, so that there's no confusion what means what for
which type...
Obviously it is slightly confusing for people like you who convert
the existing families to YAML specs, but the risk of bugs seems lower
there. So I'd prefer to stick to the existing set of options.
Is the existing code gen incorrect or just hard to wrap one's head
around?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary
2023-12-16 2:06 ` Jakub Kicinski
@ 2023-12-16 8:35 ` Hangbin Liu
2023-12-18 22:22 ` Jakub Kicinski
0 siblings, 1 reply; 15+ messages in thread
From: Hangbin Liu @ 2023-12-16 8:35 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, Paolo Abeni
On Fri, Dec 15, 2023 at 06:06:03PM -0800, Jakub Kicinski wrote:
> On Fri, 15 Dec 2023 11:50:07 +0800 Hangbin Liu wrote:
> > As the description of 'struct nla_policy', the len means the maximum length
> > of string, binary. Or minimum length of attribute payload for others.
> > But most time we only use it for string and binary.
>
> The meaning of 'len' in nla_policy is confusing to people writing new
> families. IIRC I used max-len / min-len / extact-len and not len on
> purpose in the YAML, so that there's no confusion what means what for
> which type...
>
> Obviously it is slightly confusing for people like you who convert
> the existing families to YAML specs, but the risk of bugs seems lower
> there. So I'd prefer to stick to the existing set of options.
>
> Is the existing code gen incorrect or just hard to wrap one's head
> around?
>
The max-len / min-len / extact-len micro are used by binary. For string we
need to use "len" to define the max length. e.g.
static const struct nla_policy
team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = {
[TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, },
[TEAM_ATTR_OPTION_NAME] = {
.type = NLA_STRING,
.len = TEAM_STRING_MAX_LEN,
},
Thanks
Hangbin
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary
2023-12-16 8:35 ` Hangbin Liu
@ 2023-12-18 22:22 ` Jakub Kicinski
2023-12-19 10:01 ` Hangbin Liu
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2023-12-18 22:22 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Paolo Abeni
On Sat, 16 Dec 2023 16:35:40 +0800 Hangbin Liu wrote:
> The max-len / min-len / extact-len micro are used by binary. For string we
> need to use "len" to define the max length. e.g.
>
> static const struct nla_policy
> team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = {
> [TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, },
> [TEAM_ATTR_OPTION_NAME] = {
> .type = NLA_STRING,
> .len = TEAM_STRING_MAX_LEN,
> },
max-len / min-len / extact-len are just the names in the spec.
We can put the value provided in the spec as max-len inside
nla_policy as len, given that for string spec::max-len == policy::len
Am I confused?
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary
2023-12-18 22:22 ` Jakub Kicinski
@ 2023-12-19 10:01 ` Hangbin Liu
0 siblings, 0 replies; 15+ messages in thread
From: Hangbin Liu @ 2023-12-19 10:01 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, Paolo Abeni
On Mon, Dec 18, 2023 at 02:22:09PM -0800, Jakub Kicinski wrote:
> On Sat, 16 Dec 2023 16:35:40 +0800 Hangbin Liu wrote:
> > The max-len / min-len / extact-len micro are used by binary. For string we
> > need to use "len" to define the max length. e.g.
> >
> > static const struct nla_policy
> > team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = {
> > [TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, },
> > [TEAM_ATTR_OPTION_NAME] = {
> > .type = NLA_STRING,
> > .len = TEAM_STRING_MAX_LEN,
> > },
>
> max-len / min-len / extact-len are just the names in the spec.
> We can put the value provided in the spec as max-len inside
> nla_policy as len, given that for string spec::max-len == policy::len
>
> Am I confused?
Yes, we can do that. While this looks like another magic. When user set max-len
for a string type in the yaml spec. After converting to c code, it's .len
attribute. This still makes user confused.
Anyway, this is just a matter of choosing apple or banana. I'm OK to using
the current YAML spec policy.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks
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-15 3:50 ` Hangbin Liu
2023-12-16 2:08 ` Jakub Kicinski
2023-12-15 3:50 ` [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr Hangbin Liu
2 siblings, 1 reply; 15+ messages in thread
From: Hangbin Liu @ 2023-12-15 3:50 UTC (permalink / raw)
To: netdev; +Cc: Jakub Kicinski, Paolo Abeni, Hangbin Liu
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
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks
2023-12-15 3:50 ` [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks Hangbin Liu
@ 2023-12-16 2:08 ` Jakub Kicinski
2023-12-16 8:44 ` Hangbin Liu
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2023-12-16 2:08 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Paolo Abeni
On Fri, 15 Dec 2023 11:50:08 +0800 Hangbin Liu wrote:
> - pattern: ^[0-9A-Za-z_]+( - 1)?$
> + pattern: ^[0-9A-Za-z_-]+( - 1)?$
Why the '-' ? Could you add an example of the define you're trying to
match to the commit message?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks
2023-12-16 2:08 ` Jakub Kicinski
@ 2023-12-16 8:44 ` Hangbin Liu
2023-12-18 22:23 ` Jakub Kicinski
0 siblings, 1 reply; 15+ messages in thread
From: Hangbin Liu @ 2023-12-16 8:44 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, Paolo Abeni
On Fri, Dec 15, 2023 at 06:08:24PM -0800, Jakub Kicinski wrote:
> On Fri, 15 Dec 2023 11:50:08 +0800 Hangbin Liu wrote:
> > - pattern: ^[0-9A-Za-z_]+( - 1)?$
> > + pattern: ^[0-9A-Za-z_-]+( - 1)?$
>
> Why the '-' ? Could you add an example of the define you're trying to
> match to the commit message?
For team driver, there is a define like:
#define TEAM_STRING_MAX_LEN 32
So I'd like to define it in yaml like:
definitions:
-
name: string-max-len
type: const
value: 32
And use it in the attribute-sets like
attribute-sets:
-
name: attr-option
name-prefix: team-attr-option-
attributes:
-
name: unspec
type: unused
value: 0
-
name: name
type: string
checks:
len: string-max-len
With this patch it will be converted to
[TEAM_ATTR_OPTION_NAME] = { .type = NLA_STRING, .len = TEAM_STRING_MAX_LEN, }
Thanks
Hangbin
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks
2023-12-16 8:44 ` Hangbin Liu
@ 2023-12-18 22:23 ` Jakub Kicinski
0 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2023-12-18 22:23 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Paolo Abeni
On Sat, 16 Dec 2023 16:44:30 +0800 Hangbin Liu wrote:
> On Fri, Dec 15, 2023 at 06:08:24PM -0800, Jakub Kicinski wrote:
> > On Fri, 15 Dec 2023 11:50:08 +0800 Hangbin Liu wrote:
> > > - pattern: ^[0-9A-Za-z_]+( - 1)?$
> > > + pattern: ^[0-9A-Za-z_-]+( - 1)?$
> >
> > Why the '-' ? Could you add an example of the define you're trying to
> > match to the commit message?
> For team driver, there is a define like:
>
> #define TEAM_STRING_MAX_LEN 32
>
> So I'd like to define it in yaml like:
>
> definitions:
> -
> name: string-max-len
> type: const
> value: 32
>
> And use it in the attribute-sets like
>
> attribute-sets:
> -
> name: attr-option
> name-prefix: team-attr-option-
> attributes:
> -
> name: unspec
> type: unused
> value: 0
> -
> name: name
> type: string
> checks:
> len: string-max-len
>
> With this patch it will be converted to
>
> [TEAM_ATTR_OPTION_NAME] = { .type = NLA_STRING, .len = TEAM_STRING_MAX_LEN, }
Ah, I see. The spec match needs to work on names before they go thru
c_upper(). The patch makes sense:
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr
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-15 3:50 ` [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks Hangbin Liu
@ 2023-12-15 3:50 ` Hangbin Liu
2023-12-16 2:09 ` Jakub Kicinski
2023-12-18 11:40 ` Davide Caratti
2 siblings, 2 replies; 15+ messages in thread
From: Hangbin Liu @ 2023-12-15 3:50 UTC (permalink / raw)
To: netdev; +Cc: Jakub Kicinski, Paolo Abeni, Hangbin Liu
We should use the exact-len instead of min-len for IPv6 address.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
Documentation/netlink/specs/fou.yaml | 4 ++--
Documentation/netlink/specs/mptcp.yaml | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/netlink/specs/fou.yaml b/Documentation/netlink/specs/fou.yaml
index 0af5ab842c04..d472fd5055bd 100644
--- a/Documentation/netlink/specs/fou.yaml
+++ b/Documentation/netlink/specs/fou.yaml
@@ -52,7 +52,7 @@ attribute-sets:
name: local_v6
type: binary
checks:
- min-len: 16
+ exact-len: 16
-
name: peer_v4
type: u32
@@ -60,7 +60,7 @@ attribute-sets:
name: peer_v6
type: binary
checks:
- min-len: 16
+ exact-len: 16
-
name: peer_port
type: u16
diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink/specs/mptcp.yaml
index 49f90cfb4698..2f694b79c3a7 100644
--- a/Documentation/netlink/specs/mptcp.yaml
+++ b/Documentation/netlink/specs/mptcp.yaml
@@ -223,7 +223,7 @@ attribute-sets:
name: saddr6
type: binary
checks:
- min-len: 16
+ exact-len: 16
-
name: daddr4
type: u32
@@ -232,7 +232,7 @@ attribute-sets:
name: daddr6
type: binary
checks:
- min-len: 16
+ exact-len: 16
-
name: sport
type: u16
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr
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 11:40 ` Davide Caratti
1 sibling, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2023-12-16 2:09 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Paolo Abeni
On Fri, 15 Dec 2023 11:50:09 +0800 Hangbin Liu wrote:
> We should use the exact-len instead of min-len for IPv6 address.
It does make sense, but these families historically used min-len..
Not sure if it's worth changing this now or we risk regressions.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr
2023-12-16 2:09 ` Jakub Kicinski
@ 2023-12-16 8:48 ` Hangbin Liu
2023-12-18 22:24 ` Jakub Kicinski
0 siblings, 1 reply; 15+ messages in thread
From: Hangbin Liu @ 2023-12-16 8:48 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, Paolo Abeni, Davide Caratti
On Fri, Dec 15, 2023 at 06:09:11PM -0800, Jakub Kicinski wrote:
> On Fri, 15 Dec 2023 11:50:09 +0800 Hangbin Liu wrote:
> > We should use the exact-len instead of min-len for IPv6 address.
>
> It does make sense, but these families historically used min-len..
> Not sure if it's worth changing this now or we risk regressions.
The addr6 in mptcp.yaml also use exact-len. I don't think the IPv6 address
could be larger than 16 bytes. So the min-len check looks incorrect.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr
2023-12-16 8:48 ` Hangbin Liu
@ 2023-12-18 22:24 ` Jakub Kicinski
0 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2023-12-18 22:24 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Paolo Abeni, Davide Caratti
On Sat, 16 Dec 2023 16:48:01 +0800 Hangbin Liu wrote:
> On Fri, Dec 15, 2023 at 06:09:11PM -0800, Jakub Kicinski wrote:
> > On Fri, 15 Dec 2023 11:50:09 +0800 Hangbin Liu wrote:
> > > We should use the exact-len instead of min-len for IPv6 address.
> >
> > It does make sense, but these families historically used min-len..
> > Not sure if it's worth changing this now or we risk regressions.
>
> The addr6 in mptcp.yaml also use exact-len. I don't think the IPv6 address
> could be larger than 16 bytes. So the min-len check looks incorrect.
I understand, what I'm saying is that the nla_policy before we started
using specs was buggy, so we kept the bugginess in the conversion.
But it should be fine, so we can change it now and hope for the best..
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr
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-18 11:40 ` Davide Caratti
1 sibling, 0 replies; 15+ messages in thread
From: Davide Caratti @ 2023-12-18 11:40 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, Jakub Kicinski, Paolo Abeni
hello Hangbin!
for the mptcp part: I didn't convert mptcp events, here transition
from min-len to exact-len should not generate issues at all.
Acked-by: Davide Caratti <dcaratti@redhat.com>
On Fri, Dec 15, 2023 at 4:50 AM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> We should use the exact-len instead of min-len for IPv6 address.
>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
> Documentation/netlink/specs/fou.yaml | 4 ++--
> Documentation/netlink/specs/mptcp.yaml | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/netlink/specs/fou.yaml b/Documentation/netlink/specs/fou.yaml
> index 0af5ab842c04..d472fd5055bd 100644
> --- a/Documentation/netlink/specs/fou.yaml
> +++ b/Documentation/netlink/specs/fou.yaml
> @@ -52,7 +52,7 @@ attribute-sets:
> name: local_v6
> type: binary
> checks:
> - min-len: 16
> + exact-len: 16
> -
> name: peer_v4
> type: u32
> @@ -60,7 +60,7 @@ attribute-sets:
> name: peer_v6
> type: binary
> checks:
> - min-len: 16
> + exact-len: 16
> -
> name: peer_port
> type: u16
> diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink/specs/mptcp.yaml
> index 49f90cfb4698..2f694b79c3a7 100644
> --- a/Documentation/netlink/specs/mptcp.yaml
> +++ b/Documentation/netlink/specs/mptcp.yaml
> @@ -223,7 +223,7 @@ attribute-sets:
> name: saddr6
> type: binary
> checks:
> - min-len: 16
> + exact-len: 16
> -
> name: daddr4
> type: u32
> @@ -232,7 +232,7 @@ attribute-sets:
> name: daddr6
> type: binary
> checks:
> - min-len: 16
> + exact-len: 16
> -
> name: sport
> type: u16
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread