[1/2] net/bonding: do not set promisc on non-existent primary port

Message ID 20190110102235.1238-2-hyonkim@cisco.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • net/bonding: a couple minor fixes
Related show

Checks

Context Check Description
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Hyong Youb Kim Jan. 10, 2019, 10:22 a.m.
For active-backup, tlb, and alb mode,
bond_ethdev_promiscuous_{enable,disable} tries to set promisc mode on
the primary port, even when there are no slaves. It is harmless, as
rte_eth_promiscuous_{enable,disable} does nothing if the port number
is invalid. But, it does print a warning message. Here is an example
from testpmd.

testpmd> create bonded device 5 0
Created new bonded device net_bonding_testpmd_0 on (port 4).
Invalid port_id=33
testpmd> set promisc 4 off
Invalid port_id=33

33 in this case is RTE_MAX_ETHPORTS + 1, the invalid primary port
number used within the bonding driver. This warning message is
harmless but can be confusing to the user. So do not try to set
promisc on a primary port when we know it does not exist (i.e. no
slaves).

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Chas Williams Feb. 9, 2019, 1:16 p.m. | #1
On 1/10/19 5:22 AM, Hyong Youb Kim wrote:
> For active-backup, tlb, and alb mode,
> bond_ethdev_promiscuous_{enable,disable} tries to set promisc mode on
> the primary port, even when there are no slaves. It is harmless, as
> rte_eth_promiscuous_{enable,disable} does nothing if the port number
> is invalid. But, it does print a warning message. Here is an example
> from testpmd.
> 
> testpmd> create bonded device 5 0
> Created new bonded device net_bonding_testpmd_0 on (port 4).
> Invalid port_id=33
> testpmd> set promisc 4 off
> Invalid port_id=33
> 
> 33 in this case is RTE_MAX_ETHPORTS + 1, the invalid primary port
> number used within the bonding driver. This warning message is
> harmless but can be confusing to the user. So do not try to set
> promisc on a primary port when we know it does not exist (i.e. no
> slaves).
> 
> Fixes: 2efb58cbab6e ("bond: new link bonding library")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>

Acked-by: Chas Williams <chas3@att.com>

> ---
>   drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index 44deaf119..daf2440cd 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2593,6 +2593,9 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
>   	case BONDING_MODE_TLB:
>   	case BONDING_MODE_ALB:
>   	default:
> +		/* Do not touch promisc when there cannot be primary ports */
> +		if (internals->slave_count == 0)
> +			break;
>   		rte_eth_promiscuous_enable(internals->current_primary_port);
>   	}
>   }
> @@ -2621,6 +2624,9 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
>   	case BONDING_MODE_TLB:
>   	case BONDING_MODE_ALB:
>   	default:
> +		/* Do not touch promisc when there cannot be primary ports */
> +		if (internals->slave_count == 0)
> +			break;
>   		rte_eth_promiscuous_disable(internals->current_primary_port);
>   	}
>   }
>
Ferruh Yigit Feb. 21, 2019, 2:38 p.m. | #2
On 2/9/2019 1:16 PM, Chas Williams wrote:
> 
> 
> On 1/10/19 5:22 AM, Hyong Youb Kim wrote:
>> For active-backup, tlb, and alb mode,
>> bond_ethdev_promiscuous_{enable,disable} tries to set promisc mode on
>> the primary port, even when there are no slaves. It is harmless, as
>> rte_eth_promiscuous_{enable,disable} does nothing if the port number
>> is invalid. But, it does print a warning message. Here is an example
>> from testpmd.
>>
>> testpmd> create bonded device 5 0
>> Created new bonded device net_bonding_testpmd_0 on (port 4).
>> Invalid port_id=33
>> testpmd> set promisc 4 off
>> Invalid port_id=33
>>
>> 33 in this case is RTE_MAX_ETHPORTS + 1, the invalid primary port
>> number used within the bonding driver. This warning message is
>> harmless but can be confusing to the user. So do not try to set
>> promisc on a primary port when we know it does not exist (i.e. no
>> slaves).
>>
>> Fixes: 2efb58cbab6e ("bond: new link bonding library")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
> 
> Acked-by: Chas Williams <chas3@att.com>

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

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 44deaf119..daf2440cd 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2593,6 +2593,9 @@  bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_TLB:
 	case BONDING_MODE_ALB:
 	default:
+		/* Do not touch promisc when there cannot be primary ports */
+		if (internals->slave_count == 0)
+			break;
 		rte_eth_promiscuous_enable(internals->current_primary_port);
 	}
 }
@@ -2621,6 +2624,9 @@  bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_TLB:
 	case BONDING_MODE_ALB:
 	default:
+		/* Do not touch promisc when there cannot be primary ports */
+		if (internals->slave_count == 0)
+			break;
 		rte_eth_promiscuous_disable(internals->current_primary_port);
 	}
 }