Page MenuHomeFreeBSD

if_vxlan: fix byteorder of source port
AcceptedPublic

Authored by p.mousavizadeh_protonmail.com on Fri, Oct 10, 12:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 11, 1:56 PM
Unknown Object (File)
Sat, Oct 11, 1:56 PM
Unknown Object (File)
Sat, Oct 11, 6:25 AM
Unknown Object (File)
Sat, Oct 11, 5:39 AM
Unknown Object (File)
Fri, Oct 10, 10:17 PM
Unknown Object (File)
Fri, Oct 10, 8:13 PM
Unknown Object (File)
Fri, Oct 10, 5:48 PM
Unknown Object (File)
Fri, Oct 10, 2:31 PM

Details

Reviewers
glebius
kp
zlei
Group Reviewers
network
Summary

Fix the htons byteorder of vxlan packets after
vxlan_pick_source_port picks a source port during encapsulation.

Test Plan

Check the source port of outgoing packets before and after
applying the patch:

ifconfig vxlan create inet6 2001:db8:a::/48 vni 1 vxlanremote
2001:db8::a vxlanlocal 2001:db8::b vxlanportrange 1234 1234 up

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 67695
Build 64578: arc lint + arc unit

Event Timeline

kp added a subscriber: kp.

LGTM

This revision is now accepted and ready to land.Fri, Oct 10, 12:56 PM

Looks good to me.

Well, I do not like the inconsistency, that vxlan_encap_header() requires network byte order of srcport and dstport, but vxlan_pick_source_port() generates the host byte order. Given the dstport is from sin[6]_port which is already in network byte order, then it makes no senses to convert it back and forth.

adrian added inline comments.
sys/net/if_vxlan.c
2433

Hi!

Would you at least please consider documenting what the return value here? That way it's clearer to people who are working on this that there are endian expectations?

Thanks!

sys/net/if_vxlan.c
2433

Generally we prefer host order, so I think no comments on vxlan_pick_source_port() is good.

I'd rather prefer to add comments on vxlan_encap_header(), since it has parameter ipoff which is in host byte order but the parameters srcport and dstport require network byte order.