[v1,1/3] net/failsafe: avoid crash on malformed eth_dev

Message ID 16944acc809c06be57c5a489ee7143657c4d8c6f.1588705694.git.grive@u256.net (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series failsafe & ring fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-testing success Testing PASS

Commit Message

Gaëtan Rivet May 5, 2020, 7:10 p.m. UTC
  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>
---
 drivers/net/failsafe/failsafe_ether.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Ferruh Yigit May 6, 2020, 5:16 p.m. UTC | #1
On 5/5/2020 8:10 PM, Gaetan Rivet wrote:
> 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>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
index 93deacd13..2b748bd8b 100644
--- a/drivers/net/failsafe/failsafe_ether.c
+++ b/drivers/net/failsafe/failsafe_ether.c
@@ -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);