Skip to content

Commit

Permalink
openvswitch: Use RCU lock for dp dump operation.
Browse files Browse the repository at this point in the history
RCUfy dp-dump operation which is already read-only. This
makes all ovs dump operations lockless.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
  • Loading branch information
Pravin B Shelar authored and Jesse Gross committed Aug 23, 2013
1 parent d57170b commit 59a35d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions net/openvswitch/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,9 +951,10 @@ static struct genl_ops dp_packet_genl_ops[] = {

static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats)
{
struct flow_table *table;
int i;
struct flow_table *table = ovsl_dereference(dp->table);

table = rcu_dereference_check(dp->table, lockdep_ovsl_is_held());
stats->n_flows = ovs_flow_tbl_count(table);

stats->n_hit = stats->n_missed = stats->n_lost = 0;
Expand Down Expand Up @@ -1665,7 +1666,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
goto err_destroy_local_port;

ovs_net = net_generic(ovs_dp_get_net(dp), ovs_net_id);
list_add_tail(&dp->list_node, &ovs_net->dps);
list_add_tail_rcu(&dp->list_node, &ovs_net->dps);

ovs_unlock();

Expand Down Expand Up @@ -1703,7 +1704,7 @@ static void __dp_destroy(struct datapath *dp)
ovs_dp_detach_port(vport);
}

list_del(&dp->list_node);
list_del_rcu(&dp->list_node);

/* OVSP_LOCAL is datapath internal port. We need to make sure that
* all port in datapath are destroyed first before freeing datapath.
Expand Down Expand Up @@ -1808,16 +1809,16 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
int skip = cb->args[0];
int i = 0;

ovs_lock();
list_for_each_entry(dp, &ovs_net->dps, list_node) {
rcu_read_lock();
list_for_each_entry_rcu(dp, &ovs_net->dps, list_node) {
if (i >= skip &&
ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
OVS_DP_CMD_NEW) < 0)
break;
i++;
}
ovs_unlock();
rcu_read_unlock();

cb->args[0] = i;

Expand Down

0 comments on commit 59a35d6

Please sign in to comment.