Skip to content

Commit

Permalink
dpif-netdev: Hold global port mutex while calling offload API.
Browse files Browse the repository at this point in the history
We changed datapath port lookup to netdev-offload API usage, but
forgot that port mutex was there not only to protect datapath
port hash map.  It was there also as a workaround solution for
complete unsafety of netdev-offload-dpdk functions.

Turning it back to fix the behaviour and adding a comment to prevent
removing it in the future unless netdev-offload-dpdk fixed.

For the thread safety notice see the top of netdev-offload-dpdk.c.

Fixes: 3011580 ("dpif-netdev: Use netdev-offload API for port lookup while offloading")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Eli Britstein <elibr@mellanox.com>
  • Loading branch information
igsilya committed Dec 13, 2019
1 parent c77f3a1 commit e7cb123
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/dpif-netdev.c
Expand Up @@ -2271,7 +2271,11 @@ mark_to_flow_disassociate(struct dp_netdev_pmd_thread *pmd,

port = netdev_ports_get(in_port, pmd->dp->class);
if (port) {
/* Taking a global 'port_mutex' to fulfill thread safety
* restrictions for the netdev-offload-dpdk module. */
ovs_mutex_lock(&pmd->dp->port_mutex);
ret = netdev_flow_del(port, &flow->mega_ufid, NULL);
ovs_mutex_unlock(&pmd->dp->port_mutex);
netdev_close(port);
}

Expand Down Expand Up @@ -2415,10 +2419,14 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload)
netdev_close(port);
goto err_free;
}
/* Taking a global 'port_mutex' to fulfill thread safety restrictions for
* the netdev-offload-dpdk module. */
ovs_mutex_lock(&pmd->dp->port_mutex);
ret = netdev_flow_put(port, &offload->match,
CONST_CAST(struct nlattr *, offload->actions),
offload->actions_len, &flow->mega_ufid, &info,
NULL);
ovs_mutex_unlock(&pmd->dp->port_mutex);
netdev_close(port);

if (ret) {
Expand Down

0 comments on commit e7cb123

Please sign in to comment.