From 6cb2a930b54fd091e0e13d1e12389cc8165f5a00 Mon Sep 17 00:00:00 2001 From: Stephen Barber Date: Fri, 25 Oct 2019 13:13:18 +0200 Subject: 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 Tested-by: Stephen Barber Commit-Queue: Stephen Barber Reviewed-by: Daniel Verkamp Reviewed-by: Chirantan Ekbote --- Cargo.lock | 1 + net_util/Cargo.toml | 1 + net_util/src/lib.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b03635..4bf9d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/net_util/Cargo.toml b/net_util/Cargo.toml index bfa3bc8..c7f61b1 100644 --- a/net_util/Cargo.toml +++ b/net_util/Cargo.toml @@ -6,5 +6,6 @@ edition = "2018" [dependencies] libc = "*" +data_model = { path = "../data_model" } net_sys = { path = "../net_sys" } sys_util = { path = "../sys_util" } diff --git a/net_util/src/lib.rs b/net_util/src/lib.rs index 9508dcc..0243552 100644 --- a/net_util/src/lib.rs +++ b/net_util/src/lib.rs @@ -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)] -- cgit 1.4.1