From 63579341e14e32e68f26fe8148ab4d6a20366921 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 5 Jul 2022 13:43:44 +0200 Subject: [PATCH] net_util: Don't expect the interface to be IFF_RUNNING Enabling the TAP interface is only about the IFF_UP flag, meaning we shouldn't be testing the presence of IFF_RUNNING, and therefore we shouldn't set it when not present. Signed-off-by: Sebastien Boeuf --- net_util/src/tap.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net_util/src/tap.rs b/net_util/src/tap.rs index fac62986d..195569c7b 100644 --- a/net_util/src/tap.rs +++ b/net_util/src/tap.rs @@ -321,15 +321,13 @@ impl Tap { // If TAP device is already up don't try and enable it let ifru_flags = unsafe { ifreq.ifr_ifru.ifru_flags }; - if ifru_flags - & (net_gen::net_device_flags_IFF_UP | net_gen::net_device_flags_IFF_RUNNING) as i16 - == (net_gen::net_device_flags_IFF_UP | net_gen::net_device_flags_IFF_RUNNING) as i16 + if ifru_flags & net_gen::net_device_flags_IFF_UP as i16 + == net_gen::net_device_flags_IFF_UP as i16 { return Ok(()); } - ifreq.ifr_ifru.ifru_flags = - (net_gen::net_device_flags_IFF_UP | net_gen::net_device_flags_IFF_RUNNING) as i16; + ifreq.ifr_ifru.ifru_flags = net_gen::net_device_flags_IFF_UP as i16; // ioctl is safe. Called with a valid sock fd, and we check the return. let ret =