aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch
diff options
context:
space:
mode:
authorAndy Zhou <azhou@nicira.com>2013-11-25 13:42:46 -0500
committerJesse Gross <jesse@nicira.com>2014-01-06 18:51:41 -0500
commit5bb506324d150578afadd10c3198ef5b29f5876b (patch)
tree5aed46c2280137986c2d59c4a0e43389a256331c /net/openvswitch
parent8f49ce1135676e5790d8ac5f8ecb2a218c07a33a (diff)
openvswitch: Change ovs_flow_tbl_lookup_xx() APIs
API changes only for code readability. No functional chnages. This patch removes the underscored version. Added a new API ovs_flow_tbl_lookup_stats() that returns the n_mask_hits. Reported by: Ben Pfaff <blp@nicira.com> Reviewed-by: Thomas Graf <tgraf@redhat.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'net/openvswitch')
-rw-r--r--net/openvswitch/datapath.c16
-rw-r--r--net/openvswitch/flow_table.c10
-rw-r--r--net/openvswitch/flow_table.h4
3 files changed, 16 insertions, 14 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 6f5e1dd3be2d..fcaed98b2c0d 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -234,7 +234,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
234 } 234 }
235 235
236 /* Look up flow. */ 236 /* Look up flow. */
237 flow = ovs_flow_tbl_lookup(&dp->table, &key, &n_mask_hit); 237 flow = ovs_flow_tbl_lookup_stats(&dp->table, &key, &n_mask_hit);
238 if (unlikely(!flow)) { 238 if (unlikely(!flow)) {
239 struct dp_upcall_info upcall; 239 struct dp_upcall_info upcall;
240 240
@@ -751,14 +751,6 @@ static struct sk_buff *ovs_flow_cmd_build_info(struct sw_flow *flow,
751 return skb; 751 return skb;
752} 752}
753 753
754static struct sw_flow *__ovs_flow_tbl_lookup(struct flow_table *tbl,
755 const struct sw_flow_key *key)
756{
757 u32 __always_unused n_mask_hit;
758
759 return ovs_flow_tbl_lookup(tbl, key, &n_mask_hit);
760}
761
762static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) 754static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
763{ 755{
764 struct nlattr **a = info->attrs; 756 struct nlattr **a = info->attrs;
@@ -809,7 +801,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
809 goto err_unlock_ovs; 801 goto err_unlock_ovs;
810 802
811 /* Check if this is a duplicate flow */ 803 /* Check if this is a duplicate flow */
812 flow = __ovs_flow_tbl_lookup(&dp->table, &key); 804 flow = ovs_flow_tbl_lookup(&dp->table, &key);
813 if (!flow) { 805 if (!flow) {
814 /* Bail out if we're not allowed to create a new flow. */ 806 /* Bail out if we're not allowed to create a new flow. */
815 error = -ENOENT; 807 error = -ENOENT;
@@ -921,7 +913,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
921 goto unlock; 913 goto unlock;
922 } 914 }
923 915
924 flow = __ovs_flow_tbl_lookup(&dp->table, &key); 916 flow = ovs_flow_tbl_lookup(&dp->table, &key);
925 if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) { 917 if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) {
926 err = -ENOENT; 918 err = -ENOENT;
927 goto unlock; 919 goto unlock;
@@ -969,7 +961,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
969 if (err) 961 if (err)
970 goto unlock; 962 goto unlock;
971 963
972 flow = __ovs_flow_tbl_lookup(&dp->table, &key); 964 flow = ovs_flow_tbl_lookup(&dp->table, &key);
973 if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) { 965 if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) {
974 err = -ENOENT; 966 err = -ENOENT;
975 goto unlock; 967 goto unlock;
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index f96ebd53c2cf..261a54e77503 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -429,7 +429,7 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti,
429 return NULL; 429 return NULL;
430} 430}
431 431
432struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl, 432struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *tbl,
433 const struct sw_flow_key *key, 433 const struct sw_flow_key *key,
434 u32 *n_mask_hit) 434 u32 *n_mask_hit)
435{ 435{
@@ -447,6 +447,14 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl,
447 return NULL; 447 return NULL;
448} 448}
449 449
450struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl,
451 const struct sw_flow_key *key)
452{
453 u32 __always_unused n_mask_hit;
454
455 return ovs_flow_tbl_lookup_stats(tbl, key, &n_mask_hit);
456}
457
450int ovs_flow_tbl_num_masks(const struct flow_table *table) 458int ovs_flow_tbl_num_masks(const struct flow_table *table)
451{ 459{
452 struct sw_flow_mask *mask; 460 struct sw_flow_mask *mask;
diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h
index fbe45d5ad07d..f54aa82cf81e 100644
--- a/net/openvswitch/flow_table.h
+++ b/net/openvswitch/flow_table.h
@@ -69,9 +69,11 @@ void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
69int ovs_flow_tbl_num_masks(const struct flow_table *table); 69int ovs_flow_tbl_num_masks(const struct flow_table *table);
70struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, 70struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
71 u32 *bucket, u32 *idx); 71 u32 *bucket, u32 *idx);
72struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, 72struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
73 const struct sw_flow_key *, 73 const struct sw_flow_key *,
74 u32 *n_mask_hit); 74 u32 *n_mask_hit);
75struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
76 const struct sw_flow_key *);
75 77
76bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, 78bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
77 struct sw_flow_match *match); 79 struct sw_flow_match *match);