2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +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

@@ -236,6 +236,7 @@ ovs_be32 set_mpls_lse_values(uint8_t ttl, uint8_t tc, uint8_t bos,
#define ETH_TYPE_IP 0x0800
#define ETH_TYPE_ARP 0x0806
#define ETH_TYPE_TEB 0x6558
#define ETH_TYPE_VLAN_8021Q 0x8100
#define ETH_TYPE_VLAN ETH_TYPE_VLAN_8021Q
#define ETH_TYPE_VLAN_8021AD 0x88a8
@@ -498,6 +499,7 @@ struct ip_header {
ovs_16aligned_be32 ip_src;
ovs_16aligned_be32 ip_dst;
};
BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header));
#define ICMP_HEADER_LEN 8
@@ -690,6 +692,7 @@ static inline bool dl_type_is_ip_any(ovs_be16 dl_type)
|| dl_type == htons(ETH_TYPE_IPV6);
}
/* Tunnel header */
#define GENEVE_CRIT_OPT_TYPE (1 << 7)
struct geneve_opt {
ovs_be16 opt_class;
@@ -708,6 +711,29 @@ struct geneve_opt {
uint8_t opt_data[];
};
/* GRE protocol header */
struct gre_base_hdr {
ovs_be16 flags;
ovs_be16 protocol;
};
#define GRE_CSUM 0x8000
#define GRE_ROUTING 0x4000
#define GRE_KEY 0x2000
#define GRE_SEQ 0x1000
#define GRE_STRICT 0x0800
#define GRE_REC 0x0700
#define GRE_FLAGS 0x00F8
#define GRE_VERSION 0x0007
/* VXLAN protocol header */
struct vxlanhdr {
ovs_16aligned_be32 vx_flags;
ovs_16aligned_be32 vx_vni;
};
#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
void format_ipv6_addr(char *addr_str, const struct in6_addr *addr);
void print_ipv6_addr(struct ds *string, const struct in6_addr *addr);
void print_ipv6_masked(struct ds *string, const struct in6_addr *addr,
@@ -735,5 +761,7 @@ void packet_set_sctp_port(struct ofpbuf *, ovs_be16 src, ovs_be16 dst);
void packet_format_tcp_flags(struct ds *, uint16_t);
const char *packet_tcp_flag_to_string(uint32_t flag);
void compose_arp(struct ofpbuf *b, const uint8_t eth_src[ETH_ADDR_LEN],
ovs_be32 ip_src, ovs_be32 ip_dst);
#endif /* packets.h */