mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
net_util: impl FileReadWriteVolatile for Tap
BUG=chromium:753630 TEST=cargo build Change-Id: I55e0d47c4afcb1bf01f4d7f738bda09022956898 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1881418 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
parent
34fa09918f
commit
6cb2a930b5
3 changed files with 8 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -324,6 +324,7 @@ dependencies = [
|
|||
name = "net_util"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"data_model 0.1.0",
|
||||
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"net_sys 0.1.0",
|
||||
"sys_util 0.1.0",
|
||||
|
|
|
@ -6,5 +6,6 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
libc = "*"
|
||||
data_model = { path = "../data_model" }
|
||||
net_sys = { path = "../net_sys" }
|
||||
sys_util = { path = "../sys_util" }
|
||||
|
|
|
@ -15,7 +15,8 @@ use std::str::FromStr;
|
|||
use libc::EPERM;
|
||||
|
||||
use sys_util::Error as SysError;
|
||||
use sys_util::{ioctl_with_mut_ref, ioctl_with_ref, ioctl_with_val};
|
||||
use sys_util::FileReadWriteVolatile;
|
||||
use sys_util::{ioctl_with_mut_ref, ioctl_with_ref, ioctl_with_val, volatile_impl};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
|
@ -189,7 +190,7 @@ impl Tap {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait TapT: Read + Write + AsRawFd + Send + Sized {
|
||||
pub trait TapT: FileReadWriteVolatile + Read + Write + AsRawFd + Send + Sized {
|
||||
/// Create a new tap interface. Set the `vnet_hdr` flag to true to allow offloading on this tap,
|
||||
/// which will add an extra 12 byte virtio net header to incoming frames. Offloading cannot
|
||||
/// be used if `vnet_hdr` is false.
|
||||
|
@ -484,6 +485,8 @@ impl AsRawFd for Tap {
|
|||
}
|
||||
}
|
||||
|
||||
volatile_impl!(Tap);
|
||||
|
||||
pub mod fakes {
|
||||
use super::*;
|
||||
use std::fs::remove_file;
|
||||
|
@ -580,6 +583,7 @@ pub mod fakes {
|
|||
self.tap_file.as_raw_fd()
|
||||
}
|
||||
}
|
||||
volatile_impl!(FakeTap);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue