Bug 855574 - Starting interface without cable failed with error but actually started.
Summary: Starting interface without cable failed with error but actually started.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: netcf
Version: 17
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
Assignee: Laine Stump
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-09-09 03:17 UTC by Laine Stump
Modified: 2012-10-15 03:40 UTC (History)
3 users (show)

Fixed In Version:
Clone Of: 844578
Environment:
Last Closed: 2012-10-15 03:40:01 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Laine Stump 2012-09-09 03:17:41 UTC
+++ This bug was initially created as a clone of Bug #844578 +++

Description of problem:
Starting interface without cable failed with error but actually started.

Version-Release number of selected component (if applicable):
# rpm -qa |grep libvirt
libvirt-0.9.13-3.el6.x86_64
libvirt-client-0.9.13-3.el6.x86_64

How reproducible:
100%

Steps to Reproduce:

1.Prepare a machine that has a NIC without cable.
#ifconfig
eth0      Link encap:Ethernet  HWaddr B8:AC:6F:3E:63:87
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:21 Memory:fdfe0000-fe000000

eth1      Link encap:Ethernet  HWaddr 00:0E:0C:B6:7F:8D
          inet addr:10.66.5.1  Bcast:10.66.7.255  Mask:255.255.252.0
          inet6 addr: fe80::20e:cff:feb6:7f8d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14837 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1759 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1769752 (1.6 MiB)  TX bytes:1598

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:720 (720.0 b)  TX bytes:720 (720.0 b)
2.#service NetworkManager stop
3.#virsh iface-list --all
Name                 State      MAC Address
--------------------------------------------
eth0                 active     b8:ac:6f:3e:63:87
eth1                 active     00:0e:0c:b6:7f:8d
lo                   active     00:00:00:00:00:00

4. #virsh iface-destroy eth0
Interface eth0 destroyed.

#virsh iface-list --all
Name                 State      MAC Address
--------------------------------------------
eth1                 active     00:0e:0c:b6:7f:8d
lo                   active     00:00:00:00:00:00
eth0                 inactive   b8:ac:6f:3e:63:87

5. #virsh iface-start eth0

6.virsh iface-list --all
  
Actual results:
After step 5, results are
# virsh iface-start eth0
error: Failed to start interface eth0
error: internal error failed to create (start) interface eth0: failed to execute external program - Running 'ifup eth0' failed with exit code 1:
Determining IP information for eth0... failed; no link present.  Check cable?

running #virsh iface-list --all
Name                 State      MAC Address
--------------------------------------------
eth0                 active     b8:ac:6f:3e:63:87
eth1                 active     00:0e:0c:b6:7f:8d
lo                   active     00:00:00:00:00:00



Expected results:
Interface should be inactive in the output of iface-list since starting it failed with error messages. Or the error messages should be more clear.

Additional info:
#cat /var/log/libvirt/libvirtd.log
...
 error : interfaceCreate:493 : internal error failed to create (start) interface eth0: failed to execute external program - Running 'ifup eth0' failed with exit code 1:
Determining IP information for eth0... failed; no link present.  Check cable?

--- Additional comment from ajia on 2012-07-31 05:57:44 EDT ---

(In reply to comment #0)
> ...
>  error : interfaceCreate:493 : internal error failed to create (start)
> interface eth0: failed to execute external program - Running 'ifup eth0'
> failed with exit code 1:
> Determining IP information for eth0... failed; no link present.  Check cable?

I guess your NetworkManager service is running, if you stop it then you may get a expected result?

--- Additional comment from shyuan on 2012-07-31 06:20:00 EDT ---

(In reply to comment #2)
> (In reply to comment #0)
> > ...
> >  error : interfaceCreate:493 : internal error failed to create (start)
> > interface eth0: failed to execute external program - Running 'ifup eth0'
> > failed with exit code 1:
> > Determining IP information for eth0... failed; no link present.  Check cable?
> 
> I guess your NetworkManager service is running, if you stop it then you may
> get a expected result?


I have stopped it at step 2. NetworkManager service isn't running.

--- Additional comment from ajia on 2012-07-31 06:38:57 EDT ---

(In reply to comment #3)

> > I guess your NetworkManager service is running, if you stop it then you may
> > get a expected result?
> 
> 
> I have stopped it at step 2. NetworkManager service isn't running.

Yeah, I missed it, IMHO, it may be a NetworkManager bug:

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:23:AE:6F:F1:D7  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:3183137 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1439293 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:757486621 (722.3 MiB)  TX bytes:289269951 (275.8 MiB)
          Interrupt:21 Memory:febe0000-fec00000 

# service NetworkManager status
NetworkManager is stopped

# ifup eht0
/sbin/ifup: configuration for eht0 not found.
Usage: ifup <device name>
[root@201 ajia]# ifup eth0
connect: Invalid argument
RTNETLINK answers: No such device
Error adding default gateway 0.0.0.0 for eth0.
RTNETLINK answers: File exists

# echo $?
0

Notes, If ncf_if_up(nif) == 0 then libvirt thinks interface successfully brought up, in fact, 'ifup eth0' should return non-zero value in here.

--- Additional comment from laine on 2012-07-31 20:05:21 EDT ---

The problem is that when an interface is configured for dhcp, /sbin/ifup (which netcf calls to bring up the interface) will only return success if dhclient is successful in acquiring an IP address. In the meantime, ifup still sets the IFF_UP flag on the interface, and that is what netcf checks when determining the ACTIVE/INACTIVE state of an interface.

Additionally, if NetworkManager is running, /sbin/ifup will fail when the interface's cable is unplugged, even if the IP address is configured statically (so no dhcp is required).

In order to make the results of "virsh iface-start" (aka ncf_if_up()) consistent with the reported status of the interface, the following patch has been posted to the upstream netcf mailing list:

https://lists.fedorahosted.org/pipermail/netcf-devel/2012-July/000781.html

It modifies netcf's if_is_active() function to require both IFF_UP and IFF_RUNNING before considering the interface to be active, and checks the result of this function when bringing up an interface, even after /sbin/ifup has returned success.

--- Additional comment from laine on 2012-07-31 23:14:02 EDT ---

The fix has been pushed upstream:

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

    check IFF_RUNNING before considering an interface "active"
    
    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.
    
    Note that the 2nd change needed to be done separately in all three
    linux drivers, because if_is_active() is a linux-specific function, so
    it can't be called from the platform-agnostic netcf.c (yet each
    platform's drv_if_up() is different, so they can't all call a common
    util_if_up())..

Comment 1 Fedora Update System 2012-09-09 03:27:45 UTC
netcf-0.2.2-1.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/netcf-0.2.2-1.fc17

Comment 2 Fedora Update System 2012-09-10 22:23:33 UTC
Package netcf-0.2.2-1.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing netcf-0.2.2-1.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-13735/netcf-0.2.2-1.fc17
then log in and leave karma (feedback).


Note You need to log in before you can comment on or make changes to this bug.