Ask Your Question
0

LibvirtHybridOVS problem while trying to loopback packets

asked 2013-02-02 09:52:31 -0500

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

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2013-02-03 01:36:15 -0500

gongysh gravatar image

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

edit flag offensive delete link more
0

answered 2013-02-03 06:16:52 -0500

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.

edit flag offensive delete link more
0

answered 2013-02-03 06:33:06 -0500

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)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-02-02 09:52:31 -0500

Seen: 61 times

Last updated: Feb 03 '13