netlink: specs: add big-endian byte-order for u32 IPv4 addresses
Subsystems (4)
PATCH 1/1 netlink: specs: add big-endian byte-order for u32 IPv4 addresses
The fix commit converted several IPv4 address attributes from binary to u32, but forgot to specify byte-order: big-endian. Without this, YNL tools display IPv4 addresses incorrectly due to host-endian interpretation.
Add the missing byte-order: big-endian to all affected u32 IPv4 address fields to ensure correct parsing and display.
--- Documentation/netlink/specs/rt-addr.yaml | 1 + Documentation/netlink/specs/rt-link.yaml | 2 ++ 2 files changed, 3 insertions(+)
Documentation/netlink/specs/rt-addr.yaml +1 -0
@@ -97,6 +97,7 @@ attribute-sets: - name: broadcast type: u32 + byte-order: big-endian display-hint: ipv4 - name: anycast
Documentation/netlink/specs/rt-link.yaml +2 -0
@@ -1869,6 +1869,7 @@ attribute-sets: - name: remote type: u32 + byte-order: big-endian display-hint: ipv4 - name: ttl
@@ -1987,6 +1988,7 @@ attribute-sets: - name: 6rd-relay-prefix type: u32 + byte-order: big-endian display-hint: ipv4 - name: 6rd-prefixlen
Signature · 1 line
2.50.1
Quoted 11 lines · Hangbin Liu
The fix commit converted several IPv4 address attributes from binary to u32, but forgot to specify byte-order: big-endian. Without this, YNL tools display IPv4 addresses incorrectly due to host-endian interpretation.
Add the missing byte-order: big-endian to all affected u32 IPv4 address fields to ensure correct parsing and display.
Fixes 1064d521d177 ("netlink: specs: support ipv4-or-v6 for dual-stack fields")Reported-by Paolo Abeni <[email protected]>Signed-off-by Hangbin Liu <[email protected]>
LGTM
I also checked how consistently defined the fields using the ipv6 display helper are, and it looks like they could use some realignment too. Obviously not for this fix.
git grep -C6 'display-hint.*ipv6$' Documentation/netlink/specs/
Hi,
Quoted 4 lines · Asbjørn Sloth Tønnesen
I also checked how consistently defined the fields using the ipv6 display helper are, and it looks like they could use some realignment too. Obviously not for this fix.
git grep -C6 'display-hint.*ipv6$'
Documentation/netlink/specs/
The ip6gre spec shows
-
name: local
display-hint: ipv6
-
name: remote
display-hint: ipv6
The dump result looks good. So for others ipv6 field, what alignment should we use? Should we add checks: min-len: 16? Do we need byte-order: big-endian?
Thanks
Hangbin
Quoted 15 lines · Hangbin Liu
Hi,
Quoted 4 lines · Asbjørn Sloth Tønnesen
I also checked how consistently defined the fields using the ipv6 display helper are, and it looks like they could use some realignment too. Obviously not for this fix.
git grep -C6 'display-hint.*ipv6$'
Documentation/netlink/specs/The ip6gre spec shows
(quoted diff) +0
-2- name: local display-hint: ipv6 - name: remote display-hint: ipv6
Quoted 1 line
The dump result looks good.
Those two are defined in linkinfo-gre6-attrs, which is declared as a subset-of linkinfo-gre-attrs.
In linkinfo-gre-attrs they are declared as:
-
name: local
type: binary
display-hint: ipv4-or-v6
-
name: remote
type: binary
display-hint: ipv4-or-v6
I have tested with deleting one or the other's display-helper, and at least in cli.py, this kind of display-hint overloading works.
Quoted 2 lines
So for others ipv6 field, what alignment should we
use? Should we add checks: min-len: 16? Do we need byte-order: big-endian?
IPv6 is always big-endian, the marking first becomes needed when/if we make them an u128 type. Until then it would just be nice if either all or none of them had the big-endian marking.
I prefer exact-len over min-len. The current tally is:
$ git grep 'len.*: 16' Documentation/netlink/specs/ | cut -d: -f2- | sed -e 's/^ *//' | sort | uniq -c
7 exact-len: 16
5 len: 16
6 min-len: 16
(assuming that only IPv6 has a length of 16)"len: 16" as used in ovs_flow's ipv6-src and ipv6-dst only works because they are struct members, not attributes.
Quoted 44 lines · Asbjørn Sloth Tønnesen
Quoted 15 lines · Hangbin Liu
Hi,
Quoted 4 lines · Asbjørn Sloth Tønnesen
I also checked how consistently defined the fields using the ipv6 display helper are, and it looks like they could use some realignment too. Obviously not for this fix.
git grep -C6 'display-hint.*ipv6$'
Documentation/netlink/specs/The ip6gre spec shows
(quoted diff) +0
-2- name: local display-hint: ipv6 - name: remote display-hint: ipv6Quoted 1 line
The dump result looks good.
Those two are defined in linkinfo-gre6-attrs, which is declared as a subset-of linkinfo-gre-attrs.
In linkinfo-gre-attrs they are declared as:
(quoted diff) +0
-2- name: local type: binary display-hint: ipv4-or-v6 - name: remote type: binary display-hint: ipv4-or-v6I have tested with deleting one or the other's display-helper, and at least in
cli.py, this kind of display-hint overloading works.Quoted 2 lines
So for others ipv6 field, what alignment should we
use? Should we add checks: min-len: 16? Do we need byte-order: big-endian?IPv6 is always big-endian, the marking first becomes needed when/if we make them an u128 type. Until then it would just be nice if either all or none of them had the big-endian marking.
I prefer exact-len over min-len. The current tally is:
Quoted 8 lines
$ git grep 'len.*: 16' Documentation/netlink/specs/ | cut -d: -f2- | sed -e 's/^ *//' | sort | uniq -c 7 exact-len: 16 5 len: 16 6 min-len: 16 (assuming that only IPv6 has a length of 16)"len: 16" as used in ovs_flow's ipv6-src and ipv6-dst only works because they are struct members, not attributes.
Hmm, I just found that I tried to do that 2 years ago[1] but forgot why I give up... I saw you have fixed the fou part with 9f9581ba74a9 ("netlink: specs: fou: change local-v6/peer-v6 check").
Let's alignment others this time.
[1] https://lore.kernel.org/netdev/[email protected]/
Thanks
Hangbin
Quoted 10 lines · Asbjørn Sloth Tønnesen
I prefer exact-len over min-len. The current tally is:
$ git grep 'len.*: 16' Documentation/netlink/specs/ | cut -d: -f2- | sed -e 's/^ *//' | sort | uniq -c 7 exact-len: 16 5 len: 16 6 min-len: 16 (assuming that only IPv6 has a length of 16)"len: 16" as used in ovs_flow's ipv6-src and ipv6-dst only works because they are struct members, not attributes.
Talking about the ovs, it's looks like that the struct members are used in flow metadata, like in ip_tun_from_nlattr():
case OVS_TUNNEL_KEY_ATTR_IPV6_SRC:
SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.src,
nla_get_in6_addr(a), is_mask);
ipv6 = true;
break;While attributes are used in __ip_tun_to_nlattr():
case AF_INET6:
if (!ipv6_addr_any(&output->u.ipv6.src) &&
nla_put_in6_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV6_SRC,
&output->u.ipv6.src))
return -EMSGSIZE;So I think we can also convert the ipv6-src/ipv6-dst using exact-len? WDYT?
Thanks
Hangbin
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 25 Nov 2025 11:20:48 +0000 you wrote:
The fix commit converted several IPv4 address attributes from binary to u32, but forgot to specify byte-order: big-endian. Without this, YNL tools display IPv4 addresses incorrectly due to host-endian interpretation.
Add the missing byte-order: big-endian to all affected u32 IPv4 address fields to ensure correct parsing and display.
[...]
Here is the summary with links:
- [net-next] netlink: specs: add big-endian byte-order for u32 IPv4 addresses
https://git.kernel.org/netdev/net-next/c/651765e8d527
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html