Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vxlan port range #44

Merged
merged 2 commits into from
Aug 21, 2023
Merged

Conversation

maiqueb
Copy link
Contributor

@maiqueb maiqueb commented Aug 3, 2023

Two things were wrong when attempting to create a vxlan link specifying its src port range:

  • we were using native endianness (instead of big endian) to encode the port min / max ranges
  • we were not updating the buffer pointer to where we were encoding the min/max values, and thus the "max" was overwriting the "min" value, causing an invalid netlink message.

Unit tests are added.

Fixes: #43
Depends-on: #42

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #44 (7c56679) into main (927bdd7) will increase coverage by 0.33%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #44      +/-   ##
==========================================
+ Coverage   47.28%   47.62%   +0.33%     
==========================================
  Files          74       74              
  Lines        6349     6371      +22     
==========================================
+ Hits         3002     3034      +32     
+ Misses       3347     3337      -10     
Files Changed Coverage Δ
src/rtnl/link/nlas/link_infos.rs 57.17% <100.00%> (+1.46%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@cathay4t cathay4t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kernel code vxlan_core.c has:

	struct ifla_vxlan_port_range ports = {
		.low =  htons(vxlan->cfg.port_min),
		.high = htons(vxlan->cfg.port_max),
	};

Approving.

@cathay4t cathay4t enabled auto-merge (rebase) August 21, 2023 08:54
Signed-off-by: Miguel Duarte Barroso <[email protected]>
Since we were not updating the `buffer` variable when writing to it, the "max"
part of the range was over-writing the "min", which caused the netlink message
to be considered invalid.

By adjusting the buffer to where we write, the netlink add message was
properly processed, and the link successfully created.

Unit tests were added to assert the expected behavior.

Signed-off-by: Miguel Duarte Barroso <[email protected]>
auto-merge was automatically disabled August 21, 2023 09:08

Head branch was pushed to by a user without write access

@cathay4t cathay4t merged commit 55de269 into rust-netlink:main Aug 21, 2023
5 checks passed
@maiqueb maiqueb deleted the fix-vxlan-port-range branch August 21, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create Vxlan link when defining src port range
2 participants