Skip to contentSkip to conversation

net/af_xdp: fix failure on rte_dev_remove

PATCH Applied William Tu 4 participants 4 messages May 31, 2019 – Jun 6, 2019 Network drivers

lore
Share & tools
lore

William Tu

author
#0 lore raw

PATCH 1/1 net/af_xdp: fix failure on rte_dev_remove

When users call rte_eth_dev_close() and rte_dev_remove(), the af_xdp pmd return -1 (EPERM) due to eth_dev == NULL.

Since the af_xdp pmd driver advertises RTE_ETH_DEV_CLOSE_REMOVE, all the resources are freed on rte_eth_dev_close(). rte_dev_remove() tries to detach device and subsequently calls rte_pmd_af_xdp_remove() that tries to free already freed resources and fails. Fix it by return success.

Fixes f1debd77efaf6 ("net/af_xdp: introduce AF_XDP PMD")

Reported-at: https://patchwork.ozlabs.org/patch/1106528/

---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
index 35c72272c919..3dcc3628c5d0 100644
@@ -944,7 +944,7 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
 	/* find the ethdev entry */
 	eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
 	if (eth_dev == NULL)
-		return -1;
+		return 0;
 
 	eth_dev_close(eth_dev);
 	rte_eth_dev_release_port(eth_dev);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · William Tu

When users call rte_eth_dev_close() and rte_dev_remove(), the af_xdp pmd return -1 (EPERM) due to eth_dev == NULL.

Since the af_xdp pmd driver advertises RTE_ETH_DEV_CLOSE_REMOVE, all the resources are freed on rte_eth_dev_close(). rte_dev_remove() tries to detach device and subsequently calls rte_pmd_af_xdp_remove() that tries to free already freed resources and fails. Fix it by return success.

Fixes f1debd77efaf6 ("net/af_xdp: introduce AF_XDP PMD")

Reported-at: https://patchwork.ozlabs.org/patch/1106528/

---
drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +0 -0
index 35c72272c919..3dcc3628c5d0 100644

drivers/net/af_xdp/rte_eth_af_xdp.c rte_pmd_af_xdp_remove(struct rte_vdev_device *dev) · line 950

Quoted 8 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
@@ -944,7 +944,7 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
 	/* find the ethdev entry */
 	eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
 	if (eth_dev == NULL)
-		return -1;
+		return 0;
 
 	eth_dev_close(eth_dev);
 	rte_eth_dev_release_port(eth_dev);

Looks good to me. Thanks for the fix.

Thanks,
Xiaolong

Quoted 3 lines
Signature · 1 line
2.7.4
Applied
#2 lore raw
Quoted 28 lines · Ye Xiaolong
Quoted 27 lines · William Tu

When users call rte_eth_dev_close() and rte_dev_remove(), the af_xdp pmd return -1 (EPERM) due to eth_dev == NULL.

Since the af_xdp pmd driver advertises RTE_ETH_DEV_CLOSE_REMOVE, all the resources are freed on rte_eth_dev_close(). rte_dev_remove() tries to detach device and subsequently calls rte_pmd_af_xdp_remove() that tries to free already freed resources and fails. Fix it by return success.

Fixes f1debd77efaf6 ("net/af_xdp: introduce AF_XDP PMD")

Reported-at: https://patchwork.ozlabs.org/patch/1106528/

---
drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
index 35c72272c919..3dcc3628c5d0 100644
@@ -944,7 +944,7 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
 	/* find the ethdev entry */
 	eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
 	if (eth_dev == NULL)
-		return -1;
+		return 0;
 
Quoted 6 lines

drivers/net/af_xdp/rte_eth_af_xdp.c rte_pmd_af_xdp_remove(struct rte_vdev_device *dev) · line 950

Quoted 2 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0 -0
 	eth_dev_close(eth_dev);
 	rte_eth_dev_release_port(eth_dev);

Looks good to me. Thanks for the fix.

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

#3 lore raw

Ferruh,

Quoted 31 lines · Ferruh Yigit
Quoted 7 lines · Ye Xiaolong
Quoted 6 lines · William Tu

When users call rte_eth_dev_close() and rte_dev_remove(), the af_xdp pmd return -1 (EPERM) due to eth_dev == NULL.

Since the af_xdp pmd driver advertises RTE_ETH_DEV_CLOSE_REMOVE, all the resources are freed on rte_eth_dev_close(). rte_dev_remove() tries to detach device and subsequently calls rte_pmd_af_xdp_remove() that

tries

Quoted 11 lines

Review

Quoted 11 lines

to free already freed resources and fails. Fix it by return success.

Fixes f1debd77efaf6 ("net/af_xdp: introduce AF_XDP PMD")

Reported-at: https://patchwork.ozlabs.org/patch/1106528/

---
drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/af_xdp/rte_eth_af_xdp.c

Quoted 10 lines
Quoted 10 lines

index 35c72272c919..3dcc3628c5d0 100644

drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
@@ -944,7 +944,7 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
     /* find the ethdev entry */
     eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
     if (eth_dev == NULL)
-            return -1;
+            return 0;
 
Quoted 9 lines
Quoted 6 lines

drivers/net/af_xdp/rte_eth_af_xdp.c rte_pmd_af_xdp_remove(struct rte_vdev_device *dev) · line 950

Quoted 2 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0 -0
     eth_dev_close(eth_dev);
     rte_eth_dev_release_port(eth_dev);

Looks good to me. Thanks for the fix.

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

Don't we have similar issues with the current drivers flagged RTE_ETH_DEV_CLOSE_REMOVE ?
And we are missing a check on this flag in rte_eth_dev_pci_generic_remove().

Signature · 1 line
David Marchand