diff options
Diffstat (limited to 'net/openvswitch/flow.h')
-rw-r--r-- | net/openvswitch/flow.h | 47 |
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 | |||
48 | struct 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 | |||
57 | static 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 | |||
43 | struct sw_flow_key { | 73 | struct 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); | |||
130 | void ovs_flow_deferred_free(struct sw_flow *); | 161 | void ovs_flow_deferred_free(struct sw_flow *); |
131 | void ovs_flow_free(struct sw_flow *flow); | 162 | void ovs_flow_free(struct sw_flow *flow); |
132 | 163 | ||
133 | struct sw_flow_actions *ovs_flow_actions_alloc(const struct nlattr *); | 164 | struct sw_flow_actions *ovs_flow_actions_alloc(int actions_len); |
134 | void ovs_flow_deferred_free_acts(struct sw_flow_actions *); | 165 | void ovs_flow_deferred_free_acts(struct sw_flow_actions *); |
135 | 166 | ||
136 | int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *, | 167 | int 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); | |||
141 | int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *); | 172 | int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *); |
142 | int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, | 173 | int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, |
143 | const struct nlattr *); | 174 | const struct nlattr *); |
144 | int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port, | 175 | int 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 | ||
150 | struct flow_table { | 181 | struct flow_table { |
@@ -173,11 +204,15 @@ void ovs_flow_tbl_deferred_destroy(struct flow_table *table); | |||
173 | struct flow_table *ovs_flow_tbl_alloc(int new_size); | 204 | struct flow_table *ovs_flow_tbl_alloc(int new_size); |
174 | struct flow_table *ovs_flow_tbl_expand(struct flow_table *table); | 205 | struct flow_table *ovs_flow_tbl_expand(struct flow_table *table); |
175 | struct flow_table *ovs_flow_tbl_rehash(struct flow_table *table); | 206 | struct flow_table *ovs_flow_tbl_rehash(struct flow_table *table); |
176 | void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow); | 207 | void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, |
208 | struct sw_flow_key *key, int key_len); | ||
177 | void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); | 209 | void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); |
178 | u32 ovs_flow_hash(const struct sw_flow_key *key, int key_len); | ||
179 | 210 | ||
180 | struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx); | 211 | struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx); |
181 | extern const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1]; | 212 | extern const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1]; |
213 | int ovs_ipv4_tun_from_nlattr(const struct nlattr *attr, | ||
214 | struct ovs_key_ipv4_tunnel *tun_key); | ||
215 | int 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 */ |