aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/flow.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-10-06 00:32:25 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-06 00:32:25 -0400
commit45d9cc7c609680e921060d3eb4e399043eb5e4be (patch)
treea4906c8cba2b6c2d116e7b72a71f9e1020b476cb /net/openvswitch/flow.h
parentc259c132ad284576ab44308d5d17ea6a16c971b5 (diff)
parentf5796684069e0c71c65bce6a6d4766114aec1396 (diff)
Merge branch 'geneve'
Andy Zhou says: ==================== Add Geneve tunnel protocol support This patch series adds kernel support for Geneve (Generic Network Virtualization Encapsulation) based on Geneve IETF draft: http://www.ietf.org/id/draft-gross-geneve-01.txt Patch 1 implements Geneve tunneling protocol driver Patch 2-6 adds openvswitch support for creating and using Geneve tunnels by OVS user space. v1->v2: Style fixes: use tab instead space for Kconfig Patch 2-6 are reviewed by Pravin Shetty, add him to acked-by Patch 6 was reviewed by Thomas Graf when commiting to openvswitch.org, add him to acked-by. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch/flow.h')
-rw-r--r--net/openvswitch/flow.h48
1 files changed, 35 insertions, 13 deletions
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index 0f5db4ec565d..71813318c8c7 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -49,23 +49,45 @@ struct ovs_key_ipv4_tunnel {
49 u8 ipv4_ttl; 49 u8 ipv4_ttl;
50} __packed __aligned(4); /* Minimize padding. */ 50} __packed __aligned(4); /* Minimize padding. */
51 51
52static inline void ovs_flow_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key, 52struct ovs_tunnel_info {
53 const struct iphdr *iph, __be64 tun_id, 53 struct ovs_key_ipv4_tunnel tunnel;
54 __be16 tun_flags) 54 struct geneve_opt *options;
55 u8 options_len;
56};
57
58/* Store options at the end of the array if they are less than the
59 * maximum size. This allows us to get the benefits of variable length
60 * matching for small options.
61 */
62#define GENEVE_OPTS(flow_key, opt_len) \
63 ((struct geneve_opt *)((flow_key)->tun_opts + \
64 FIELD_SIZEOF(struct sw_flow_key, tun_opts) - \
65 opt_len))
66
67static inline void ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info,
68 const struct iphdr *iph,
69 __be64 tun_id, __be16 tun_flags,
70 struct geneve_opt *opts,
71 u8 opts_len)
55{ 72{
56 tun_key->tun_id = tun_id; 73 tun_info->tunnel.tun_id = tun_id;
57 tun_key->ipv4_src = iph->saddr; 74 tun_info->tunnel.ipv4_src = iph->saddr;
58 tun_key->ipv4_dst = iph->daddr; 75 tun_info->tunnel.ipv4_dst = iph->daddr;
59 tun_key->ipv4_tos = iph->tos; 76 tun_info->tunnel.ipv4_tos = iph->tos;
60 tun_key->ipv4_ttl = iph->ttl; 77 tun_info->tunnel.ipv4_ttl = iph->ttl;
61 tun_key->tun_flags = tun_flags; 78 tun_info->tunnel.tun_flags = tun_flags;
62 79
63 /* clear struct padding. */ 80 /* clear struct padding. */
64 memset((unsigned char *) tun_key + OVS_TUNNEL_KEY_SIZE, 0, 81 memset((unsigned char *)&tun_info->tunnel + OVS_TUNNEL_KEY_SIZE, 0,
65 sizeof(*tun_key) - OVS_TUNNEL_KEY_SIZE); 82 sizeof(tun_info->tunnel) - OVS_TUNNEL_KEY_SIZE);
83
84 tun_info->options = opts;
85 tun_info->options_len = opts_len;
66} 86}
67 87
68struct sw_flow_key { 88struct sw_flow_key {
89 u8 tun_opts[255];
90 u8 tun_opts_len;
69 struct ovs_key_ipv4_tunnel tun_key; /* Encapsulating tunnel key. */ 91 struct ovs_key_ipv4_tunnel tun_key; /* Encapsulating tunnel key. */
70 struct { 92 struct {
71 u32 priority; /* Packet QoS priority. */ 93 u32 priority; /* Packet QoS priority. */
@@ -190,8 +212,8 @@ void ovs_flow_stats_clear(struct sw_flow *);
190u64 ovs_flow_used_time(unsigned long flow_jiffies); 212u64 ovs_flow_used_time(unsigned long flow_jiffies);
191 213
192int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key); 214int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key);
193int ovs_flow_key_extract(struct ovs_key_ipv4_tunnel *tun_key, 215int ovs_flow_key_extract(struct ovs_tunnel_info *tun_info, struct sk_buff *skb,
194 struct sk_buff *skb, struct sw_flow_key *key); 216 struct sw_flow_key *key);
195/* Extract key from packet coming from userspace. */ 217/* Extract key from packet coming from userspace. */
196int ovs_flow_key_extract_userspace(const struct nlattr *attr, 218int ovs_flow_key_extract_userspace(const struct nlattr *attr,
197 struct sk_buff *skb, 219 struct sk_buff *skb,