diff options
Diffstat (limited to 'net/openvswitch/flow.h')
-rw-r--r-- | net/openvswitch/flow.h | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index 5e5aaed3a85b..71813318c8c7 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h | |||
@@ -49,29 +49,53 @@ 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 | ||
52 | static inline void ovs_flow_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key, | 52 | struct 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 | |||
67 | static 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 | ||
68 | struct sw_flow_key { | 88 | struct 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. */ |
72 | u32 skb_mark; /* SKB mark. */ | 94 | u32 skb_mark; /* SKB mark. */ |
73 | u16 in_port; /* Input switch port (or DP_MAX_PORTS). */ | 95 | u16 in_port; /* Input switch port (or DP_MAX_PORTS). */ |
74 | } __packed phy; /* Safe when right after 'tun_key'. */ | 96 | } __packed phy; /* Safe when right after 'tun_key'. */ |
97 | u32 ovs_flow_hash; /* Datapath computed hash value. */ | ||
98 | u32 recirc_id; /* Recirculation ID. */ | ||
75 | struct { | 99 | struct { |
76 | u8 src[ETH_ALEN]; /* Ethernet source address. */ | 100 | u8 src[ETH_ALEN]; /* Ethernet source address. */ |
77 | u8 dst[ETH_ALEN]; /* Ethernet destination address. */ | 101 | u8 dst[ETH_ALEN]; /* Ethernet destination address. */ |
@@ -187,6 +211,12 @@ void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *, | |||
187 | void ovs_flow_stats_clear(struct sw_flow *); | 211 | void ovs_flow_stats_clear(struct sw_flow *); |
188 | u64 ovs_flow_used_time(unsigned long flow_jiffies); | 212 | u64 ovs_flow_used_time(unsigned long flow_jiffies); |
189 | 213 | ||
190 | int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *); | 214 | int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key); |
215 | int ovs_flow_key_extract(struct ovs_tunnel_info *tun_info, struct sk_buff *skb, | ||
216 | struct sw_flow_key *key); | ||
217 | /* Extract key from packet coming from userspace. */ | ||
218 | int ovs_flow_key_extract_userspace(const struct nlattr *attr, | ||
219 | struct sk_buff *skb, | ||
220 | struct sw_flow_key *key); | ||
191 | 221 | ||
192 | #endif /* flow.h */ | 222 | #endif /* flow.h */ |