Skip to contentSkip to conversation

netlink: specs: add big-endian byte-order for u32 IPv4 addresses

PATCH Applied Hangbin Liu 3 participants 7 messages Nov 25, 2025 – Nov 27, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 1064d521d177 ("netlink: specs: support ipv4-or-v6 for dual-stack fields")
---
 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
index abcbaa73fa9d..163a106c41bb 100644
@@ -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
index ca22c68ca691..6beeb6ee5adf 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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")

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/

#2 lore raw

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

#3 lore raw
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.

#4 lore raw
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: 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:

(quoted diff) +0 -2
-
  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:

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

#5 lore raw
In reply to Asbjørn Sloth Tønnesen
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

#6 lore raw
In reply to Hangbin Liu
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