mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
sys_util: netlink: implement AsRawDescriptor for netlink generic socket
In order to use netlink generic socket together with WaitContext, AsRawDescriptor needs to be implemented. BUG=b:197247746, b:205072342 TEST=Use NetlinkGenericSocket with WaitContext and successfully use it for threads Change-Id: I99c9d508c86395f104a7a2f17a1726b753c9698b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3528638 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
This commit is contained in:
parent
f35129885b
commit
550ed754da
1 changed files with 9 additions and 1 deletions
|
@ -9,7 +9,9 @@ use libc::EINVAL;
|
|||
|
||||
use sys_util_core::LayoutAllocation;
|
||||
|
||||
use super::{errno_result, Error, FromRawDescriptor, Result, SafeDescriptor};
|
||||
use super::{
|
||||
errno_result, AsRawDescriptor, Error, FromRawDescriptor, RawDescriptor, Result, SafeDescriptor,
|
||||
};
|
||||
|
||||
// Custom nlmsghdr struct that can be declared DataInit.
|
||||
#[repr(C)]
|
||||
|
@ -101,6 +103,12 @@ pub struct NetlinkGenericSocket {
|
|||
sock: SafeDescriptor,
|
||||
}
|
||||
|
||||
impl AsRawDescriptor for NetlinkGenericSocket {
|
||||
fn as_raw_descriptor(&self) -> RawDescriptor {
|
||||
self.sock.as_raw_descriptor()
|
||||
}
|
||||
}
|
||||
|
||||
impl NetlinkGenericSocket {
|
||||
/// Create and bind a new `NETLINK_GENERIC` socket.
|
||||
pub fn new(nl_groups: u32) -> Result<Self> {
|
||||
|
|
Loading…
Reference in a new issue