tap: keeping only an fd around after jailing...
is not a correct option for making use of /dev/net/tun.
We need to obtain an fd everytime we create a tap interface.
@@ -63,19 +63,13 @@ impl Tap {
pub fn open_named(if_name: &str) -> Result<Tap> {
let terminated_if_name = build_terminated_if_name(if_name)?;
- let fd = if ::data_model::FIRECRACKER_IS_JAILED.load(::std::sync::atomic::Ordering::Relaxed)
- {
- // This is the /dev/net/tun fd inherited from the jailer.
- ::jailer::DEV_NET_TUN_FD
- } else {
- unsafe {
- // Open calls are safe because we give a constant nul-terminated
+ let fd = unsafe {
+ // Open calls are safe because we give a constant null-terminated
// string and verify the result.
libc::open(
b"/dev/net/tun\0".as_ptr() as *const c_char,
libc::O_RDWR | libc::O_NONBLOCK | libc::O_CLOEXEC,
)
- }
};
if fd < 0 {
return Err(Error::OpenTun(IoError::last_os_error()));
