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

Convert InfoBond::ArpValidate into an enum. #110

Merged

Conversation

Gilnaa
Copy link
Contributor

@Gilnaa Gilnaa commented Apr 1, 2024

Closes #80

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 31.57895% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 63.82%. Comparing base (3e16f9c) to head (ae7a60a).
Report is 5 commits behind head on main.

Current head ae7a60a differs from pull request most recent head 236fbe9

Please upload reports for the commit 236fbe9 to get more accurate results.

Files Patch % Lines
src/link/link_info/bond.rs 31.57% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #110      +/-   ##
==========================================
- Coverage   63.97%   63.82%   -0.16%     
==========================================
  Files         140      140              
  Lines        8617     8653      +36     
==========================================
+ Hits         5513     5523      +10     
- Misses       3104     3130      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/link/link_info/bond.rs Outdated Show resolved Hide resolved
@Gilnaa
Copy link
Contributor Author

Gilnaa commented Apr 1, 2024

Also, it seems that these PRs steadily lower the code-coverage.
What meaningful tests can I add?
Use nlmon to record ip link add bond0 type bond mode blablablah and make sure we produce an equivalent output?

Is there place for tests that open an actual socket and try to create rtnl objects; is this problematic with CI running us in a non-privileged context?

@cathay4t
Copy link
Member

cathay4t commented Apr 8, 2024

Also, it seems that these PRs steadily lower the code-coverage. What meaningful tests can I add? Use nlmon to record ip link add bond0 type bond mode blablablah and make sure we produce an equivalent output?

I have document on how to capture netlink package and convert it into Vec at:

https://github.com/rust-netlink/netlink-packet-route/blob/main/README.md

You may setup up a bond with arp_validate value changed to non-default one. Then capture the netlink package kernel replied to the request of ip -d link show bond0. The unit test should parse this Vec into structs/enums, and also emit() should generate identical Vec<u8> as kernel did.

Is there place for tests that open an actual socket and try to create rtnl objects; is this problematic with CI running us in a non-privileged context?

For this crate, there is no real netlink communication to kernel. Because this crate only handle parsing and emitting netlink package itself, no socket communication code included. All tests in this crate are unit test, no privilege required.

@little-dude
Copy link
Contributor

@Gilnaa I just added a test in my own MR, in case you want to see how it looks: #98

I used wireshark to get the hex dump of a captured netlink packet, and isolate the different packet parts. It's very tedious, and you don't have to go into so much detail though.

@Gilnaa
Copy link
Contributor Author

Gilnaa commented Apr 24, 2024

Thank you both!

Unfortunately life got in the way;
will hopefully get back to it eventually

@Gilnaa Gilnaa closed this Apr 24, 2024
@Gilnaa Gilnaa reopened this May 26, 2024
@Gilnaa Gilnaa force-pushed the gilnaa/convert-arp-validate-to-enum branch from dbb355f to 1f51fc8 Compare May 26, 2024 19:52
@Gilnaa
Copy link
Contributor Author

Gilnaa commented May 26, 2024

Unfortunately life got in the way; will hopefully get back to it eventually

Life got out of the way!

I've added a test as instructed; dump is taken of tcpdump, with the last few fields removed for brevity, and the length patched in the header.


I did notice that serializing stats64 will result in a slightly different payload (I think the length field was different, probably counted padding or something).
Unrelated to this change, though.

EDIT: Yep, the kernel-sent message claimed that the length of Stats64 is 196, and omitted the last 4 fields in stats64.rs (rx_compressed, tx_compressed, rx_nohandler, rx_otherhost_dropped).
Probably due to the link type, nothing to worry about.

@Gilnaa Gilnaa force-pushed the gilnaa/convert-arp-validate-to-enum branch from 1f51fc8 to 236fbe9 Compare May 26, 2024 19:55
src/link/tests/bond.rs Outdated Show resolved Hide resolved
src/link/tests/bond.rs Outdated Show resolved Hide resolved
src/link/tests/bond.rs Outdated Show resolved Hide resolved
@Gilnaa Gilnaa force-pushed the gilnaa/convert-arp-validate-to-enum branch from 236fbe9 to 6300363 Compare August 5, 2024 14:14
@cathay4t cathay4t force-pushed the gilnaa/convert-arp-validate-to-enum branch from 6300363 to d432894 Compare September 4, 2024 08:58
@cathay4t
Copy link
Member

cathay4t commented Sep 4, 2024

I have amend the patch:

  • Rebased to latest main branch.
  • Changed enum ArpValidate to enum BondArpValidate.

@cathay4t cathay4t force-pushed the gilnaa/convert-arp-validate-to-enum branch from d432894 to 87c4997 Compare September 4, 2024 09:01
@cathay4t cathay4t force-pushed the gilnaa/convert-arp-validate-to-enum branch from 87c4997 to e12f9be Compare September 4, 2024 09:02
@cathay4t cathay4t enabled auto-merge (rebase) September 4, 2024 09:02
@cathay4t cathay4t merged commit c91b2e9 into rust-netlink:main Sep 4, 2024
8 checks passed
@Gilnaa Gilnaa deleted the gilnaa/convert-arp-validate-to-enum branch September 4, 2024 09:49
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.

Convert InfoBond::ArpValidate(u32) to enum
3 participants