Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Incorrect VXLAN port endianess #192

Open
Tuetuopay opened this issue Oct 19, 2021 · 0 comments
Open

Incorrect VXLAN port endianess #192

Tuetuopay opened this issue Oct 19, 2021 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Tuetuopay
Copy link
Contributor

Tuetuopay commented Oct 19, 2021

During serialization, the VXLAN port is serialized using the host endianess, which is incorrect as netlink uses network endianess, which is big endian. This breaks on little-endian architectures, such as x86.

Example on x86 (handle setup omitted):

handle.link().add().vxlan("vxlan10".into(), 10).port(4789).execute().await?;

will result in a vxlan interface with a dstport of 46354, which is 4789 with the two bytes swapped:

$ ip -d l show dev vxlan10
9: vxlan10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 7e:e7:d4:c7:ec:2c brd ff:ff:ff:ff:ff:ff promiscuity 1 minmtu 68 maxmtu 65535
    vxlan id 10 local 172.16.0.1 srcport 0 0 dstport 46354 nolearning ttl auto ageing 300 udpcsum noudp6zerocsumtx noudp6zerocsumrx

Interesting this is, parsing is done correctly by using u16::from_be_bytes().

Doing .port(u16::from_be(4789)) makes the link come with the proper port.

@little-dude little-dude added bug Something isn't working good first issue Good for newcomers labels Nov 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants