Openstack neutron ovs ARP Responder

Source: Internet
Author: User
Tags openvswitch

ARP-why do we need it?

In any environment, be it the physical data-center, your home, or a rolling alization cloud, machines need to know the Mac, or physical network address, of the next hop. for example, let there be two machines connected directly via a switch:

The first machine has an IP address of 10.0.0.1, and a MAC address of 0000: Dead: beef,

While the second machine has an IP address of 10.0.0.2, and a MAC address of 2222: Face: b00c.

I merrily log into the first machine and hit 'Ping 10.0.0.2 ', my computer places 10.0.0.2 in the destination IP field of the IP packet, then attempts to place a destination MAC address in the Ethernet header, and politely bonks itself on its digital forehead. messages must be forwarded out of a computer's Nic with the destination MAC address of the next hop (in this case 10.0.0, 2, as they're directly connected ). this is so switches know where to forward the frame to, for example.

Well, at this point, the first computer has never talked to the second one, so of course it doesn't know its MAC address. how do you discover something that you don't know? You ask! In this case, you shout. 10.0.0.1 will flood, or broadcast, an ARP request saying: What is the MAC address of 10.0.0.2? This message will be sent ed by the entire broadcast domain. 10.0.0.2 will receive this message (amongst others) and happily reply, in Unicast: I am 10.0.0.2 and my mac address is 2222: Face: b00c. the first computer will receive the ARP reply and will then be able to fill in the destination MAC address field, and finally send the ping.

Will this entire process be repeated every time the two computers wish to talk to each other? No. Sane devices keep a local cache of ARP responses. in Linux You may view the current cache with the 'Arp 'command.

A slightly more complex case wocould be two computers separated by a Layer 3 hop, or a router. in this case the two computers are in different subnets, for example 10.0.0.0/8 and 255.0.0.0/8. when the first computer pings the second one, the OS will notice that the destination is in a different subnet, and thus forward the message to the default gateway. in this case the ARP request will be sent for the MAC address of the pre-configured default gateway IP address. A device only cares about the MAC address of the next hop, not of the final destination.

The absurdity of l2pop without an ARP Responder

Let there be VM 1 hosted on Compute node A, and Vm 2 hosted on Compute Node B.

With l2pop disabled, when VM 1 sends an initial message to VM 2, compute node A won't know the MAC address of VM 2 and will be forced to flood the message out all tunnels, to all compute nodes. when the reply is already ed, node A wocould learn the MAC address of VM 2 along with the remote node and tunnel ID. this way, future floods are prevented. l2pop prevents even the initial flood by pre-populating the tables, as the neutron service is aware of vm mac addresses, scheduling, and tunnel IDs. more information may be found in the dedicated l2pop post.

So, we optimized one broadcast, but what about Arps? Compute node A is aware of the MAC address (and whereabouts) of VM 2, but VM 1 isn' t. thus, when sending an initial message from VM 1 to 2, an ARP request will be sent out. compute node A knows the MAC address of VM 2 but chooses to put a blindfold over its eyes and send a broadcast anyway. well, with the ARP responder feature this is no longer case.

The ovs ARP responder-how does it work?

A new table is inserted into the Br-tun ovs bridge, to be used as an ARP table. whenever a message is received ed by Br-tun from a local Vm, it is classified into unicast, broadcast/multicast and now ARP requests. ARP requests go into the ARP table, where pre-learned MAC addresses (via l2pop, more in a minute) reside. rows in this table are then matched against the (ARP protocol, network, IP of the requested VM) tuple. the resulting action is to construct an ARP reply that will contain in the IP and MAC addresses of the remote Vm, and will be sent back from the port it came in on to the VM making the original request. if a match is not found (for example, if the VM is trying to access a physical device not managed by neutron, thus was never learned via l2pop ), the ARP table contains a final default flow, to resubmit the message to the broadcast/multicast table, and the message will be treated like any old broadcast.

The table is filled whenever new l2pop address changes come in. for example, when VM 3 is hosted on Compute C, both compute nodes A and B get a message that a VM 3 with IP address 'X' and MAC address 'y' is now on host C, in network 'Z '. thus, compute nodes A and B can now fill their respective ARP tables with VM 3's IP and MAC addresses.

The interesting code is currently:

Https://github.com/openstack/neutron/blob/master/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py#L484

For help on reading ovs tables, and an explanation of ovs flows and how they're comprised of match and action parts, please see aprevious post.

Blow by blow:

Here's the action part:

Actions = ('move: nxm_of_eth_src []-> nxm_of_eth_dst [], '-place the source MAC address of the request (the requesting VM) as the new reply's destination MAC address

'Mod _ dl_src: % (MAC) s, '-put the requested MAC address of the remote VM as this message's source MAC address

'Load: 0x2-> nxm_of_arp_op [], '-put an 0x2 code as the type of the ARP message. 0x2 is an ARP response.

'Move: nxm_nx_arp_sha []-> nxm_nx_arp_tha [], '-place the ARP request's source hardware address (MAC) as this new message's ARP target/destination hardware address

'Move: nxm_of_arp_spa []-> nxm_of_arp_tpa [], '-place the ARP request's source protocol/IP address as the new message's ARP destination IP address

'Load: % (MAC) # X-> nxm_nx_arp_sha [], '-place the requested VM's MAC address as the source MAC address of the ARP reply

'Load: % (IP) # X-> nxm_of_arp_spa [], '-place the requested VM's IP address as the source IP address of the ARP reply

'In _ port' % {'mac': Mac, 'IP': IP})-forward the message back to the port it came in on

Here's the match part:

Self. tun_br.add_flow (Table = constants. arp_responder,-add this new flow to the arp_responder table

Priority = 1,-with a priority of 1 (another, default flow with the lower priority of 0 is added elsewhere in the Code)

PROTO = 'Arp ',-match only on ARP messages

Dl_vlan = lvid,-match only if the destination VLAN (the message has been locally VLAN tagged by now) matches the vlan id/network of the remote VM

Nw_dst = '% s' % IP,-match on the IP address of the remote VM in question

Actions = Actions)

Example:

An ARP request comes in.

In the Ethernet frame, the source MAC address is a, the destination MAC address is FFFF: FFFF.

In the ARP header, the source IP address is 10.0.0.1, the destination IP is 10.0.0.2, the source MAC is A, and the destination MAC is FFFF: FFFF.

Please make sure that entire part makes sense before moving on.

Assuming l2pop has already learned about vm B, the hypervisor's ARP table will already contain an ARP entry for vm B, with IP 10.0.0.2 and Mac B.

Will this message be matched? Sure, the Proto is 'Arp ', they're in the same network so dl_vlan will be correct, and nw_dst (this part is slightly confusing) will correctly match on the destination IP address of the ARP header, seeing as ARP replaces IP in the third layer during ARP messages.

What will be the action? Well, we 'd expect CT an ARP reply. remember that ARP replies reverse the source and destination so that the source MAC and IP inside the ARP header are the Mac and IP addresses of the machine we asked about originally, and the destination MAC address in the ARP header is the MAC address of the machine originating the ARP request. similarly we 'd got CT that the source MAC of the Ethernet frame wocould be the MAC of the VM we're querying about, and the destination MAC of the Ethernet frame wocould be the MAC of the VM originating the ARP request. if you carefully observe the explanation of the action part above, you wocould see that this is indeed the case.

Thus, the source MAC of the Ethernet frame wocould be B, the destination MAC. in the ARP header, the Source IP 10.0.0.2 and source mac B, while the destination IP 10.0.0.1 and destination MAC. this ARP reply will be forwarded back through the port which it came in on and will be released ed by vm. vm a will unpack the ARP reply and find the MAC address which it queried about in the source MAC address of the ARP header.

Turning it on

Assuming ml2 + ovs >=2.1:

  • Turn on GRE or vxlan tenant networks as you normally wowould
  • Enable l2pop
    • On the neutron API node, in the conf file you pass to the neutron Service (plugin. INI/ml2_conf.ini ):
[ml2]mechanism_drivers = openvswitch,l2population
    • On each compute node, in the conf file you pass to the ovs agent (plugin. INI/ml2_conf.ini ):
[agent]l2_population = True
  • Enable the ARP responder: on each compute node, in the conf file you pass to the ovs agent (plugin. INI/ml2_conf.ini ):
[agent]arp_responder = True

To summarize, you must use vxlan or GRE tenant networks, you must enable l2pop, and finally you need to enable the arp_responder flag in the [Agent] section in the conf file you pass to the ovs agent on each compute node.

Thanks

Props to Edouard thuleau for taking the initiative and doing the hard work, and for the rest of the neutron team in the lengthy review process! It took us nearly 8 months but we finally got it merged, in fantastic shape.

This article from http://assafmuller.com/2014/05/21/ovs-arp-responder-theory-and-practice/

Openstack neutron ovs ARP Responder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.