-
Notifications
You must be signed in to change notification settings - Fork 48
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
link: ipvlan: Change flag mode from u16 to Flag. #125
Conversation
3ab9b13
to
ff2164b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IpVlanFlag
is a bitflag. Please check kernel function ipvlan_mark_vepa
.
Please check other code which is using bitflags!
.
src/link/link_info/ipvlan.rs
Outdated
@@ -165,3 +167,43 @@ impl From<IpVlanMode> for u16 { | |||
} | |||
} | |||
} | |||
|
|||
const IPVLAN_FLAG_BRIDGE: u16 = 0; | |||
const IPVLAN_FLAG_PRIVATE: u16 = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use kernel constant name to helping other developers to validate.
In this case, it should be IPVLAN_F_PRIVATE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. thanks
ff2164b
to
286741c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #125 +/- ##
==========================================
- Coverage 66.33% 66.31% -0.03%
==========================================
Files 136 137 +1
Lines 8662 8790 +128
==========================================
+ Hits 5746 5829 +83
- Misses 2916 2961 +45 ☔ View full report in Codecov by Sentry. |
ff230c9
to
b33eef5
Compare
src/link/link_info/ipvlan.rs
Outdated
bitflags! { | ||
#[non_exhaustive] | ||
#[derive(Debug, Clone, Copy, Eq, PartialEq)] | ||
pub struct IpVlanFlag: u16 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename it to IpVlanFlags
as this is a bitflags.
src/link/tests/ipvtap.rs
Outdated
@@ -16,7 +16,7 @@ fn test_ipvtap_link_info() { | |||
0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x12, 0x00, 0x0b, 0x00, 0x01, 0x00, | |||
0x69, 0x70, 0x76, 0x74, 0x61, 0x70, 0x00, 0x00, 0x14, 0x00, 0x02, 0x00, | |||
0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, | |||
0x02, 0x00, 0x00, 0x00, | |||
0x01, 0x00, 0x00, 0x00, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not modify captured data.
If you want to test your enum value, please create new test case and do the nl_mon capture by following the README file of this repo.
819e5a2
to
465294f
Compare
src/link/link_info/ipvlan.rs
Outdated
.context("invalid IFLA_IPVLAN_FLAGS value")?, | ||
), | ||
IFLA_IPVLAN_FLAGS => Self::Flags(IpVlanFlags::from_bits_retain( | ||
parse_u16(payload).context("failed to parse IPVLAN_FLAG")?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed to parse IFLA_IPVLAN_FLAGS
src/link/link_info/ipvlan.rs
Outdated
#[non_exhaustive] | ||
#[derive(Debug, Clone, Copy, Eq, PartialEq)] | ||
pub struct IpVlanFlags: u16 { | ||
const PRIVATE = IPVLAN_F_PRIVATE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum variants should be UpperCamelCase
.
In this crate, bitflags created type are considered as enum.
465294f
to
4fb21fc
Compare
default => bridge; 0x01 => private; 0x02 => vepa; Signed-off-by: xujunjie-cover <[email protected]>
4fb21fc
to
17fad80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done! Thanks!
0 => bridge;
1 => private;
2 => vepa;