ifplugd: if SIOCSIFFLAGS fails with ENODEV, don't die
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 16 Aug 2016 18:39:52 +0000 (20:39 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 16 Aug 2016 18:39:52 +0000 (20:39 +0200)
Some user managed to hit a race where iface is gone between SIOCGIFFLAGS
and SIOCSIFFLAGS (!). If SIOCSIFFLAGS fails, treat it the same as failed
SIOCGIFFLAGS

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/ifplugd.c

index 28c49e218866b1221fe0da2aeac9bb0e77ab3721..029cba147e0eda11e90f5881442da30bd6f67b93 100644 (file)
@@ -358,8 +358,12 @@ static void up_iface(void)
                ifrequest.ifr_flags |= IFF_UP;
                /* Let user know we mess up with interface */
                bb_error_msg("upping interface");
-               if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0)
-                       xfunc_die();
+               if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0) {
+                       if (errno != ENODEV)
+                               xfunc_die();
+                       G.iface_exists = 0;
+                       return;
+               }
        }
 
 #if 0 /* why do we mess with IP addr? It's not our business */