net/failsafe: avoid crash on malformed ethdev

Some PMD do not respect the eth_dev API when allocating their
rte_eth_dev. As a result, on device add event resulting from
rte_eth_dev_probing_finish() call, the eth_dev processed is incomplete.

The segfault is a good way to focus the developer on the issue, but does
not inspire confidence. Instead, warn the user of the error repeatedly.

The failsafe PMD can warn of the issue and continue. It will repeatedly
attempt to initialize the failed port and complain about it, which
should result in the same developer focus but with less crashing.

Signed-off-by: Gaetan Rivet <grive@u256.net>
This commit is contained in:
Gaetan Rivet 2020-05-05 21:10:29 +02:00 committed by Ferruh Yigit
parent b9663f6035
commit 94a6f2def2

View File

@ -623,6 +623,11 @@ failsafe_eth_new_event_callback(uint16_t port_id,
FOREACH_SUBDEV_STATE(sdev, i, fs_dev, DEV_PARSED) {
if (sdev->state >= DEV_PROBED)
continue;
if (dev->device == NULL) {
WARN("Trying to probe malformed device %s.\n",
sdev->devargs.name);
continue;
}
if (strcmp(sdev->devargs.name, dev->device->name) != 0)
continue;
rte_eth_dev_owner_set(port_id, &PRIV(fs_dev)->my_owner);