ethdev: handle removed device properly on promisc replay

Message ID 1569344480-7571-1-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: handle removed device properly on promisc replay |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Rybchenko Sept. 24, 2019, 5:01 p.m. UTC
  Promiscuous mode callback may return error if the device is removed.
Use eth_err() helper to check the condition and return appropriate
error code.

Fixes: dff6d544fb3c ("ethdev: do nothing if promiscuous mode is applied again")

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 lib/librte_ethdev/rte_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Sept. 26, 2019, 10:43 a.m. UTC | #1
On 9/24/2019 6:01 PM, Andrew Rybchenko wrote:
> Promiscuous mode callback may return error if the device is removed.
> Use eth_err() helper to check the condition and return appropriate
> error code.
> 
> Fixes: dff6d544fb3c ("ethdev: do nothing if promiscuous mode is applied again")
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Squashed into relevant commit in next-net, thanks.
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index d0da3322e..af823607c 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1401,7 +1401,8 @@  rte_eth_dev_config_restore(struct rte_eth_dev *dev,
 	 */
 	if (rte_eth_promiscuous_get(port_id) == 1 &&
 	    *dev->dev_ops->promiscuous_enable != NULL) {
-		ret = (*dev->dev_ops->promiscuous_enable)(dev);
+		ret = eth_err(port_id,
+			      (*dev->dev_ops->promiscuous_enable)(dev));
 		if (ret != 0 && ret != -ENOTSUP) {
 			RTE_ETHDEV_LOG(ERR,
 				"Failed to enable promiscuous mode for device (port %u): %s\n",
@@ -1410,7 +1411,8 @@  rte_eth_dev_config_restore(struct rte_eth_dev *dev,
 		}
 	} else if (rte_eth_promiscuous_get(port_id) == 0 &&
 		   *dev->dev_ops->promiscuous_disable != NULL) {
-		ret = (*dev->dev_ops->promiscuous_disable)(dev);
+		ret = eth_err(port_id,
+			      (*dev->dev_ops->promiscuous_disable)(dev));
 		if (ret != 0 && ret != -ENOTSUP) {
 			RTE_ETHDEV_LOG(ERR,
 				"Failed to disable promiscuous mode for device (port %u): %s\n",