ethdev: add lock to port allocation check
authorMatan Azrad <matan@mellanox.com>
Thu, 10 May 2018 23:58:32 +0000 (01:58 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:31:53 +0000 (22:31 +0100)
commitac7d3b6ddf87e1e0435de6d40cfe2749dc0ff9a4
tree7a7a6eeeaae2a046ccb3b29ccd54a8158e705342
parent33c73aae32e4ec46d16ab6968b164682e648579a
ethdev: add lock to port allocation check

When comparing the port name, there can be a race condition with
a thread allocating a new port and writing the name at the same time.
It can lead to match with a partial name by error.

The check of the port is now considered as a critical section
protected with locks.

This fix will be even more required for multi-process when the
port availability will rely only on the name, in a following patch.

Fixes: 84934303a17c ("ethdev: synchronize port allocation")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_ethdev/rte_ethdev.c