Skip to contentSkip to conversation

netlink: specs: mptcp: fix port endianness

PATCH Applied Asbjørn Sloth Tønnesen 5 participants 5 messages Sep 11, 2024 – Sep 12, 2024

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

PATCH 1/1 netlink: specs: mptcp: fix port endianness

The MPTCP port attribute is in host endianness, but was documented as big-endian in the ynl specification.

Below are two examples from net/mptcp/pm_netlink.c showing that the attribute is converted to/from host endianness for use with netlink.

Import from netlink:
addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]))

Export to netlink:
nla_put_u16(skb, MPTCP_PM_ADDR_ATTR_PORT, ntohs(addr->port))

Where addr->port is defined as __be16.

No functional change intended.

Fixes bc8aeb2045e2 ("Documentation: netlink: add a YAML spec for mptcp")
---
 Documentation/netlink/specs/mptcp_pm.yaml | 1 -
 1 file changed, 1 deletion(-)
Documentation/netlink/specs/mptcp_pm.yaml +0 -1
index af525ed29792..30d8342cacc8 100644
@@ -109,7 +109,6 @@ attribute-sets:
       -
         name: port
         type: u16
-        byte-order: big-endian
       -
         name: flags
         type: u32
Signature · 1 line
2.45.2
#1 lore raw

Hi Asbjørn,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/10808837330

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a918e18ee437
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=889241

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

Reviewed-by on v1 1/1
#2 lore raw
In reply to Asbjørn Sloth Tønnesen

hello Asbjørn,

Quoted 12 lines · Asbjørn Sloth Tønnesen

The MPTCP port attribute is in host endianness, but was documented as big-endian in the ynl specification.

Below are two examples from net/mptcp/pm_netlink.c showing that the attribute is converted to/from host endianness for use with netlink.

Import from netlink:
addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]))

Export to netlink:
nla_put_u16(skb, MPTCP_PM_ADDR_ATTR_PORT, ntohs(addr->port))

Quoted 6 lines

Where addr->port is defined as __be16.

No functional change intended.

Fixes bc8aeb2045e2 ("Documentation: netlink: add a YAML spec for mptcp")

not sure why we are doing addresses in network byte order and ports in host byte order for endpoints. But it's like this since the very beginning, so this host ordering in spec is correct.

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Asbjørn Sloth Tønnesen

Hi Asbjørn,

Quoted 9 lines · Asbjørn Sloth Tønnesen

The MPTCP port attribute is in host endianness, but was documented as big-endian in the ynl specification.

Below are two examples from net/mptcp/pm_netlink.c showing that the attribute is converted to/from host endianness for use with netlink.

Import from netlink:
addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]))

Quoted 6 lines

Export to netlink:
nla_put_u16(skb, MPTCP_PM_ADDR_ATTR_PORT, ntohs(addr->port))

Where addr->port is defined as __be16.

No functional change intended.

Good catch. Indeed, this port attribute is supposed to be in host endianness.

This patch can be applied in netdev directly.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#4 lore raw
In reply to Asbjørn Sloth Tønnesen
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 11 Sep 2024 09:10:02 +0000 you wrote:

The MPTCP port attribute is in host endianness, but was documented as big-endian in the ynl specification.

Below are two examples from net/mptcp/pm_netlink.c showing that the attribute is converted to/from host endianness for use with netlink.

Import from netlink:
addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]))

[...]

Here is the summary with links:
- [net] netlink: specs: mptcp: fix port endianness

    https://git.kernel.org/netdev/net/c/09a45a555379

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html