@@ -79,6 +79,9 @@ const BOND_XMIT_POLICY_ENCAP34: u8 = 4;
79
79
const BOND_XMIT_POLICY_VLAN_SRCMAC : u8 = 5 ;
80
80
const BOND_OPT_ARP_ALL_TARGETS_ANY : u32 = 0 ;
81
81
const 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 ;
82
85
83
86
#[ derive( Debug , Clone , Eq , PartialEq ) ]
84
87
#[ non_exhaustive]
@@ -280,6 +283,51 @@ impl std::fmt::Display for BondArpValidate {
280
283
}
281
284
}
282
285
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
+
283
331
#[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
284
332
pub enum BondXmitHashPolicy {
285
333
#[ default]
@@ -458,7 +506,7 @@ pub enum InfoBond {
458
506
ArpValidate ( BondArpValidate ) ,
459
507
ArpAllTargets ( BondArpAllTargets ) ,
460
508
Primary ( u32 ) ,
461
- PrimaryReselect ( u8 ) ,
509
+ PrimaryReselect ( BondPrimaryReselect ) ,
462
510
FailOverMac ( BondFailOverMac ) ,
463
511
XmitHashPolicy ( BondXmitHashPolicy ) ,
464
512
ResendIgmp ( u32 ) ,
@@ -526,8 +574,10 @@ impl Nla for InfoBond {
526
574
match self {
527
575
Self :: Mode ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
528
576
Self :: XmitHashPolicy ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
577
+ Self :: PrimaryReselect ( value) => buffer[ 0 ] = ( * value) . into ( ) ,
529
578
Self :: UseCarrier ( value)
530
- | Self :: PrimaryReselect ( value)
579
+ | Self :: FailOverMac ( value)
580
+ | Self :: XmitHashPolicy ( value)
531
581
| Self :: NumPeerNotif ( value)
532
582
| Self :: AllPortsActive ( value)
533
583
| Self :: AdLacpActive ( value)
@@ -667,7 +717,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoBond {
667
717
) ,
668
718
IFLA_BOND_PRIMARY_RESELECT => Self :: PrimaryReselect (
669
719
parse_u8 ( payload)
670
- . context ( "invalid IFLA_BOND_PRIMARY_RESELECT value" ) ?,
720
+ . context ( "invalid IFLA_BOND_PRIMARY_RESELECT value" ) ?
721
+ . into ( ) ,
671
722
) ,
672
723
IFLA_BOND_FAIL_OVER_MAC => Self :: FailOverMac (
673
724
parse_u8 ( payload)
0 commit comments