Bug 1147650

Summary: virsh iface-bridge eat my ip address config
Product: Red Hat Enterprise Linux 7 Reporter: Dr. David Alan Gilbert <dgilbert>
Component: netcfAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: dyuan, honzhang, jiahu, jsuchane
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: netcf-0.2.6-2.el7 Doc Type: Bug Fix
Doc Text:
On hosts using IPADDR0/NETMASK0/PREFIX0 (instead of the more traditional IPADDR/NETMASK/PREFIX) in the ifcfg file in /etc/sysconfig/network-scripts, the "virsh iface-dumpxml" command would not show the interfaces' IP configuration, and the "virsh iface-bridge" command would not propagate the IP configuration from the physical ethernet to the newly created bridge device. netcf now recognizes IPADDR0/NETMASK0/PREFIX0, so the IP configuration is properly recognized and propagated with "virsh iface-bridge"
Story Points: ---
Clone Of:
: 1159000 (view as bug list) Environment:
Last Closed: 2015-03-05 08:51:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1159000    

Description Dr. David Alan Gilbert 2014-09-29 18:01:55 UTC
Description of problem:
I had an interface (not my main interface) that I'd originally configured using NM (nm-tui) with a static IP, and after adding a DEVICE= line to the config file I did:

virsh iface-bridge em4 brpair

it created the bridge and moved em4 to it, but complained it couldn't bring the interface up but more importantly lost the IP address configuration on the interface

Version-Release number of selected component (if applicable):
netcf-libs-0.2.3-8.el7.x86_64
libvirt-daemon-driver-interface-1.1.1-29.el7_0.1.x86_64
libvirt-daemon-driver-network-1.1.1-29.el7_0.1.x86_64
NetworkManager-0.9.9.1-13.git20140326.4dba720.el7.x86_64
NetworkManager-tui-0.9.9.1-13.git20140326.4dba720.el7.x86_64

How reproducible:
Unknown

Steps to Reproduce:
1. Take a RHEL7 system with multiple network interfaces, only one of which is wired to the internet
2. Wire another one directly to another machine
3. Configure the interface with a static IP using nm-tui
4. Edit the ifcfg- script for the interface to add the DEVICE= line
5. virsh iface-bridge em4 brpair    to create a bridge with your interface (replacing em4 as appropriate)
6. systemctl stop NetworkManager; systemctl disable NetworkManager
7. reboot.


Actual results:
No static IP address configured on either the interface or bridge

Expected results:
The IP connectivity should be the same as before the bridge was added.

Additional info:

Comment 1 Laine Stump 2014-09-29 18:08:49 UTC
This is due to netcf using IPADDR and PREFIX/NETMASK in the ifcfg file rather than IPADDR0 and PREFIX0. netcf should alter all occurrences of IPADDR/PREFIX/NETMASK to IPADDR0/PREFIX0/NETMASK0 wherever they are found, as the latter is now supported in every version of OS that both supports netcf and is also still itself being supported (i.e. RHEL6+, CentOS6+, Fedora18+).

Related to this - note that there is now also a GATEWAY0 that is used by NetworkManager, but the network service (i.e. the initscripts files) still use GATEWAY and ignore GATEWAY0. This means that it is impossible to write a single ifcfg file that can be used by both NM and the network service (if you want to specify a default route, that is).

Comment 3 Hu Jianwei 2014-10-21 03:00:48 UTC
I can reproduce it.

[root@localhost ~]# rpm -q libvirt netcf-libs
libvirt-1.2.8-5.el7.x86_64
netcf-libs-0.2.6-1.el7.x86_64

1. Using IPADDR0/NETMASK0/GATEWAY0 instead of IPADDR/NETMASK/GATEWAY
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp16s0f1
DEVICE=enp16s0f1
ONBOOT=no
BOOTPROTO=none
IPADDR0=10.66.5.124
NETMASK0=255.255.252.0
GATEWAY0=10.66.7.254
IPV6INIT=yes
IPV6_AUTOCONF=yes
DHCPV6C=no
[root@localhost ~]# virsh iface-bridge enp16s0f1 br66 --no-stp
Created bridge br66 with attached device enp16s0f1
Bridge interface br66 started

[root@localhost ~]# virsh iface-dumpxml br66
<interface type='bridge' name='br66'>
  <protocol family='ipv6'>
    <ip address='fe80::21b:21ff:fe55:b3bd' prefix='64'/>
  </protocol>
  <bridge>
    <interface type='ethernet' name='enp16s0f1'>
      <link speed='10' state='up'/>
      <mac address='00:1b:21:55:b3:bd'/>
    </interface>
  </bridge>
</interface>

[root@localhost ~]# ip ad show br66
26: br66: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 00:1b:21:55:b3:bd brd ff:ff:ff:ff:ff:ff
    inet6 fe80::21b:21ff:fe55:b3bd/64 scope link 
       valid_lft forever preferred_lft forever

[root@localhost ~]# virsh iface-unbridge br66
Device enp16s0f1 un-attached from bridge br66
Interface enp16s0f1 started

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp16s0f1
DEVICE=enp16s0f1
ONBOOT=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
DHCPV6C=no                                <==== All static config disappeared

2. Add a new IP using nmtui  
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp16s0f1
DEVICE=enp16s0f1
ONBOOT=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME="System enp16s0f1"
UUID=c5a180f8-a44b-bfc8-6f45-0f171f275fac
IPADDR=192.168.1.22
PREFIX=24
GATEWAY=192.168.1.1
IPADDR1=192.168.1.88                      <====here
PREFIX1=24                                <====here
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

[root@localhost ~]# virsh iface-dumpxml enp16s0f1
<interface type='ethernet' name='enp16s0f1'>
  <protocol family='ipv4'>
    <ip address='192.168.1.22' prefix='24'/>
    <ip address='192.168.1.88' prefix='24'/>
  </protocol>
  <link speed='10' state='up'/>
  <mac address='00:1b:21:55:b3:bd'/>
</interface>

[root@localhost ~]# ip ad show enp16s0f1
7: enp16s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:1b:21:55:b3:bd brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.22/24 brd 192.168.1.255 scope global enp16s0f1
       valid_lft forever preferred_lft forever
    inet 192.168.1.88/24 brd 192.168.1.255 scope global secondary enp16s0f1
       valid_lft forever preferred_lft forever
[root@localhost ~]# virsh iface-bridge enp16s0f1 br66 --no-stp
Created bridge br66 with attached device enp16s0f1
Bridge interface br66 started

[root@localhost ~]# virsh iface-dumpxml br66
<interface type='bridge' name='br66'>
  <protocol family='ipv4'>
    <ip address='192.168.1.22' prefix='24'/>
  </protocol>
  <protocol family='ipv6'>
    <ip address='fe80::21b:21ff:fe55:b3bd' prefix='64'/>
  </protocol>
  <bridge>
    <interface type='ethernet' name='enp16s0f1'>
      <link speed='10' state='up'/>
      <mac address='00:1b:21:55:b3:bd'/>
    </interface>
  </bridge>
</interface>

[root@localhost ~]# virsh iface-list --all
 Name                 State      MAC Address
---------------------------------------------------
 br66                 active     00:1b:21:55:b3:bd
..

[root@localhost ~]# ip ad show br66
27: br66: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 00:1b:21:55:b3:bd brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.22/24 brd 192.168.1.255 scope global br66
       valid_lft forever preferred_lft forever
    inet6 fe80::21b:21ff:fe55:b3bd/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# virsh iface-unbridge br66 
Device enp16s0f1 un-attached from bridge br66
Interface enp16s0f1 started

[root@localhost ~]# virsh iface-dumpxml enp16s0f1
<interface type='ethernet' name='enp16s0f1'>
  <protocol family='ipv4'>
    <ip address='192.168.1.22' prefix='24'/>
  </protocol>
  <link speed='10' state='up'/>
  <mac address='00:1b:21:55:b3:bd'/>
</interface>

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp16s0f1
DEVICE=enp16s0f1
ONBOOT=no
BOOTPROTO=none
IPADDR=192.168.1.22
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
IPV6INIT=yes
IPV6_AUTOCONF=yes
DHCPV6C=no                                 <=== the second IP is disappeared.

Comment 4 Laine Stump 2014-10-30 17:44:34 UTC
I've posted a patch upstream which causes netcf to recognize IPADDR0/PREFIX0/NETMASK0/GATEWAY0 (but still writes them back as IPADDR/PREFIX/GATEWAY):

  https://lists.fedorahosted.org/pipermail/netcf-devel/2014-October/000911.html

This solves the originally reported problem, but does not address what happened in reproduction case 2 described in Comment 3 (where multiple IP addresses were assigned to the same interface using IPADDR1 etc). I've cloned this BZ as Bug 1159000 to track that functionality.

Comment 5 Laine Stump 2014-11-03 15:09:49 UTC
Fix pushed upstream>:

commit c0e7734cb3c616c102cfff4ce1aeee023e85659a
Author: Laine Stump <laine>
Date:   Thu Oct 30 11:45:23 2014 -0400

    Recognize IPADDR0/PREFIX0/NETMASK0/GATEWAY0 in redhat and suse backends

Comment 9 Hu Jianwei 2014-11-17 06:51:27 UTC
I can not reproduce it on below version.

[root@dhcp-66-71-181 ~]# rpm -q netcf libvirt
netcf-0.2.6-2.el7.x86_64
libvirt-1.2.8-6.el7.x86_64

[root@dhcp-66-71-181 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
DEVICE=enp2s0
ONBOOT=yes
MTU=1500
BOOTPROTO=none
IPADDR0=10.66.71.181
NETMASK0=255.255.254.0
GATEWAY0=10.66.71.254
[root@dhcp-66-71-181 ~]# virsh iface-bridge enp2s0 br66 --no-stp
Created bridge br66 with attached device enp2s0
Bridge interface br66 started

[root@dhcp-66-71-181 ~]# virsh iface-dumpxml br66
<interface type='bridge' name='br66'>
  <protocol family='ipv4'>
    <ip address='10.66.71.181' prefix='23'/>
  </protocol>
  <protocol family='ipv6'>
    <ip address='fe80::21b:21ff:fe27:4ece' prefix='64'/>
  </protocol>
  <bridge>
    <interface type='ethernet' name='enp2s0'>
      <link speed='1000' state='up'/>
      <mac address='00:1b:21:27:4e:ce'/>
    </interface>
  </bridge>
</interface>

[root@dhcp-66-71-181 ~]# virsh iface-unbridge br66
Device enp2s0 un-attached from bridge br66
Interface enp2s0 started

[root@dhcp-66-71-181 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
DEVICE=enp2s0
ONBOOT=yes
MTU=1500
BOOTPROTO=none
IPADDR=10.66.71.181
NETMASK=255.255.254.0
GATEWAY=10.66.71.254

Do test again without suffix 0
[root@dhcp-66-71-181 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
DEVICE=enp2s0
ONBOOT=yes
MTU=1500
BOOTPROTO=none
IPADDR=10.66.71.181
NETMASK=255.255.254.0
GATEWAY=10.66.71.254
[root@dhcp-66-71-181 ~]# virsh iface-bridge enp2s0 br66 --no-stp
Created bridge br66 with attached device enp2s0
Bridge interface br66 started

[root@dhcp-66-71-181 ~]# virsh iface-dumpxml br66
<interface type='bridge' name='br66'>
  <protocol family='ipv4'>
    <ip address='10.66.71.181' prefix='23'/>
  </protocol>
  <protocol family='ipv6'>
    <ip address='fe80::21b:21ff:fe27:4ece' prefix='64'/>
  </protocol>
  <bridge>
    <interface type='ethernet' name='enp2s0'>
      <link speed='1000' state='up'/>
      <mac address='00:1b:21:27:4e:ce'/>
    </interface>
  </bridge>
</interface>

[root@dhcp-66-71-181 ~]# virsh iface-unbridge br66
Device enp2s0 un-attached from bridge br66
Interface enp2s0 started

[root@dhcp-66-71-181 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
DEVICE=enp2s0
ONBOOT=yes
MTU=1500
BOOTPROTO=none
IPADDR=10.66.71.181
NETMASK=255.255.254.0
GATEWAY=10.66.71.254

Can get expected results, changed to Verified.

Comment 11 errata-xmlrpc 2015-03-05 08:51:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0363.html