datapath.c (b637e4988c2d689bb43f943a5af0e684a4981159) datapath.c (618ed0c805b64c820279f50732110ab873221c3b)
1/*
2 * Copyright (c) 2007-2013 Nicira, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 147 unchanged lines hidden (view full) ---

156
157 return ifindex;
158}
159
160static void destroy_dp_rcu(struct rcu_head *rcu)
161{
162 struct datapath *dp = container_of(rcu, struct datapath, rcu);
163
1/*
2 * Copyright (c) 2007-2013 Nicira, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 147 unchanged lines hidden (view full) ---

156
157 return ifindex;
158}
159
160static void destroy_dp_rcu(struct rcu_head *rcu)
161{
162 struct datapath *dp = container_of(rcu, struct datapath, rcu);
163
164 ovs_flow_tbl_destroy(&dp->table, false);
164 ovs_flow_tbl_destroy(&dp->table);
165 free_percpu(dp->stats_percpu);
166 release_net(ovs_dp_get_net(dp));
167 kfree(dp->ports);
168 kfree(dp);
169}
170
171static struct hlist_head *vport_hash_bucket(const struct datapath *dp,
172 u16 port_no)

--- 617 unchanged lines hidden (view full) ---

790 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
791 error = -ENODEV;
792 if (!dp)
793 goto err_unlock_ovs;
794
795 /* Check if this is a duplicate flow */
796 flow = ovs_flow_tbl_lookup(&dp->table, &key);
797 if (!flow) {
165 free_percpu(dp->stats_percpu);
166 release_net(ovs_dp_get_net(dp));
167 kfree(dp->ports);
168 kfree(dp);
169}
170
171static struct hlist_head *vport_hash_bucket(const struct datapath *dp,
172 u16 port_no)

--- 617 unchanged lines hidden (view full) ---

790 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
791 error = -ENODEV;
792 if (!dp)
793 goto err_unlock_ovs;
794
795 /* Check if this is a duplicate flow */
796 flow = ovs_flow_tbl_lookup(&dp->table, &key);
797 if (!flow) {
798 struct sw_flow_mask *mask_p;
799
800 /* Bail out if we're not allowed to create a new flow. */
801 error = -ENOENT;
802 if (info->genlhdr->cmd == OVS_FLOW_CMD_SET)
803 goto err_unlock_ovs;
804
805 /* Allocate flow. */
806 flow = ovs_flow_alloc();
807 if (IS_ERR(flow)) {
808 error = PTR_ERR(flow);
809 goto err_unlock_ovs;
810 }
811 clear_stats(flow);
812
813 flow->key = masked_key;
814 flow->unmasked_key = key;
798 /* Bail out if we're not allowed to create a new flow. */
799 error = -ENOENT;
800 if (info->genlhdr->cmd == OVS_FLOW_CMD_SET)
801 goto err_unlock_ovs;
802
803 /* Allocate flow. */
804 flow = ovs_flow_alloc();
805 if (IS_ERR(flow)) {
806 error = PTR_ERR(flow);
807 goto err_unlock_ovs;
808 }
809 clear_stats(flow);
810
811 flow->key = masked_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);
831
832 /* Put flow in bucket. */
813 rcu_assign_pointer(flow->sf_acts, acts);
814
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
835 reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid,
836 info->snd_seq, OVS_FLOW_CMD_NEW);
837 } else {
838 /* We found a matching flow. */
839 struct sw_flow_actions *old_acts;
840
841 /* Bail out if we're not allowed to modify an existing flow.

--- 389 unchanged lines hidden (view full) ---

1231
1232err_destroy_local_port:
1233 ovs_dp_detach_port(ovs_vport_ovsl(dp, OVSP_LOCAL));
1234err_destroy_ports_array:
1235 kfree(dp->ports);
1236err_destroy_percpu:
1237 free_percpu(dp->stats_percpu);
1238err_destroy_table:
821
822 reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid,
823 info->snd_seq, OVS_FLOW_CMD_NEW);
824 } else {
825 /* We found a matching flow. */
826 struct sw_flow_actions *old_acts;
827
828 /* Bail out if we're not allowed to modify an existing flow.

--- 389 unchanged lines hidden (view full) ---

1218
1219err_destroy_local_port:
1220 ovs_dp_detach_port(ovs_vport_ovsl(dp, OVSP_LOCAL));
1221err_destroy_ports_array:
1222 kfree(dp->ports);
1223err_destroy_percpu:
1224 free_percpu(dp->stats_percpu);
1225err_destroy_table:
1239 ovs_flow_tbl_destroy(&dp->table, false);
1226 ovs_flow_tbl_destroy(&dp->table);
1240err_free_dp:
1241 release_net(ovs_dp_get_net(dp));
1242 kfree(dp);
1243err_unlock_ovs:
1244 ovs_unlock();
1245err:
1246 return err;
1247}

--- 667 unchanged lines hidden ---
1227err_free_dp:
1228 release_net(ovs_dp_get_net(dp));
1229 kfree(dp);
1230err_unlock_ovs:
1231 ovs_unlock();
1232err:
1233 return err;
1234}

--- 667 unchanged lines hidden ---