aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/flow.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/openvswitch/flow.h')
-rw-r--r--net/openvswitch/flow.h47
1 files changed, 41 insertions, 6 deletions
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index 0875fde65b9c..66ef7220293e 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -40,7 +40,38 @@ struct sw_flow_actions {
40 struct nlattr actions[]; 40 struct nlattr actions[];
41}; 41};
42 42
43/* Used to memset ovs_key_ipv4_tunnel padding. */
44#define OVS_TUNNEL_KEY_SIZE \
45 (offsetof(struct ovs_key_ipv4_tunnel, ipv4_ttl) + \
46 FIELD_SIZEOF(struct ovs_key_ipv4_tunnel, ipv4_ttl))
47
48struct ovs_key_ipv4_tunnel {
49 __be64 tun_id;
50 __be32 ipv4_src;
51 __be32 ipv4_dst;
52 __be16 tun_flags;
53 u8 ipv4_tos;
54 u8 ipv4_ttl;
55};
56
57static inline void ovs_flow_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key,
58 const struct iphdr *iph, __be64 tun_id,
59 __be16 tun_flags)
60{
61 tun_key->tun_id = tun_id;
62 tun_key->ipv4_src = iph->saddr;
63 tun_key->ipv4_dst = iph->daddr;
64 tun_key->ipv4_tos = iph->tos;
65 tun_key->ipv4_ttl = iph->ttl;
66 tun_key->tun_flags = tun_flags;
67
68 /* clear struct padding. */
69 memset((unsigned char *) tun_key + OVS_TUNNEL_KEY_SIZE, 0,
70 sizeof(*tun_key) - OVS_TUNNEL_KEY_SIZE);
71}
72
43struct sw_flow_key { 73struct sw_flow_key {
74 struct ovs_key_ipv4_tunnel tun_key; /* Encapsulating tunnel key. */
44 struct { 75 struct {
45 u32 priority; /* Packet QoS priority. */ 76 u32 priority; /* Packet QoS priority. */
46 u32 skb_mark; /* SKB mark. */ 77 u32 skb_mark; /* SKB mark. */
@@ -130,7 +161,7 @@ struct sw_flow *ovs_flow_alloc(void);
130void ovs_flow_deferred_free(struct sw_flow *); 161void ovs_flow_deferred_free(struct sw_flow *);
131void ovs_flow_free(struct sw_flow *flow); 162void ovs_flow_free(struct sw_flow *flow);
132 163
133struct sw_flow_actions *ovs_flow_actions_alloc(const struct nlattr *); 164struct sw_flow_actions *ovs_flow_actions_alloc(int actions_len);
134void ovs_flow_deferred_free_acts(struct sw_flow_actions *); 165void ovs_flow_deferred_free_acts(struct sw_flow_actions *);
135 166
136int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *, 167int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *,
@@ -141,10 +172,10 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies);
141int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *); 172int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);
142int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, 173int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
143 const struct nlattr *); 174 const struct nlattr *);
144int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port, 175int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow, int key_len,
145 const struct nlattr *); 176 const struct nlattr *attr);
146 177
147#define MAX_ACTIONS_BUFSIZE (16 * 1024) 178#define MAX_ACTIONS_BUFSIZE (32 * 1024)
148#define TBL_MIN_BUCKETS 1024 179#define TBL_MIN_BUCKETS 1024
149 180
150struct flow_table { 181struct flow_table {
@@ -173,11 +204,15 @@ void ovs_flow_tbl_deferred_destroy(struct flow_table *table);
173struct flow_table *ovs_flow_tbl_alloc(int new_size); 204struct flow_table *ovs_flow_tbl_alloc(int new_size);
174struct flow_table *ovs_flow_tbl_expand(struct flow_table *table); 205struct flow_table *ovs_flow_tbl_expand(struct flow_table *table);
175struct flow_table *ovs_flow_tbl_rehash(struct flow_table *table); 206struct flow_table *ovs_flow_tbl_rehash(struct flow_table *table);
176void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow); 207void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
208 struct sw_flow_key *key, int key_len);
177void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); 209void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
178u32 ovs_flow_hash(const struct sw_flow_key *key, int key_len);
179 210
180struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx); 211struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx);
181extern const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1]; 212extern const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1];
213int ovs_ipv4_tun_from_nlattr(const struct nlattr *attr,
214 struct ovs_key_ipv4_tunnel *tun_key);
215int ovs_ipv4_tun_to_nlattr(struct sk_buff *skb,
216 const struct ovs_key_ipv4_tunnel *tun_key);
182 217
183#endif /* flow.h */ 218#endif /* flow.h */