Skip to content

Commit a1b79a1

Browse files
ydirsoncathay4t
authored andcommitted
Do not activate network namespaces and traffic control on FreeBSD.
Not supported there. Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
1 parent ef48eca commit a1b79a1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/handle.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ use netlink_packet_route::RouteNetlinkMessage;
66
use netlink_proto::{sys::SocketAddr, ConnectionHandle};
77

88
use crate::{
9-
AddressHandle, Error, LinkHandle, NeighbourHandle, QDiscHandle,
10-
RouteHandle, RuleHandle, TrafficChainHandle, TrafficClassHandle,
11-
TrafficFilterHandle,
9+
AddressHandle, Error, LinkHandle, NeighbourHandle, RouteHandle, RuleHandle,
10+
};
11+
#[cfg(not(target_os = "freebsd"))]
12+
use crate::{
13+
QDiscHandle, TrafficChainHandle, TrafficClassHandle, TrafficFilterHandle,
1214
};
1315

1416
#[derive(Clone, Debug)]
@@ -71,24 +73,28 @@ impl Handle {
7173

7274
/// Create a new handle, specifically for traffic control qdisc requests
7375
/// (equivalent to `tc qdisc show` commands)
76+
#[cfg(not(target_os = "freebsd"))]
7477
pub fn qdisc(&self) -> QDiscHandle {
7578
QDiscHandle::new(self.clone())
7679
}
7780

7881
/// Create a new handle, specifically for traffic control class requests
7982
/// (equivalent to `tc class show dev <interface_name>` commands)
83+
#[cfg(not(target_os = "freebsd"))]
8084
pub fn traffic_class(&self, ifindex: i32) -> TrafficClassHandle {
8185
TrafficClassHandle::new(self.clone(), ifindex)
8286
}
8387

8488
/// Create a new handle, specifically for traffic control filter requests
8589
/// (equivalent to `tc filter show dev <interface_name>` commands)
90+
#[cfg(not(target_os = "freebsd"))]
8691
pub fn traffic_filter(&self, ifindex: i32) -> TrafficFilterHandle {
8792
TrafficFilterHandle::new(self.clone(), ifindex)
8893
}
8994

9095
/// Create a new handle, specifically for traffic control chain requests
9196
/// (equivalent to `tc chain show dev <interface_name>` commands)
97+
#[cfg(not(target_os = "freebsd"))]
9298
pub fn traffic_chain(&self, ifindex: i32) -> TrafficChainHandle {
9399
TrafficChainHandle::new(self.clone(), ifindex)
94100
}

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
mod handle;
99
pub use crate::handle::*;
1010

11+
#[cfg(not(target_os = "freebsd"))]
1112
mod ns;
13+
#[cfg(not(target_os = "freebsd"))]
1214
pub use crate::ns::*;
1315

1416
mod errors;
@@ -29,7 +31,9 @@ pub use crate::rule::*;
2931
mod connection;
3032
pub use crate::connection::*;
3133

34+
#[cfg(not(target_os = "freebsd"))]
3235
mod traffic_control;
36+
#[cfg(not(target_os = "freebsd"))]
3337
pub use crate::traffic_control::*;
3438

3539
mod neighbour;

0 commit comments

Comments
 (0)