@@ -13,9 +13,10 @@ use netlink_packet_core::{
13
13
14
14
use netlink_packet_route:: {
15
15
link:: {
16
- InfoBond , InfoData , InfoKind , InfoMacVlan , InfoMacVtap , InfoVeth ,
17
- InfoVlan , InfoVrf , InfoVxlan , InfoXfrm , LinkAttribute , LinkFlag ,
18
- LinkInfo , LinkMessage , VlanQosMapping ,
16
+ BondMode , InfoBond , InfoData , InfoKind , InfoMacVlan , InfoMacVtap ,
17
+ InfoVeth , InfoVlan , InfoVrf , InfoVxlan , InfoXfrm , LinkAttribute ,
18
+ LinkFlags , LinkInfo , LinkMessage , MacVlanMode , MacVtapMode ,
19
+ VlanQosMapping ,
19
20
} ,
20
21
RouteNetlinkMessage ,
21
22
} ;
@@ -45,7 +46,7 @@ impl BondAddRequest {
45
46
46
47
/// Adds the `mode` attribute to the bond
47
48
/// This is equivalent to `ip link add name NAME type bond mode MODE`.
48
- pub fn mode ( mut self , mode : u8 ) -> Self {
49
+ pub fn mode ( mut self , mode : BondMode ) -> Self {
49
50
self . info_data . push ( InfoBond :: Mode ( mode) ) ;
50
51
self
51
52
}
@@ -442,7 +443,7 @@ impl VxlanAddRequest {
442
443
443
444
/// Adds the `learning` attribute to the VXLAN
444
445
/// This is equivalent to `ip link add name NAME type vxlan id VNI
445
- /// [no]learning`. [no]learning - specifies if unknown source link layer
446
+ /// \ [no\ ]learning`. \ [no\ ]learning - specifies if unknown source link layer
446
447
/// addresses and IP addresses are entered into the VXLAN
447
448
/// device forwarding database.
448
449
pub fn learning ( mut self , learning : bool ) -> Self {
@@ -480,23 +481,23 @@ impl VxlanAddRequest {
480
481
481
482
/// Adds the `proxy` attribute to the VXLAN
482
483
/// This is equivalent to `ip link add name NAME type vxlan id VNI
483
- /// [no]proxy`. [no]proxy - specifies ARP proxy is turned on.
484
+ /// [no]proxy`. \ [no\ ]proxy - specifies ARP proxy is turned on.
484
485
pub fn proxy ( mut self , proxy : bool ) -> Self {
485
486
self . info_data . push ( InfoVxlan :: Proxy ( proxy) ) ;
486
487
self
487
488
}
488
489
489
- /// Adds the `rsc` attribute to the VXLAN
490
- /// This is equivalent to `ip link add name NAME type vxlan id VNI [no]rsc`.
491
- /// [no]rsc - specifies if route short circuit is turned on.
490
+ /// Adds the `rsc` attribute to the VXLAN This is equivalent to
491
+ /// `ip link add name NAME type vxlan id VNI [no]rsc`.
492
+ /// \ [no\ ]rsc - specifies if route short circuit is turned on.
492
493
pub fn rsc ( mut self , rsc : bool ) -> Self {
493
494
self . info_data . push ( InfoVxlan :: Rsc ( rsc) ) ;
494
495
self
495
496
}
496
497
497
498
// Adds the `l2miss` attribute to the VXLAN
498
499
/// This is equivalent to `ip link add name NAME type vxlan id VNI
499
- /// [no]l2miss`. [no]l2miss - specifies if netlink LLADDR miss
500
+ /// [no]l2miss`. \ [no\ ]l2miss - specifies if netlink LLADDR miss
500
501
/// notifications are generated.
501
502
pub fn l2miss ( mut self , l2miss : bool ) -> Self {
502
503
self . info_data . push ( InfoVxlan :: L2Miss ( l2miss) ) ;
@@ -505,8 +506,8 @@ impl VxlanAddRequest {
505
506
506
507
// Adds the `l3miss` attribute to the VXLAN
507
508
/// This is equivalent to `ip link add name NAME type vxlan id VNI
508
- /// [no]l3miss`. [no]l3miss - specifies if netlink IP ADDR miss
509
- /// notifications are generated.
509
+ /// [no]l3miss`. \ [no\ ]l3miss - specifies if netlink IP ADDR
510
+ /// miss notifications are generated.
510
511
pub fn l3miss ( mut self , l3miss : bool ) -> Self {
511
512
self . info_data . push ( InfoVxlan :: L3Miss ( l3miss) ) ;
512
513
self
@@ -520,8 +521,8 @@ impl VxlanAddRequest {
520
521
521
522
// Adds the `udp_csum` attribute to the VXLAN
522
523
/// This is equivalent to `ip link add name NAME type vxlan id VNI
523
- /// [no]udp_csum`. [no]udpcsum - specifies if UDP checksum is calculated
524
- /// for transmitted packets over IPv4.
524
+ /// [no]udp_csum`. \ [no\ ]udpcsum - specifies if UDP checksum is
525
+ /// calculated for transmitted packets over IPv4.
525
526
pub fn udp_csum ( mut self , udp_csum : bool ) -> Self {
526
527
self . info_data . push ( InfoVxlan :: UDPCsum ( udp_csum) ) ;
527
528
self
@@ -588,23 +589,22 @@ impl LinkAddRequest {
588
589
///
589
590
/// Let's say we want to create a vlan interface on a link with id 6. By
590
591
/// default, the [`vlan()`](#method.vlan) method would create a request
591
- /// with the `LinkFlag ::Up` link set, so that the interface is up after
592
+ /// with the `LinkFlags ::Up` link set, so that the interface is up after
592
593
/// creation. If we want to create a interface that is down by default we
593
594
/// could do:
594
595
///
595
596
/// ```rust,no_run
596
597
/// use futures::Future;
597
- /// use netlink_packet_route::link::LinkFlag ;
598
+ /// use netlink_packet_route::link::LinkFlags ;
598
599
/// use rtnetlink::{Handle, new_connection};
599
600
///
600
601
/// async fn run(handle: Handle) -> Result<(), String> {
601
602
/// let vlan_id = 100;
602
603
/// let link_id = 6;
603
604
/// let mut request = handle.link().add().vlan("my-vlan-itf".into(),
604
605
/// link_id, vlan_id);
605
- /// request.message_mut().header.flags.push(LinkFlag::Up);
606
- /// request.message_mut().header.change_mask.retain(
607
- /// |f| *f != LinkFlag::Up);
606
+ /// request.message_mut().header.flags.remove(LinkFlags::Up);
607
+ /// request.message_mut().header.change_mask.remove(LinkFlags::Up);
608
608
/// // send the request
609
609
/// request.execute().await.map_err(|e| format!("{}", e))
610
610
/// }
@@ -628,8 +628,8 @@ impl LinkAddRequest {
628
628
629
629
let mut peer = LinkMessage :: default ( ) ;
630
630
// FIXME: we get a -107 (ENOTCONN) (???) when trying to set `name` up.
631
- // peer.header.flags.push(LinkFlag ::Up) ;
632
- // peer.header.change_mask.push( LinkFlag::Up) ;
631
+ // peer.header.flags |= LinkFlags ::Up;
632
+ // peer.header.change_mask |= LinkFlag::Up;
633
633
peer. attributes . push ( LinkAttribute :: IfName ( name) ) ;
634
634
let link_info_data = InfoData :: Veth ( InfoVeth :: Peer ( peer) ) ;
635
635
self . name ( peer_name)
@@ -687,7 +687,7 @@ impl LinkAddRequest {
687
687
/// flags from MACVLAN_MODE (netlink-packet-route/src/rtnl/constants.rs)
688
688
/// being: _PRIVATE, _VEPA, _BRIDGE, _PASSTHRU, _SOURCE, which can be
689
689
/// *combined*.
690
- pub fn macvlan ( self , name : String , index : u32 , mode : u32 ) -> Self {
690
+ pub fn macvlan ( self , name : String , index : u32 , mode : MacVlanMode ) -> Self {
691
691
self . name ( name)
692
692
. link_info (
693
693
InfoKind :: MacVlan ,
@@ -704,7 +704,7 @@ impl LinkAddRequest {
704
704
/// flags from MACVTAP_MODE (netlink-packet-route/src/rtnl/constants.rs)
705
705
/// being: _PRIVATE, _VEPA, _BRIDGE, _PASSTHRU, _SOURCE, which can be
706
706
/// *combined*.
707
- pub fn macvtap ( self , name : String , index : u32 , mode : u32 ) -> Self {
707
+ pub fn macvtap ( self , name : String , index : u32 , mode : MacVtapMode ) -> Self {
708
708
self . name ( name)
709
709
. link_info (
710
710
InfoKind :: MacVtap ,
@@ -779,11 +779,7 @@ impl LinkAddRequest {
779
779
/// This is equivalent to `ip link add NAME type wireguard`.
780
780
pub fn wireguard ( self , name : String ) -> Self {
781
781
let mut request = self . name ( name) . link_info ( InfoKind :: Wireguard , None ) ;
782
- request
783
- . message_mut ( )
784
- . header
785
- . flags
786
- . retain ( |f| * f != LinkFlag :: Up ) ;
782
+ request. message_mut ( ) . header . flags . remove ( LinkFlags :: Up ) ;
787
783
request
788
784
}
789
785
@@ -805,8 +801,8 @@ impl LinkAddRequest {
805
801
}
806
802
807
803
fn up ( mut self ) -> Self {
808
- self . message . header . flags . push ( LinkFlag :: Up ) ;
809
- self . message . header . change_mask . push ( LinkFlag :: Up ) ;
804
+ self . message . header . flags |= LinkFlags :: Up ;
805
+ self . message . header . change_mask |= LinkFlags :: Up ;
810
806
self
811
807
}
812
808
0 commit comments