Skip to content

Commit 8ec609d

Browse files
author
Pravin B Shelar
committed
openvswitch: Convert dp rcu read operation to locked operations
dp read operations depends on ovs_dp_cmd_fill_info(). This API needs to looup vport to find dp name, but vport lookup can fail. Therefore to keep vport reference alive we need to take ovs lock. Introduced by commit 6093ae9 ("openvswitch: Minimize dp and vport critical sections"). Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
1 parent 19e7a3d commit 8ec609d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎net/openvswitch/datapath.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ static size_t ovs_dp_cmd_msg_size(void)
12651265
return msgsize;
12661266
}
12671267

1268-
/* Called with ovs_mutex or RCU read lock. */
1268+
/* Called with ovs_mutex. */
12691269
static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,
12701270
u32 portid, u32 seq, u32 flags, u8 cmd)
12711271
{
@@ -1555,7 +1555,7 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct genl_info *info)
15551555
if (!reply)
15561556
return -ENOMEM;
15571557

1558-
rcu_read_lock();
1558+
ovs_lock();
15591559
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
15601560
if (IS_ERR(dp)) {
15611561
err = PTR_ERR(dp);
@@ -1564,12 +1564,12 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct genl_info *info)
15641564
err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
15651565
info->snd_seq, 0, OVS_DP_CMD_NEW);
15661566
BUG_ON(err < 0);
1567-
rcu_read_unlock();
1567+
ovs_unlock();
15681568

15691569
return genlmsg_reply(reply, info);
15701570

15711571
err_unlock_free:
1572-
rcu_read_unlock();
1572+
ovs_unlock();
15731573
kfree_skb(reply);
15741574
return err;
15751575
}
@@ -1581,16 +1581,16 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
15811581
int skip = cb->args[0];
15821582
int i = 0;
15831583

1584-
rcu_read_lock();
1585-
list_for_each_entry_rcu(dp, &ovs_net->dps, list_node) {
1584+
ovs_lock();
1585+
list_for_each_entry(dp, &ovs_net->dps, list_node) {
15861586
if (i >= skip &&
15871587
ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
15881588
cb->nlh->nlmsg_seq, NLM_F_MULTI,
15891589
OVS_DP_CMD_NEW) < 0)
15901590
break;
15911591
i++;
15921592
}
1593-
rcu_read_unlock();
1593+
ovs_unlock();
15941594

15951595
cb->args[0] = i;
15961596

0 commit comments

Comments
 (0)