Add validation for the return value of rte_eth_promiscuous_enable
and rte_eth_promiscuous_disable.

Signed-off-by: Sunyang Wu <sunyang...@jaguarmicro.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 91bf2c2345..f69496feec 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2783,6 +2783,7 @@ bond_ethdev_promiscuous_update(struct rte_eth_dev *dev)
 {
        struct bond_dev_private *internals = dev->data->dev_private;
        uint16_t port_id = internals->current_primary_port;
+       int ret;
 
        switch (internals->mode) {
        case BONDING_MODE_ROUND_ROBIN:
@@ -2802,10 +2803,19 @@ bond_ethdev_promiscuous_update(struct rte_eth_dev *dev)
                 * mode should be set to new primary member according to bonding
                 * device.
                 */
-               if (rte_eth_promiscuous_get(internals->port_id) == 1)
-                       rte_eth_promiscuous_enable(port_id);
-               else
-                       rte_eth_promiscuous_disable(port_id);
+               if (rte_eth_promiscuous_get(internals->port_id) == 1) {
+                       ret = rte_eth_promiscuous_enable(port_id);
+                       if (ret != 0)
+                               RTE_BOND_LOG(ERR,
+                                            "Failed to enable promiscuous mode 
for port %u: %s",
+                                            port_id, rte_strerror(-ret));
+               } else {
+                       ret = rte_eth_promiscuous_disable(port_id);
+                       if (ret != 0)
+                               RTE_BOND_LOG(ERR,
+                                            "Failed to disable promiscuous 
mode for port %u: %s",
+                                            port_id, rte_strerror(-ret));
+               }
        }
 
        return 0;
-- 
2.19.0.rc0.windows.1

Reply via email to