Bug 704065

Summary: Xen guest with isolated virtual network could ping public
Product: Red Hat Enterprise Linux 5 Reporter: zhanghaiyan <yoyzhang>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 5.7CC: dallan, dyuan, hjiang, laine, llim, mshao, xhu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-03 18:01:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description zhanghaiyan 2011-05-12 02:41:17 UTC
Description of problem:
Start a xenpv guest with isolated virtual network, but the guest still could ping to public 

Version-Release number of selected component (if applicable):
2.6.18-259.el5xen
xen-3.0.3-130.el5
libvirt-0.8.2-18.el5

How reproducible:
5/5

Steps to Reproduce:
1.Define and start an isolated virtual network
# virsh net-list --all
Name                 State      Autostart
-----------------------------------------
br1                  active     no        
default              active     yes       

# virsh net-dumpxml br1
<network>
  <name>br1</name>
  <uuid>1c596a4f-9d31-bbd4-2852-f1521d2f5391</uuid>
  <bridge name='br1' stp='on' delay='0' />
  <ip address='192.168.100.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.100.2' end='192.168.100.254' />
    </dhcp>
  </ip>
</network>
2. Define and start a guest using the isolated virtual network
# virsh list
 Id Name                 State
----------------------------------
  0 Domain-0             running
 32 xenpv-rhel6u1-x86_64 idle
# virsh dumpxml xenpv-rhel6u1-x86_64
.......
    <interface type='bridge'>
      <mac address='00:16:3e:c4:2a:c2'/>
      <source bridge='virbr0'/>
      <script path='vif-bridge'/>
      <target dev='vif32.0'/>
    </interface>
......
3. Log in the guest and ping to google.com
4. # iptables -vnL FORWARD
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  br1    br1     0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  *      br1     0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable 
    0     0 REJECT     all  --  br1    *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable 
 518K  752M ACCEPT     all  --  *      virbr0  0.0.0.0/0            192.168.122.0/24    state RELATED,ESTABLISHED 
 103K 5736K ACCEPT     all  --  virbr0 *       192.168.122.0/24     0.0.0.0/0           
    0     0 ACCEPT     all  --  virbr0 virbr0  0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  *      virbr0  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable 
    0     0 REJECT     all  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable 
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0  
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 br1
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
10.66.82.0      0.0.0.0         255.255.254.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         10.66.83.254    0.0.0.0         UG    0      0        0 eth0
# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535 
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535 
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
  
Actual results:
3. Could ping to public
(but seems in step4, the iptables rule is correct)

Expected results:
3. Cannot ping to public 

Additional info:
On kvm, the guest cannot ping to public as expected

Comment 1 Huming Jiang 2011-05-31 02:57:31 UTC
Could not reproduce this bug on the following components:
kernel-xen-2.6.18-238.el5
libvirt-0.8.2-15.el5
virt-manager-0.6.1-13.el5

Steps to Reproduce:
1.Define and start an isolated virtual network
# virsh net-list --all
Name                 State      Autostart
-----------------------------------------
br1                  active     yes        
default              active     yes       

# virsh net-dumpxml br1
<network>
  <name>br1</name>
  <uuid>b5c8a932-5d47-6760-b372-99e22a3a561a</uuid>
  <bridge name='virbr1' stp='on' delay='0' />
  <ip address='192.168.100.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.100.128' end='192.168.100.254' />
    </dhcp>
  </ip>
</network>
2. Define and start a guest using the isolated virtual network
# virsh list
 Id Name                 State
----------------------------------
  0 Domain-0             running
  2 pv6.1                idle
# virsh dumpxml xenpv-rhel6u1-x86_64
.......
    <interface type='bridge'>
      <mac address='00:16:36:5a:6f:e2'/>
      <source bridge='virbr1'/>
      <script path='vif-bridge'/>
      <target dev='vif2.0'/>
    </interface>
......
3. Log in the guest and ping to google.com
4. # iptables -vnL FORWARD
  Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   0.0.0.0         255.255.255.0   U     1      0        0 eth0
0.0.0.0         192.168.100.1   0.0.0.0         UG    0      0        0 eth0

# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Comment 3 Huming Jiang 2011-05-31 03:49:12 UTC
In my last comment, the result of step 3 is "could not ping to google.com".

Comment 4 Laine Stump 2011-06-03 18:01:30 UTC
In both test cases the configuration is not correct, and I believe this is leading to improper results.

The configuration in comment 1 is creating a libvirt virtual network named "br1" that creates a bridge device called "br1", then in the domain's interface XML is telling the guest to connect to a bridge device called *"virbr0"* - a completely unrelated device!

Beyond that, in both cases, rather than using the standard accepted method of connecting a guest's interface to a libvirt virtual network, eg:

   **CORRECT**
   <interface type='network'>
     <source network='br1'/>
     <mac address=='.....'/>
   </interface>
   **CORRECT**

(see http://wiki.libvirt.org/page/Networking) (and by the way, avoid using common names like "br1". Use something like "isolated" for the name of the network instead, to avoid confusion), you are connecting to the *bridge* that libvirt created for its virtual network as if it were a bridge created by the host's system config files:

   **WRONG**
   <interface type='bridge'>
     <source bridge='br1'/>
     ...
   **WRONG**

Finally, I'm not sure why you've included the

       <script path='vif-bridge'/>
       <target dev='vif32.0'/>

lines. These look like something that could be used to bypass libvirt's own virtual networks and connect to the network via an alternate method provided by Xen.

Because your test scenario seems to both incorrect and also not related to recommended/supported methods for using libvirt's virtual networks, I am closing this bug.

Please redo your testing in the following manner, and file a new bug (or re-open this bug if the results are the same) if you still experience a failure:


1) Create an isolated virtual network like this:

  <network>
    <name>isolated</name>
    <ip address='192.168.200.1'>
      <dhcp>
        <range start='192.168.200.2' end='192.168.200.254'/>
      </dhcp>
    </ip>
  </network>

(NB: libvirt will auto-generate a unique uuid and bridge device name)

2) configure your guest domain's interface XML like this (make sure there is only *1* <interface> element in the domain's XML!):

   <interface type='network'>
     <source network='isolated'/>
   </interface>

(NB: libvirt will auto-generate a unique mac address for the interface)

Now re-run the test.

Comment 6 zhanghaiyan 2011-06-10 09:33:40 UTC
According to comment 4 guide, I have re-tested this bug, the isolated virtual
network works well in xen guest. But a little information to update

After adding the following network interface xml into guest config xml
   <interface type='network'>
     <source network='isolated'/>
   </interface>
it is changed to bridge type automatically in guest config xml as below
    <interface type='bridge'>
      <mac address='00:16:3e:26:34:5c'/>
      <source bridge='virbr2'/>
      <script path='vif-bridge'/>
      <target dev='vif1.0'/>
    </interface>
I think it is correct, because bridge 'virbr2' is the same one with network
'isolated'
# virsh net-dumpxml isolated
<network>
  <name>isolated</name>
  <uuid>c3fdf1ce-8c39-1ba4-8c89-c65c3a3919dc</uuid>
  <bridge name='virbr2' stp='on' delay='0' />
  <ip address='10.0.0.1'>
  </ip>
</network>

The isolated virtual network works well means the guest A could ping to the host A but cannot ping to host B