Skip to content

Commit 59a35d6

Browse files
Pravin B Shelarjessegross
authored andcommitted
openvswitch: Use RCU lock for dp dump operation.
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>
1 parent d57170b commit 59a35d6

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎net/openvswitch/datapath.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -951,9 +951,10 @@ static struct genl_ops dp_packet_genl_ops[] = {
951951

952952
static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats)
953953
{
954+
struct flow_table *table;
954955
int i;
955-
struct flow_table *table = ovsl_dereference(dp->table);
956956

957+
table = rcu_dereference_check(dp->table, lockdep_ovsl_is_held());
957958
stats->n_flows = ovs_flow_tbl_count(table);
958959

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

16671668
ovs_net = net_generic(ovs_dp_get_net(dp), ovs_net_id);
1668-
list_add_tail(&dp->list_node, &ovs_net->dps);
1669+
list_add_tail_rcu(&dp->list_node, &ovs_net->dps);
16691670

16701671
ovs_unlock();
16711672

@@ -1703,7 +1704,7 @@ static void __dp_destroy(struct datapath *dp)
17031704
ovs_dp_detach_port(vport);
17041705
}
17051706

1706-
list_del(&dp->list_node);
1707+
list_del_rcu(&dp->list_node);
17071708

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

1811-
ovs_lock();
1812-
list_for_each_entry(dp, &ovs_net->dps, list_node) {
1812+
rcu_read_lock();
1813+
list_for_each_entry_rcu(dp, &ovs_net->dps, list_node) {
18131814
if (i >= skip &&
18141815
ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
18151816
cb->nlh->nlmsg_seq, NLM_F_MULTI,
18161817
OVS_DP_CMD_NEW) < 0)
18171818
break;
18181819
i++;
18191820
}
1820-
ovs_unlock();
1821+
rcu_read_unlock();
18211822

18221823
cb->args[0] = i;
18231824

0 commit comments

Comments
 (0)