diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2013-10-04 03:17:42 -0400 |
---|---|---|
committer | Jesse Gross <jesse@nicira.com> | 2013-10-04 03:18:30 -0400 |
commit | 618ed0c805b64c820279f50732110ab873221c3b (patch) | |
tree | 28af2a6cbc7d81cbc19b02fb4b9c79079a03a8ce /net/openvswitch/datapath.c | |
parent | b637e4988c2d689bb43f943a5af0e684a4981159 (diff) |
openvswitch: Simplify mega-flow APIs.
Hides mega-flow implementation in flow_table.c rather than
datapath.c.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r-- | net/openvswitch/datapath.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 60b9be3b9477..cf270973095d 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -161,7 +161,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu) | |||
161 | { | 161 | { |
162 | struct datapath *dp = container_of(rcu, struct datapath, rcu); | 162 | struct datapath *dp = container_of(rcu, struct datapath, rcu); |
163 | 163 | ||
164 | ovs_flow_tbl_destroy(&dp->table, false); | 164 | ovs_flow_tbl_destroy(&dp->table); |
165 | free_percpu(dp->stats_percpu); | 165 | free_percpu(dp->stats_percpu); |
166 | release_net(ovs_dp_get_net(dp)); | 166 | release_net(ovs_dp_get_net(dp)); |
167 | kfree(dp->ports); | 167 | kfree(dp->ports); |
@@ -795,8 +795,6 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) | |||
795 | /* Check if this is a duplicate flow */ | 795 | /* Check if this is a duplicate flow */ |
796 | flow = ovs_flow_tbl_lookup(&dp->table, &key); | 796 | flow = ovs_flow_tbl_lookup(&dp->table, &key); |
797 | if (!flow) { | 797 | if (!flow) { |
798 | struct sw_flow_mask *mask_p; | ||
799 | |||
800 | /* Bail out if we're not allowed to create a new flow. */ | 798 | /* Bail out if we're not allowed to create a new flow. */ |
801 | error = -ENOENT; | 799 | error = -ENOENT; |
802 | if (info->genlhdr->cmd == OVS_FLOW_CMD_SET) | 800 | if (info->genlhdr->cmd == OVS_FLOW_CMD_SET) |
@@ -812,25 +810,14 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) | |||
812 | 810 | ||
813 | flow->key = masked_key; | 811 | flow->key = masked_key; |
814 | flow->unmasked_key = key; | 812 | flow->unmasked_key = key; |
815 | |||
816 | /* Make sure mask is unique in the system */ | ||
817 | mask_p = ovs_sw_flow_mask_find(&dp->table, &mask); | ||
818 | if (!mask_p) { | ||
819 | /* Allocate a new mask if none exsits. */ | ||
820 | mask_p = ovs_sw_flow_mask_alloc(); | ||
821 | if (!mask_p) | ||
822 | goto err_flow_free; | ||
823 | mask_p->key = mask.key; | ||
824 | mask_p->range = mask.range; | ||
825 | ovs_sw_flow_mask_insert(&dp->table, mask_p); | ||
826 | } | ||
827 | |||
828 | ovs_sw_flow_mask_add_ref(mask_p); | ||
829 | flow->mask = mask_p; | ||
830 | rcu_assign_pointer(flow->sf_acts, acts); | 813 | rcu_assign_pointer(flow->sf_acts, acts); |
831 | 814 | ||
832 | /* Put flow in bucket. */ | 815 | /* Put flow in bucket. */ |
833 | ovs_flow_tbl_insert(&dp->table, flow); | 816 | error = ovs_flow_tbl_insert(&dp->table, flow, &mask); |
817 | if (error) { | ||
818 | acts = NULL; | ||
819 | goto err_flow_free; | ||
820 | } | ||
834 | 821 | ||
835 | reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid, | 822 | reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid, |
836 | info->snd_seq, OVS_FLOW_CMD_NEW); | 823 | info->snd_seq, OVS_FLOW_CMD_NEW); |
@@ -1236,7 +1223,7 @@ err_destroy_ports_array: | |||
1236 | err_destroy_percpu: | 1223 | err_destroy_percpu: |
1237 | free_percpu(dp->stats_percpu); | 1224 | free_percpu(dp->stats_percpu); |
1238 | err_destroy_table: | 1225 | err_destroy_table: |
1239 | ovs_flow_tbl_destroy(&dp->table, false); | 1226 | ovs_flow_tbl_destroy(&dp->table); |
1240 | err_free_dp: | 1227 | err_free_dp: |
1241 | release_net(ovs_dp_get_net(dp)); | 1228 | release_net(ovs_dp_get_net(dp)); |
1242 | kfree(dp); | 1229 | kfree(dp); |