[v3,1/1] net/bonding: fix rss key configuration when the key length is 52

Message ID 20220411054003.60095-1-ke1x.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v3,1/1] net/bonding: fix rss key configuration when the key length is 52 |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Zhang, Ke1X April 11, 2022, 5:40 a.m. UTC
  when creating a bonding device, if the slave device's rss key length
= standard_rss_key length + extended_hash_key length, then bonding
device will be same as slave, in function bond_ethdev_configure(),
the default_rss_key length is 40, it is not matched, so it should
calculate a new key for bonding device if the default key could not
be used.

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
  

Comments

humin (Q) April 13, 2022, 9:01 a.m. UTC | #1
Acked-by: Min Hu (Connor) <humin29@huawei.com>

在 2022/4/11 13:40, Ke Zhang 写道:
> when creating a bonding device, if the slave device's rss key length
> = standard_rss_key length + extended_hash_key length, then bonding
> device will be same as slave, in function bond_ethdev_configure(),
> the default_rss_key length is 40, it is not matched, so it should
> calculate a new key for bonding device if the default key could not
> be used.
> 
> Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> ---
>   drivers/net/bonding/rte_eth_bond_pmd.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index b305b6a35b..5cbe89031b 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -3617,13 +3617,18 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
>   			       internals->rss_key_len);
>   		} else {
>   			if (internals->rss_key_len > sizeof(default_rss_key)) {
> -				RTE_BOND_LOG(ERR,
> -				       "There is no suitable default hash key");
> -				return -EINVAL;
> +				/*
> +				 * If the rss_key includes standard_rss_key and
> +				 * extended_hash_key, the rss key length will be
> +				 * larger than default rss key length, so it should
> +				 * re-calculate the hash key.
> +				 */
> +				for (i = 0; i < internals->rss_key_len; i++)
> +					internals->rss_key[i] = (uint8_t)rte_rand();
> +			} else {
> +				memcpy(internals->rss_key, default_rss_key,
> +					internals->rss_key_len);
>   			}
> -
> -			memcpy(internals->rss_key, default_rss_key,
> -			       internals->rss_key_len);
>   		}
>   
>   		for (i = 0; i < RTE_DIM(internals->reta_conf); i++) {
>
  
Ferruh Yigit May 4, 2022, 4:32 p.m. UTC | #2
On 4/13/2022 10:01 AM, Min Hu (Connor) wrote:

<...>

> 在 2022/4/11 13:40, Ke Zhang 写道:
>> when creating a bonding device, if the slave device's rss key length
>> = standard_rss_key length + extended_hash_key length, then bonding
>> device will be same as slave, in function bond_ethdev_configure(),
>> the default_rss_key length is 40, it is not matched, so it should
>> calculate a new key for bonding device if the default key could not
>> be used.
>>
>> Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> 
> Acked-by: Min Hu (Connor) <humin29@huawei.com>
> 
     Fixes: 6b1a001ec546 ("net/bonding: fix RSS key length")
     Cc: stable@dpdk.org

(The fixes line not exactly true, since 52 byte keys seems not 
considered from the begging, but above commit seems the closest one to 
make the patch backported to proper releases.)

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

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index b305b6a35b..5cbe89031b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3617,13 +3617,18 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 			       internals->rss_key_len);
 		} else {
 			if (internals->rss_key_len > sizeof(default_rss_key)) {
-				RTE_BOND_LOG(ERR,
-				       "There is no suitable default hash key");
-				return -EINVAL;
+				/*
+				 * If the rss_key includes standard_rss_key and
+				 * extended_hash_key, the rss key length will be
+				 * larger than default rss key length, so it should
+				 * re-calculate the hash key.
+				 */
+				for (i = 0; i < internals->rss_key_len; i++)
+					internals->rss_key[i] = (uint8_t)rte_rand();
+			} else {
+				memcpy(internals->rss_key, default_rss_key,
+					internals->rss_key_len);
 			}
-
-			memcpy(internals->rss_key, default_rss_key,
-			       internals->rss_key_len);
 		}
 
 		for (i = 0; i < RTE_DIM(internals->reta_conf); i++) {