Page MenuHomeFreeBSD

if_vxlan: fix byteorder of source port
ClosedPublic

Authored by p.mousavizadeh_protonmail.com on Fri, Oct 10, 12:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 2, 7:43 AM
Unknown Object (File)
Sun, Nov 2, 7:43 AM
Unknown Object (File)
Sun, Nov 2, 7:42 AM
Unknown Object (File)
Sun, Nov 2, 7:39 AM
Unknown Object (File)
Mon, Oct 27, 6:56 AM
Unknown Object (File)
Sun, Oct 26, 9:31 PM
Unknown Object (File)
Sun, Oct 26, 5:41 PM
Unknown Object (File)
Sat, Oct 25, 7:51 PM

Details

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 Not Applicable
Unit
Tests Not Applicable

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.

sys/net/if_vxlan.c
2433

How about moving the htons() into vxlan_encap_header() so all input variables are consistent without extra comments?

sys/net/if_vxlan.c
2433

I can pass fvxlsa directly into vxlan_encap_header() and call vxlan_pick_source_port() inside it too, since ports aren't required in vxlan_encap[4|6]. However, this makes the existing code more complex that it is.

IMHO, changing the current version of this patch or adding extra comments to this complex driver doesn't add value.
I'm in the middle of adding another NVO-based interface driver and I think these two could merge duplicate functions into another header for any future changes that NVO3 (IETF) brings.

I'm not a committer yet, I would appreciate it if someone could commit this.

This revision was automatically updated to reflect the committed changes.