diff options
author | Joe Stringer <joestringer@nicira.com> | 2015-01-21 19:42:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-26 18:45:50 -0500 |
commit | 272c2cf84152eb7fba11407d1649c85eee243e21 (patch) | |
tree | c5f2fecdd85cb310382d7d9c37ef7cf9eea714b8 /net/openvswitch/flow_table.c | |
parent | d29ab6f8a92eceb00d6085f028b6e05213faa72d (diff) |
openvswitch: Use sw_flow_key_range for key ranges.
These minor tidyups make a future patch a little tidier.
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch/flow_table.c')
-rw-r--r-- | net/openvswitch/flow_table.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 81b977d839df..9a3f41f26da8 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c | |||
@@ -357,9 +357,11 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table) | |||
357 | return 0; | 357 | return 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | static u32 flow_hash(const struct sw_flow_key *key, int key_start, | 360 | static u32 flow_hash(const struct sw_flow_key *key, |
361 | int key_end) | 361 | const struct sw_flow_key_range *range) |
362 | { | 362 | { |
363 | int key_start = range->start; | ||
364 | int key_end = range->end; | ||
363 | const u32 *hash_key = (const u32 *)((const u8 *)key + key_start); | 365 | const u32 *hash_key = (const u32 *)((const u8 *)key + key_start); |
364 | int hash_u32s = (key_end - key_start) >> 2; | 366 | int hash_u32s = (key_end - key_start) >> 2; |
365 | 367 | ||
@@ -395,9 +397,9 @@ static bool cmp_key(const struct sw_flow_key *key1, | |||
395 | 397 | ||
396 | static bool flow_cmp_masked_key(const struct sw_flow *flow, | 398 | static bool flow_cmp_masked_key(const struct sw_flow *flow, |
397 | const struct sw_flow_key *key, | 399 | const struct sw_flow_key *key, |
398 | int key_start, int key_end) | 400 | const struct sw_flow_key_range *range) |
399 | { | 401 | { |
400 | return cmp_key(&flow->key, key, key_start, key_end); | 402 | return cmp_key(&flow->key, key, range->start, range->end); |
401 | } | 403 | } |
402 | 404 | ||
403 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, | 405 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, |
@@ -416,18 +418,15 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, | |||
416 | { | 418 | { |
417 | struct sw_flow *flow; | 419 | struct sw_flow *flow; |
418 | struct hlist_head *head; | 420 | struct hlist_head *head; |
419 | int key_start = mask->range.start; | ||
420 | int key_end = mask->range.end; | ||
421 | u32 hash; | 421 | u32 hash; |
422 | struct sw_flow_key masked_key; | 422 | struct sw_flow_key masked_key; |
423 | 423 | ||
424 | ovs_flow_mask_key(&masked_key, unmasked, mask); | 424 | ovs_flow_mask_key(&masked_key, unmasked, mask); |
425 | hash = flow_hash(&masked_key, key_start, key_end); | 425 | hash = flow_hash(&masked_key, &mask->range); |
426 | head = find_bucket(ti, hash); | 426 | head = find_bucket(ti, hash); |
427 | hlist_for_each_entry_rcu(flow, head, hash_node[ti->node_ver]) { | 427 | hlist_for_each_entry_rcu(flow, head, hash_node[ti->node_ver]) { |
428 | if (flow->mask == mask && flow->hash == hash && | 428 | if (flow->mask == mask && flow->hash == hash && |
429 | flow_cmp_masked_key(flow, &masked_key, | 429 | flow_cmp_masked_key(flow, &masked_key, &mask->range)) |
430 | key_start, key_end)) | ||
431 | return flow; | 430 | return flow; |
432 | } | 431 | } |
433 | return NULL; | 432 | return NULL; |
@@ -590,8 +589,7 @@ static void flow_key_insert(struct flow_table *table, struct sw_flow *flow) | |||
590 | struct table_instance *new_ti = NULL; | 589 | struct table_instance *new_ti = NULL; |
591 | struct table_instance *ti; | 590 | struct table_instance *ti; |
592 | 591 | ||
593 | flow->hash = flow_hash(&flow->key, flow->mask->range.start, | 592 | flow->hash = flow_hash(&flow->key, &flow->mask->range); |
594 | flow->mask->range.end); | ||
595 | ti = ovsl_dereference(table->ti); | 593 | ti = ovsl_dereference(table->ti); |
596 | table_instance_insert(ti, flow); | 594 | table_instance_insert(ti, flow); |
597 | table->count++; | 595 | table->count++; |