Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 332b49f

Browse files
davidarinzondavem330
authored andcommitted
net: ena: Fix toeplitz initial hash value
On driver initialization, RSS hash initial value is set to zero, instead of the default value. This happens because we pass NULL as the RSS key parameter, which caused us to never initialize the RSS hash value. This patch fixes it by making sure the initial value is set, no matter what the value of the RSS key is. Fixes: 91a65b7 ("net: ena: fix potential crash when rxfh key is NULL") Signed-off-by: Nati Koler <[email protected]> Signed-off-by: David Arinzon <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1573c68 commit 332b49f

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,29 +2400,18 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
24002400
return -EOPNOTSUPP;
24012401
}
24022402

2403-
switch (func) {
2404-
case ENA_ADMIN_TOEPLITZ:
2405-
if (key) {
2406-
if (key_len != sizeof(hash_key->key)) {
2407-
netdev_err(ena_dev->net_device,
2408-
"key len (%u) doesn't equal the supported size (%zu)\n",
2409-
key_len, sizeof(hash_key->key));
2410-
return -EINVAL;
2411-
}
2412-
memcpy(hash_key->key, key, key_len);
2413-
rss->hash_init_val = init_val;
2414-
hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
2403+
if ((func == ENA_ADMIN_TOEPLITZ) && key) {
2404+
if (key_len != sizeof(hash_key->key)) {
2405+
netdev_err(ena_dev->net_device,
2406+
"key len (%u) doesn't equal the supported size (%zu)\n",
2407+
key_len, sizeof(hash_key->key));
2408+
return -EINVAL;
24152409
}
2416-
break;
2417-
case ENA_ADMIN_CRC32:
2418-
rss->hash_init_val = init_val;
2419-
break;
2420-
default:
2421-
netdev_err(ena_dev->net_device, "Invalid hash function (%d)\n",
2422-
func);
2423-
return -EINVAL;
2410+
memcpy(hash_key->key, key, key_len);
2411+
hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
24242412
}
24252413

2414+
rss->hash_init_val = init_val;
24262415
old_func = rss->hash_func;
24272416
rss->hash_func = func;
24282417
rc = ena_com_set_hash_function(ena_dev);

0 commit comments

Comments
 (0)