From d5ff4624498d0d212df0a563e69ccb5d006faba0 Mon Sep 17 00:00:00 2001 From: Sanath Kumar Gampa Date: Thu, 27 Jun 2024 05:37:48 +0000 Subject: [PATCH] nvethernet: Generate Hkey based on SAK - Remove restriction to allow multicast addresses to be added to byp_lut and sci_lut - Also update the usage of macsec_enable node to enable/disable both Tx and Rx traffic - Fix the issue of generating same Hkey for differet SAK by moving the Hey key generation logic post obtaining SAK Bug 4715173 Bug 4715001 Change-Id: I7d3088a1f58203a474b659c7197bacc05e8510dd Signed-off-by: Sanath Kumar Gampa Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3164153 Tested-by: mobile promotions Reviewed-by: mobile promotions --- .../net/ethernet/nvidia/nvethernet/sysfs.c | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c index 378b01ea..50b9777a 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c +++ b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c @@ -346,7 +346,7 @@ static ssize_t macsec_enable_store(struct device *dev, ret = macsec_open(macsec_pdata, OSI_NULL); } else { dev_err(pdata->dev, - "Invalid. Valid inputs are 0/tx/rx/txrx\n"); + "Invalid. Valid inputs are 0/txrx\n"); } return size; @@ -715,11 +715,6 @@ static int parse_inputs(const char *buf, byte[i] = (unsigned char)temp3[i]; } - if (mac_da_valid && !is_valid_ether_addr(mac_da)) { - pr_err("%s: Invalid mac DA\n", __func__); - goto err; - } - if (mac_sa_valid && !is_valid_ether_addr(mac_sa)) { pr_err("%s: Invalid mac SA\n", __func__); goto err; @@ -1876,6 +1871,15 @@ static ssize_t macsec_kt_store(struct device *dev, kt_config.table_config.rw = OSI_LUT_WRITE; kt_config.table_config.index = index; + for (i = 0; i < OSI_KEY_LEN_128; i++) { + sak[i] = (unsigned char)temp[i]; + } + if (key256bit == 1) { + for (i = OSI_KEY_LEN_128; i < OSI_KEY_LEN_256; i++) { + sak[i] = (unsigned char)temp[i]; + } + } + /* HKEY GENERATION */ tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (crypto_cipher_setkey(tfm, sak, OSI_KEY_LEN_128)) { @@ -1886,15 +1890,6 @@ static ssize_t macsec_kt_store(struct device *dev, crypto_cipher_encrypt_one(tfm, hkey, zeros); crypto_free_cipher(tfm); - for (i = 0; i < OSI_KEY_LEN_128; i++) { - sak[i] = (unsigned char)temp[i]; - } - if (key256bit == 1) { - for (i = OSI_KEY_LEN_128; i < OSI_KEY_LEN_256; i++) { - sak[i] = (unsigned char)temp[i]; - } - } - for (i = 0; i < OSI_KEY_LEN_128; i++) { kt_config.entry.h[i] = hkey[OSI_KEY_LEN_128 - 1 - i]; }