2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

openvswitch: Userspace tunneling.

Following patch adds support for userspace tunneling. Tunneling
needs three more component first is routing table which is configured by
caching kernel routes and second is ARP cache which build automatically
by snooping arp. And third is tunnel protocol table which list all
listening protocols which is populated by vswitchd as tunnel ports
are added. GRE and VXLAN protocol support is added in this patch.

Tunneling works as follows:
On packet receive vswitchd check if this packet is targeted to tunnel
port. If it is then vswitchd inserts tunnel pop action which pops
header and sends packet to tunnel port.
On packet xmit rather than generating Set tunnel action it generate
tunnel push action which has tunnel header data. datapath can use
tunnel-push action data to generate header for each packet and
forward this packet to output port. Since tunnel-push action
contains most of packet header vswitchd needs to lookup routing
table and arp table to build this action.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Pravin B Shelar
2014-11-11 11:53:47 -08:00
parent 0746a84f39
commit a36de779d7
46 changed files with 2144 additions and 77 deletions

View File

@@ -956,3 +956,38 @@ packet_format_tcp_flags(struct ds *s, uint16_t tcp_flags)
ds_put_cstr(s, "[800]");
}
}
#define ARP_PACKET_SIZE (2 + ETH_HEADER_LEN + VLAN_HEADER_LEN + \
ARP_ETH_HEADER_LEN)
void
compose_arp(struct ofpbuf *b, const uint8_t eth_src[ETH_ADDR_LEN],
ovs_be32 ip_src, ovs_be32 ip_dst)
{
struct eth_header *eth;
struct arp_eth_header *arp;
ofpbuf_clear(b);
ofpbuf_prealloc_tailroom(b, ARP_PACKET_SIZE);
ofpbuf_reserve(b, 2 + VLAN_HEADER_LEN);
eth = ofpbuf_put_uninit(b, sizeof *eth);
memcpy(eth->eth_dst, eth_addr_broadcast, ETH_ADDR_LEN);
memcpy(eth->eth_src, eth_src, ETH_ADDR_LEN);
eth->eth_type = htons(ETH_TYPE_ARP);
arp = ofpbuf_put_uninit(b, sizeof *arp);
arp->ar_hrd = htons(ARP_HRD_ETHERNET);
arp->ar_pro = htons(ARP_PRO_IP);
arp->ar_hln = sizeof arp->ar_sha;
arp->ar_pln = sizeof arp->ar_spa;
arp->ar_op = htons(ARP_OP_REQUEST);
memcpy(arp->ar_sha, eth_src, ETH_ADDR_LEN);
memset(arp->ar_tha, 0, ETH_ADDR_LEN);
put_16aligned_be32(&arp->ar_spa, ip_src);
put_16aligned_be32(&arp->ar_tpa, ip_dst);
ofpbuf_set_frame(b, eth);
ofpbuf_set_l3(b, arp);
}