[netcf-devel] Why check for IFF_RUNNING in if_is_active?

Laine Stump laine at laine.org
Wed Sep 5 18:42:20 UTC 2012


On 09/05/2012 10:45 AM, Hendrik Schwartke wrote:
> Hi,
>
> I'm wondering why the IFF_RUNNING flag is checked in if_is_active.
> Shouldn't it be enough to check only for IFF_UP?
> My problem is that whenever I set a device up which is intentionally
> not running (because the cable is not plugged in or because it's a tap
> device) I got an error although everything is perfectly right.
> So I have to write a wrapper to distinguish  between "real" error
> messages and the "cable is not inserted" error.
>
> Is there any reason for checking both flags I didn't notice?

Basically because someone had a problem with the previous behavior
displaying inconsistent results depending on whether or not
NetworkManager was running and whether or not the interface was using DHCP.

I suppose the core of this problem is that netcf has only a single flag
(active or not active) and there are multiple different states that the
interface could be in.

Here's the commit that added the check for IFF_RUNNING. It has a bit of
explanation, as well as a pointer to the BZ that started it all:


commit 012e2169dfd904520ecac65553ccdd265537351f
Author: Laine Stump <laine at redhat.com>
Date:   Tue Jul 31 19:57:59 2012 -0400

Author: Laine Stump <laine at redhat.com>
Date:   Tue Jul 31 19:57:59 2012 -0400

    check IFF_RUNNING before considering an interface "active"
   
    This is in response to:
   
      https://bugzilla.redhat.com/show_bug.cgi?id=844578
   
    If an interface's cable is unplugged and it is configured to use dhcp
    (or if NetworkManager is running), attempts to ifup will fail, but
    netcf will later report that the interface is active. This is because
    netcf only checks the IFF_UP flag in the interface status.
   
    It makes more sense for the interface to be counted as active only if
    ifup has been successful, so this patch changes the if_is_active()
    utility function to require both IFF_UP and IFF_RUNNING be set before
    counting the interface as active.
   
    However, if an interface is configured for a static IP address *and
    NetworkManager isn't running*, ifup will succeed even when the cable
    is unplugged. So again the active status of the interface is not
    consistent with the result of ifup. To resolve this inconsistency,
    this patch makes na additional check for if_is_active() after the
    system's ifup utility successfully completes.
   
    The result is consistency between the result of ifup and the
    interface's flags in all cases.
   
 


More information about the netcf-devel mailing list