mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-20 03:04:01 +08:00
openvswitch: Minimize ovs_flow_cmd_del critical section.
ovs_flow_cmd_del() now allocates reply (if needed) after the flow has already been removed from the flow table. If the reply allocation fails, a netlink error is signaled with netlink_set_err(), as is already done in ovs_flow_cmd_new_or_set() in the similar situation. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
This commit is contained in:
parent
0e9796b4af
commit
aed067783e
@ -984,50 +984,53 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
|
|||||||
struct sw_flow_match match;
|
struct sw_flow_match match;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (likely(a[OVS_FLOW_ATTR_KEY])) {
|
||||||
|
ovs_match_init(&match, &key, NULL);
|
||||||
|
err = ovs_nla_get_match(&match, a[OVS_FLOW_ATTR_KEY], NULL);
|
||||||
|
if (unlikely(err))
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
ovs_lock();
|
ovs_lock();
|
||||||
dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
|
dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
|
||||||
if (!dp) {
|
if (unlikely(!dp)) {
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!a[OVS_FLOW_ATTR_KEY]) {
|
if (unlikely(!a[OVS_FLOW_ATTR_KEY])) {
|
||||||
err = ovs_flow_tbl_flush(&dp->table);
|
err = ovs_flow_tbl_flush(&dp->table);
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
ovs_match_init(&match, &key, NULL);
|
|
||||||
err = ovs_nla_get_match(&match, a[OVS_FLOW_ATTR_KEY], NULL);
|
|
||||||
if (err)
|
|
||||||
goto unlock;
|
|
||||||
|
|
||||||
flow = ovs_flow_tbl_lookup(&dp->table, &key);
|
flow = ovs_flow_tbl_lookup(&dp->table, &key);
|
||||||
if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) {
|
if (unlikely(!flow || !ovs_flow_cmp_unmasked_key(flow, &match))) {
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = ovs_flow_cmd_alloc_info(ovsl_dereference(flow->sf_acts), info,
|
|
||||||
false);
|
|
||||||
if (IS_ERR(reply)) {
|
|
||||||
err = PTR_ERR(reply);
|
|
||||||
goto unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
ovs_flow_tbl_remove(&dp->table, flow);
|
ovs_flow_tbl_remove(&dp->table, flow);
|
||||||
|
ovs_unlock();
|
||||||
|
|
||||||
if (reply) {
|
reply = ovs_flow_cmd_alloc_info((const struct sw_flow_actions __force *) flow->sf_acts,
|
||||||
|
info, false);
|
||||||
|
if (likely(reply)) {
|
||||||
|
if (likely(!IS_ERR(reply))) {
|
||||||
|
rcu_read_lock(); /*To keep RCU checker happy. */
|
||||||
err = ovs_flow_cmd_fill_info(flow, ovs_header->dp_ifindex,
|
err = ovs_flow_cmd_fill_info(flow, ovs_header->dp_ifindex,
|
||||||
reply, info->snd_portid,
|
reply, info->snd_portid,
|
||||||
info->snd_seq, 0,
|
info->snd_seq, 0,
|
||||||
OVS_FLOW_CMD_DEL);
|
OVS_FLOW_CMD_DEL);
|
||||||
|
rcu_read_unlock();
|
||||||
BUG_ON(err < 0);
|
BUG_ON(err < 0);
|
||||||
}
|
|
||||||
ovs_flow_free(flow, true);
|
|
||||||
ovs_unlock();
|
|
||||||
|
|
||||||
if (reply)
|
|
||||||
ovs_notify(&dp_flow_genl_family, reply, info);
|
ovs_notify(&dp_flow_genl_family, reply, info);
|
||||||
|
} else {
|
||||||
|
netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 0, PTR_ERR(reply));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ovs_flow_free(flow, true);
|
||||||
return 0;
|
return 0;
|
||||||
unlock:
|
unlock:
|
||||||
ovs_unlock();
|
ovs_unlock();
|
||||||
|
Loading…
Reference in New Issue
Block a user