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

support IFLA_VRF_PORT_TABLE attribute #98

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

little-dude
Copy link
Contributor

@little-dude little-dude commented Feb 24, 2024

Links that belong to a VRF carry the VRF table ID in the link info. For a VRF link we already had these attributes:

LinkInfo([Kind(Vrf), Data(Vrf([TableId(10)]))])

For ports attached to a VRF we now have:

LinkInfo([Kind(Veth), PortKind(Vrf), PortData(VrfPort([TableId(10)]))])

This tells us that this veth interface belong to the VRF with table ID 10.


To test this:

sudo ip link add vrf-blue type vrf table 10                                                            
sudo ip link set dev vrf-blue up                                                                         
sudo ip link add veth20 type veth
sudo ip link set veth20 master vrf-blue # this link should now have the new attribute

Ref: https://github.com/torvalds/linux/blob/f2e367d6ad3bdc527c2b14e759c2f010d6b2b7a1/drivers/net/vrf.c#L1797

Copy link

codecov bot commented Feb 24, 2024

Codecov Report

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

Project coverage is 63.94%. Comparing base (3e16f9c) to head (4dbbfcf).
Report is 3 commits behind head on main.

❗ Current head 4dbbfcf differs from pull request most recent head a822400. Consider uploading reports for the commit a822400 to get more accurate results

Files Patch % Lines
src/link/link_info/info_port.rs 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
- Coverage   63.97%   63.94%   -0.04%     
==========================================
  Files         140      140              
  Lines        8617     8528      -89     
==========================================
- Hits         5513     5453      -60     
+ Misses       3104     3075      -29     

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

@little-dude
Copy link
Contributor Author

The clippy failure is due to TryFrom which we explicitly import but that is part of the prelude in the 2021 edition. Should I fix this @cathay4t ?

@little-dude
Copy link
Contributor Author

@cathay4t would you mind reviewing this?

little-dude added a commit to little-dude/netlink-packet-route that referenced this pull request Mar 25, 2024
little-dude added a commit to little-dude/netlink-packet-route that referenced this pull request Mar 25, 2024
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 code looks good to me. But I would like to see a unit test case parsing and emitting Vec captured on real VRF port. I have document on how to capture netlink message in https://github.com/rust-netlink/netlink-packet-route/blob/main/README.md

@little-dude little-dude force-pushed the vrf-slave-link branch 2 times, most recently from f71ea1d to d86627c Compare April 12, 2024 13:21
@little-dude
Copy link
Contributor Author

@cathay4t I added a test. Note that we might have a couple problemactic attributes when emitting packets, but that doesn't seem to be related to my changes, and I really don't have time to investigate further at the moment unfortunately. See the commented out part of the test.

@little-dude
Copy link
Contributor Author

@cathay4t are you ok with merging this?

Links that belong to a VRF carry the VRF table ID in the link info. For
a VRF link we already had these attributes:

```
LinkInfo([Kind(Vrf), Data(Vrf([TableId(10)]))])
```

For ports attached to a VRF we now have:

```
LinkInfo([Kind(Veth), PortKind(Vrf), PortData(VrfPort([TableId(10)]))])
```

This tells us that this veth interface belong to the VRF with table ID
10.
Note that I had to derive `Default` on a couple structs to make the
test manageable.

Also, I noticed that the packet we emit does not 100% matches the
packet emitted by the kernel.
@cathay4t
Copy link
Member

Your kernel support IPSTATS_MIB_REASM_OVERLAPS and IPSTATS_MIB_OUTPKTS but netlink-packet-route does not, hence the emitted data missed 8 bytes.

That is not related to your patch. I will fix it later.

@cathay4t cathay4t merged commit baed9af into rust-netlink:main Apr 24, 2024
8 checks passed
@cathay4t
Copy link
Member

#119 created for the FIXME.

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.

2 participants