@@ -71,6 +71,8 @@ const BOND_ARP_VALIDATE_ALL: u32 =
7171const BOND_ARP_FILTER : u32 = BOND_ARP_VALIDATE_ALL + 1 ;
7272const BOND_ARP_FILTER_ACTIVE : u32 = BOND_ARP_FILTER | BOND_ARP_VALIDATE_ACTIVE ;
7373const BOND_ARP_FILTER_BACKUP : u32 = BOND_ARP_FILTER | BOND_ARP_VALIDATE_BACKUP ;
74+ const BOND_OPT_ARP_ALL_TARGETS_ANY : u32 = 0 ;
75+ const BOND_OPT_ARP_ALL_TARGETS_ALL : u32 = 1 ;
7476
7577#[ derive( Debug , Clone , Eq , PartialEq ) ]
7678#[ non_exhaustive]
@@ -272,6 +274,47 @@ impl std::fmt::Display for BondArpValidate {
272274 }
273275}
274276
277+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
278+ pub enum BondArpAllTargets {
279+ #[ default]
280+ Any ,
281+ All ,
282+ Other ( u32 ) ,
283+ }
284+
285+ impl From < BondArpAllTargets > for u32 {
286+ fn from ( value : BondArpAllTargets ) -> Self {
287+ match value {
288+ BondArpAllTargets :: All => BOND_OPT_ARP_ALL_TARGETS_ALL ,
289+ BondArpAllTargets :: Any => BOND_OPT_ARP_ALL_TARGETS_ANY ,
290+ BondArpAllTargets :: Other ( d) => d,
291+ }
292+ }
293+ }
294+
295+ impl From < u32 > for BondArpAllTargets {
296+ fn from ( value : u32 ) -> Self {
297+ match value {
298+ BOND_OPT_ARP_ALL_TARGETS_ANY => BondArpAllTargets :: Any ,
299+ BOND_OPT_ARP_ALL_TARGETS_ALL => BondArpAllTargets :: All ,
300+ d => BondArpAllTargets :: Other ( d) ,
301+ }
302+ }
303+ }
304+
305+ impl std:: fmt:: Display for BondArpAllTargets {
306+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
307+ let kernel_name = match self {
308+ BondArpAllTargets :: Any => "any" ,
309+ BondArpAllTargets :: All => "all" ,
310+ BondArpAllTargets :: Other ( d) => {
311+ return write ! ( f, "unknown-variant ({d})" )
312+ }
313+ } ;
314+ f. write_str ( kernel_name)
315+ }
316+ }
317+
275318// Some attributes (ARP_IP_TARGET, NS_IP6_TARGET) contain a nested
276319// list of IP addresses, where each element uses the index as NLA kind
277320// and the address as value. InfoBond exposes vectors of IP addresses,
@@ -350,7 +393,7 @@ pub enum InfoBond {
350393 ArpInterval ( u32 ) ,
351394 ArpIpTarget ( Vec < Ipv4Addr > ) ,
352395 ArpValidate ( BondArpValidate ) ,
353- ArpAllTargets ( u32 ) ,
396+ ArpAllTargets ( BondArpAllTargets ) ,
354397 Primary ( u32 ) ,
355398 PrimaryReselect ( u8 ) ,
356399 FailOverMac ( u8 ) ,
@@ -436,12 +479,14 @@ impl Nla for InfoBond {
436479 Self :: ArpValidate ( value) => {
437480 NativeEndian :: write_u32 ( buffer, ( * value) . into ( ) )
438481 }
482+ Self :: ArpAllTargets ( value) => {
483+ NativeEndian :: write_u32 ( buffer, ( * value) . into ( ) )
484+ }
439485 Self :: ActivePort ( value)
440486 | Self :: MiiMon ( value)
441487 | Self :: UpDelay ( value)
442488 | Self :: DownDelay ( value)
443489 | Self :: ArpInterval ( value)
444- | Self :: ArpAllTargets ( value)
445490 | Self :: Primary ( value)
446491 | Self :: ResendIgmp ( value)
447492 | Self :: MinLinks ( value)
@@ -550,7 +595,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoBond {
550595 ) ,
551596 IFLA_BOND_ARP_ALL_TARGETS => Self :: ArpAllTargets (
552597 parse_u32 ( payload)
553- . context ( "invalid IFLA_BOND_ARP_ALL_TARGETS value" ) ?,
598+ . context ( "invalid IFLA_BOND_ARP_ALL_TARGETS value" ) ?
599+ . into ( ) ,
554600 ) ,
555601 IFLA_BOND_PRIMARY => Self :: Primary (
556602 parse_u32 ( payload)
0 commit comments