@@ -82,6 +82,9 @@ const BOND_OPT_ARP_ALL_TARGETS_ALL: u32 = 1;
8282const BOND_PRI_RESELECT_ALWAYS : u8 = 0 ;
8383const BOND_PRI_RESELECT_BETTER : u8 = 1 ;
8484const BOND_PRI_RESELECT_FAILURE : u8 = 2 ;
85+ const BOND_FOM_NONE : u8 = 0 ;
86+ const BOND_FOM_ACTIVE : u8 = 1 ;
87+ const BOND_FOM_FOLLOW : u8 = 2 ;
8588
8689#[ derive( Debug , Clone , Eq , PartialEq ) ]
8790#[ non_exhaustive]
@@ -426,6 +429,51 @@ impl std::fmt::Display for BondArpAllTargets {
426429 }
427430}
428431
432+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
433+ pub enum BondFailOverMac {
434+ #[ default]
435+ None ,
436+ Active ,
437+ Follow ,
438+ Other ( u8 ) ,
439+ }
440+
441+ impl From < BondFailOverMac > for u8 {
442+ fn from ( value : BondFailOverMac ) -> Self {
443+ match value {
444+ BondFailOverMac :: None => BOND_FOM_NONE ,
445+ BondFailOverMac :: Active => BOND_FOM_ACTIVE ,
446+ BondFailOverMac :: Follow => BOND_FOM_FOLLOW ,
447+ BondFailOverMac :: Other ( d) => d,
448+ }
449+ }
450+ }
451+
452+ impl From < u8 > for BondFailOverMac {
453+ fn from ( value : u8 ) -> Self {
454+ match value {
455+ BOND_FOM_NONE => BondFailOverMac :: None ,
456+ BOND_FOM_ACTIVE => BondFailOverMac :: Active ,
457+ BOND_FOM_FOLLOW => BondFailOverMac :: Follow ,
458+ d => BondFailOverMac :: Other ( d) ,
459+ }
460+ }
461+ }
462+
463+ impl std:: fmt:: Display for BondFailOverMac {
464+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
465+ let kernel_name = match self {
466+ BondFailOverMac :: None => "none" ,
467+ BondFailOverMac :: Active => "active" ,
468+ BondFailOverMac :: Follow => "follow" ,
469+ BondFailOverMac :: Other ( d) => {
470+ return write ! ( f, "unknown-variant ({d})" )
471+ }
472+ } ;
473+ f. write_str ( kernel_name)
474+ }
475+ }
476+
429477// Some attributes (ARP_IP_TARGET, NS_IP6_TARGET) contain a nested
430478// list of IP addresses, where each element uses the index as NLA kind
431479// and the address as value. InfoBond exposes vectors of IP addresses,
@@ -576,8 +624,6 @@ impl Nla for InfoBond {
576624 Self :: XmitHashPolicy ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
577625 Self :: PrimaryReselect ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
578626 Self :: UseCarrier ( value)
579- | Self :: FailOverMac ( value)
580- | Self :: XmitHashPolicy ( value)
581627 | Self :: NumPeerNotif ( value)
582628 | Self :: AllPortsActive ( value)
583629 | Self :: AdLacpActive ( value)
@@ -818,52 +864,3 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoBond {
818864 } )
819865 }
820866}
821-
822- const BOND_FOM_NONE : u8 = 0 ;
823- const BOND_FOM_ACTIVE : u8 = 1 ;
824- const BOND_FOM_FOLLOW : u8 = 2 ;
825-
826- #[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
827- pub enum BondFailOverMac {
828- #[ default]
829- None ,
830- Active ,
831- Follow ,
832- Other ( u8 ) ,
833- }
834-
835- impl From < BondFailOverMac > for u8 {
836- fn from ( value : BondFailOverMac ) -> Self {
837- match value {
838- BondFailOverMac :: None => BOND_FOM_NONE ,
839- BondFailOverMac :: Active => BOND_FOM_ACTIVE ,
840- BondFailOverMac :: Follow => BOND_FOM_FOLLOW ,
841- BondFailOverMac :: Other ( d) => d,
842- }
843- }
844- }
845-
846- impl From < u8 > for BondFailOverMac {
847- fn from ( value : u8 ) -> Self {
848- match value {
849- BOND_FOM_NONE => BondFailOverMac :: None ,
850- BOND_FOM_ACTIVE => BondFailOverMac :: Active ,
851- BOND_FOM_FOLLOW => BondFailOverMac :: Follow ,
852- d => BondFailOverMac :: Other ( d) ,
853- }
854- }
855- }
856-
857- impl std:: fmt:: Display for BondFailOverMac {
858- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
859- let kernel_name = match self {
860- BondFailOverMac :: None => "none" ,
861- BondFailOverMac :: Active => "active" ,
862- BondFailOverMac :: Follow => "follow" ,
863- BondFailOverMac :: Other ( d) => {
864- return write ! ( f, "unknown-variant ({d})" )
865- }
866- } ;
867- f. write_str ( kernel_name)
868- }
869- }
0 commit comments