diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2018-05-31 15:31:31 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-12 00:36:27 -0700 |
commit | 5f787217cc48e526c6244cd39db4f944fadfcd88 (patch) | |
tree | 8d3160c83c19c3ef3356502a3b18603b1de05ec3 /net_util | |
parent | 92068bca00d7499dc789527b90efdf3daed2e927 (diff) | |
download | crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.tar crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.tar.gz crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.tar.bz2 crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.tar.lz crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.tar.xz crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.tar.zst crosvm-5f787217cc48e526c6244cd39db4f944fadfcd88.zip |
net: Allow passing in a configured tap fd on the command line
Allow the process that spawned crosvm to pass in a configured tap file descriptor for networking. If this option is provided then crosvm will ignore the other networking related command line flags (like mac address, netmask, etc). Passing in a configured tap device allows us to run crosvm without having to give it CAP_NET_ADMIN. BUG=none TEST=Start a container and verify that networking still works Change-Id: I70b9e6ae030d66c4882e4e48804dc2f29d9874ba Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1081394 Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'net_util')
-rw-r--r-- | net_util/src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/net_util/src/lib.rs b/net_util/src/lib.rs index 273c1ca..0826729 100644 --- a/net_util/src/lib.rs +++ b/net_util/src/lib.rs @@ -449,6 +449,15 @@ impl AsRawFd for Tap { } } +impl FromRawFd for Tap { + unsafe fn from_raw_fd(fd: RawFd) -> Tap { + Tap { + tap_file: File::from_raw_fd(fd), + if_name: [0; 16usize], + } + } +} + pub mod fakes { use super::*; use std::fs::OpenOptions; |