forked from one-d-wide/netlink-bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextack.rs
More file actions
32 lines (27 loc) · 1.15 KB
/
extack.rs
File metadata and controls
32 lines (27 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! This example demonstrates how extended ACK attributes are reported on error.
//! See https://docs.kernel.org/userspace-api/netlink/intro.html#extended-ack
//!
//! Unfortunately, only validation policy violations is consistently reported,
//! and there're not many netlink families correctly reporting missing attributes.
//!
//! Run with: `cargo run --example extack --features=rt-link`
use netlink_bindings::rt_link;
#[cfg_attr(not(feature = "async"), maybe_async::maybe_async)]
#[cfg_attr(feature = "tokio", tokio::main(flavor = "current_thread"))]
#[cfg_attr(feature = "smol", macro_rules_attribute::apply(smol_macros::main))]
async fn main() {
let header = rt_link::PushIfinfomsg::new();
let mut request = rt_link::Request::new()
.set_create()
.op_newlink_do_request(&header);
request
.encode()
.push_ifname(c"12345678901234567890") // Interface name is too long
.nested_linkinfo()
.push_kind(c"bridge");
let mut sock = netlink_socket2::NetlinkSocket::new();
let mut iter = sock.request(&request).await.unwrap();
while let Some(res) = iter.recv().await {
println!("{:?}", res);
}
}