netlink-packet-wireguard's People
netlink-packet-wireguard's Issues
Wireguard `SetDevice` call blocks
I'm trying to set up wireguard interface and I'm running into an issue with call being blocked at retrieving results. Here is sample code:
let (connection, mut handle, _) = genetlink::new_connection().map_err(|err| {
error!("{err}");
Error::InternalError
})?;
let _ = tokio::spawn(connection);
let nlas = vec![
WgDeviceAttrs::IfName(self.name.clone()),
WgDeviceAttrs::PrivateKey(self.priv_key.expect("failed to unwrap private key")),
WgDeviceAttrs::ListenPort(self.listen_port),
WgDeviceAttrs::Fwmark(self.fwmark),
WgDeviceAttrs::Flags(WGDEVICE_F_REPLACE_PEERS),
];
let genlmsg: GenlMessage<Wireguard> = GenlMessage::from_payload(Wireguard {
cmd: WireguardCmd::SetDevice,
nlas,
});
let mut nlmsg = NetlinkMessage::from(genlmsg);
nlmsg.header.flags = NLM_F_REQUEST;
// this call does not return any error if application does not have necessary capabilities
let mut res = handle.request(nlmsg).await.map_err(|err| {
debug!("{err}");
Error::InternalError
})?;
// this call blocks if there is no error
let _result = res.try_next().await.map_err(|err| {
debug!("{err}");
Error::InternalError
})?;
According to netlink documentation only NLM_F_REQUEST
flag supposed to be supplied and the kernel is not expected to return result. Which is fine but I still want to catch any permission errors.
Here are some observations:
- If application does not have sufficient permissions -
request()
call goes not return any error. When I check result with either
res.try_next()
orres.next()
call it returns permission error, which is reasonably okay. - However, when application is executed with elevated permissions, no error is expected but
res.try_next()
orres.next()
calls block indefinitely. - I also noticed, that if I don't wait for the result - the device is not set up. It only gets set up when application blocks and then terminated.
I think most likely I'm doing something wrong but it also feels that it may be a bug in genetlink
. Any thoughts?
publish version 0.2.2 on crates.io
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.