@@ -79,6 +79,9 @@ const BOND_XMIT_POLICY_ENCAP34: u8 = 4;
7979const BOND_XMIT_POLICY_VLAN_SRCMAC : u8 = 5 ;
8080const BOND_OPT_ARP_ALL_TARGETS_ANY : u32 = 0 ;
8181const BOND_OPT_ARP_ALL_TARGETS_ALL : u32 = 1 ;
82+ const BOND_PRI_RESELECT_ALWAYS : u8 = 0 ;
83+ const BOND_PRI_RESELECT_BETTER : u8 = 1 ;
84+ const BOND_PRI_RESELECT_FAILURE : u8 = 2 ;
8285
8386#[ derive( Debug , Clone , Eq , PartialEq ) ]
8487#[ non_exhaustive]
@@ -280,6 +283,51 @@ impl std::fmt::Display for BondArpValidate {
280283 }
281284}
282285
286+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
287+ pub enum BondPrimaryReselect {
288+ #[ default]
289+ Always ,
290+ Better ,
291+ Failure ,
292+ Other ( u8 ) ,
293+ }
294+
295+ impl From < BondPrimaryReselect > for u8 {
296+ fn from ( value : BondPrimaryReselect ) -> Self {
297+ match value {
298+ BondPrimaryReselect :: Always => BOND_PRI_RESELECT_ALWAYS ,
299+ BondPrimaryReselect :: Better => BOND_PRI_RESELECT_BETTER ,
300+ BondPrimaryReselect :: Failure => BOND_PRI_RESELECT_FAILURE ,
301+ BondPrimaryReselect :: Other ( d) => d,
302+ }
303+ }
304+ }
305+
306+ impl From < u8 > for BondPrimaryReselect {
307+ fn from ( value : u8 ) -> Self {
308+ match value {
309+ BOND_PRI_RESELECT_ALWAYS => BondPrimaryReselect :: Always ,
310+ BOND_PRI_RESELECT_BETTER => BondPrimaryReselect :: Better ,
311+ BOND_PRI_RESELECT_FAILURE => BondPrimaryReselect :: Failure ,
312+ d => BondPrimaryReselect :: Other ( d) ,
313+ }
314+ }
315+ }
316+
317+ impl std:: fmt:: Display for BondPrimaryReselect {
318+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
319+ let kernel_name = match self {
320+ BondPrimaryReselect :: Always => "always" ,
321+ BondPrimaryReselect :: Better => "better" ,
322+ BondPrimaryReselect :: Failure => "failure" ,
323+ BondPrimaryReselect :: Other ( d) => {
324+ return write ! ( f, "unknown-variant ({d})" )
325+ }
326+ } ;
327+ f. write_str ( kernel_name)
328+ }
329+ }
330+
283331#[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
284332pub enum BondXmitHashPolicy {
285333 #[ default]
@@ -458,7 +506,7 @@ pub enum InfoBond {
458506 ArpValidate ( BondArpValidate ) ,
459507 ArpAllTargets ( BondArpAllTargets ) ,
460508 Primary ( u32 ) ,
461- PrimaryReselect ( u8 ) ,
509+ PrimaryReselect ( BondPrimaryReselect ) ,
462510 FailOverMac ( BondFailOverMac ) ,
463511 XmitHashPolicy ( BondXmitHashPolicy ) ,
464512 ResendIgmp ( u32 ) ,
@@ -526,8 +574,10 @@ impl Nla for InfoBond {
526574 match self {
527575 Self :: Mode ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
528576 Self :: XmitHashPolicy ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
577+ Self :: PrimaryReselect ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
529578 Self :: UseCarrier ( value)
530- | Self :: PrimaryReselect ( value)
579+ | Self :: FailOverMac ( value)
580+ | Self :: XmitHashPolicy ( value)
531581 | Self :: NumPeerNotif ( value)
532582 | Self :: AllPortsActive ( value)
533583 | Self :: AdLacpActive ( value)
@@ -667,7 +717,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoBond {
667717 ) ,
668718 IFLA_BOND_PRIMARY_RESELECT => Self :: PrimaryReselect (
669719 parse_u8 ( payload)
670- . context ( "invalid IFLA_BOND_PRIMARY_RESELECT value" ) ?,
720+ . context ( "invalid IFLA_BOND_PRIMARY_RESELECT value" ) ?
721+ . into ( ) ,
671722 ) ,
672723 IFLA_BOND_FAIL_OVER_MAC => Self :: FailOverMac (
673724 parse_u8 ( payload)
0 commit comments