LibvirtHybridOVS problem while trying to loopback packets

Asked by Asif

I have folsom/quantum setup. As we know nova creates per VM bridge and adds a veth pair between the bridge and quantum' s integration bridge. Connections are like this:

{veth1----veth0}<----->linux bridge<--->libvirt tap (VM-eth0)

Now inside the vm, i am trying to loopback packets that are coming into its eth0 interface. I am using L2 raw PACKET sockets to achieve this. The code for that is

s = socket.socket( socket.AF_PACKET , socket.SOCK_RAW)
s.bind(('eth1',0x0800))
packet = s.recvfrom(65565)
/*Then I change the source mac to this vm's mac*/
/*later on*/
s.send(packet)
So now I send packets from my veth pair and they are received in the VM. Similarly normal packets actually originated by the VM(e.g ping) are received on the veth. The problem is with these packets that are looped back, I can see them on the tap device,but cannot see them on my veth pair. The VM's eth0Frame TX count increments properly which means the packets was successfully sent from the it, hence i can see it on the tap interface.

Next device on the return path is the linux bridge. It seems to me that bridge is not getting the packets from the tap dev for some reason. BUT here is the catch, packet actually originated from the VM make it out just fine.

The RX count for the bridge is also not incrementing is this case. What could have happened? Any ideas?
However, if I start a ping from within the VM that packet reaches the tap device and the bridge. Are there any pointers to debug this issue? can we see dropped packets on tap device thats created during vif plugging?

thanks
Asif

Question information

Language:
English Edit question
Status:
Answered
For:
neutron Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
yong sheng gong (gongysh) said :
#1

where is your eth1 from? it is a double port VM? can u give more information about how u run your code?

Revision history for this message
Asif (asif-roll1) said :
#2

I have tried with both single port and double port VMs. In both cases when in case of single port i send it out via eth0 interface(i.e the same one it came from) and in case of double port I take it in from eth0 and sendout via eth1. In both cases it does not go beyond the tap device created for that interface.

I run it as a simple python script as root user.

Revision history for this message
Asif (asif-roll1) said :
#3

more code here:

try:
    s = socket.socket( socket.AF_PACKET , socket.SOCK_RAW)
    s.bind(('eth0',0x0800))
except socket.error , msg:
    print 'Socket could not be created. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
    sys.exit()

# receive a packet
while True:
    packet = s.recvfrom(65565)

    #packet string from tuple
    packet = packet[0]

    #parse ethernet header
    eth_length = 14

    eth_header = packet[:eth_length]
    eth = unpack('!6s6sH' , eth_header)
    eth_protocol = socket.ntohs(eth[2])
    print 'Destination MAC : ' + eth_addr(packet[0:6]) + ' Source MAC : ' + eth_addr(packet[6:12]) + ' Protocol : ' + str(eth_protocol)

    #Par7
    # just loopback IP packets. probably not needed.
    if eth[2] == 0x0800 :
     ....................................
  ....................................
  .... do some printing of packet data
  ....................................
  ....................................
        s.send(packet)

Can you help with this problem?

Provide an answer of your own, or ask Asif for more information if necessary.

To post a message you must log in.