Skip to content

Commit fc1ba75

Browse files
committed
bond: Change InfoBond::UseCarrier from u8 to bool
Both linux kernel code and document confirmed the `use_carrier` is a boolean. Unit test case updated. Signed-off-by: Gris Ge <[email protected]>
1 parent 0bedb4c commit fc1ba75

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/link/link_info/bond.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,9 @@ pub enum InfoBond {
614614
MiiMon(u32),
615615
UpDelay(u32),
616616
DownDelay(u32),
617-
UseCarrier(u8),
617+
/// Specifies whether or not miimon should use MII or ETHTOOL ioctls vs.
618+
/// `netif_carrier_ok()` to determine the link status.
619+
UseCarrier(bool),
618620
ArpInterval(u32),
619621
ArpIpTarget(Vec<Ipv4Addr>),
620622
ArpValidate(BondArpValidate),
@@ -696,13 +698,12 @@ impl Nla for InfoBond {
696698
Self::Mode(value) => buffer[0] = (*value).into(),
697699
Self::XmitHashPolicy(value) => buffer[0] = (*value).into(),
698700
Self::PrimaryReselect(value) => buffer[0] = (*value).into(),
699-
Self::UseCarrier(value)
700-
| Self::NumPeerNotif(value)
701+
Self::NumPeerNotif(value)
701702
| Self::AdSelect(value)
702703
| Self::MissedMax(value) => buffer[0] = *value,
703-
Self::AdLacpActive(value) | Self::TlbDynamicLb(value) => {
704-
buffer[0] = (*value).into()
705-
}
704+
Self::UseCarrier(value)
705+
| Self::AdLacpActive(value)
706+
| Self::TlbDynamicLb(value) => buffer[0] = (*value).into(),
706707
Self::AdLacpRate(value) => buffer[0] = (*value).into(),
707708
Self::AllPortsActive(value) => buffer[0] = (*value).into(),
708709
Self::FailOverMac(value) => buffer[0] = (*value).into(),
@@ -802,7 +803,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoBond {
802803
),
803804
IFLA_BOND_USE_CARRIER => Self::UseCarrier(
804805
parse_u8(payload)
805-
.context("invalid IFLA_BOND_USE_CARRIER value")?,
806+
.context("invalid IFLA_BOND_USE_CARRIER value")?
807+
> 0,
806808
),
807809
IFLA_BOND_ARP_INTERVAL => Self::ArpInterval(
808810
parse_u32(payload)

src/link/tests/bond.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn test_bond_link_info() {
6565
InfoBond::UpDelay(0),
6666
InfoBond::DownDelay(0),
6767
InfoBond::PeerNotifDelay(0),
68-
InfoBond::UseCarrier(1),
68+
InfoBond::UseCarrier(true),
6969
InfoBond::ArpInterval(0),
7070
InfoBond::ArpValidate(BondArpValidate::None),
7171
InfoBond::ArpAllTargets(BondArpAllTargets::Any),

0 commit comments

Comments
 (0)