Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

octeontx2-pf: mcs: update PN only when update_pn is true

When updating SA, update the PN only when the update_pn flag is true.
Otherwise, the PN will be reset to its previous value using the
following command and this should not happen:
$ ip macsec set macsec0 tx sa 0 on

Fixes: c54ffc73601c ("octeontx2-pf: mcs: Introduce MACSEC hardware offloading")
Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Radu Pirea (NXP OSS) and committed by
Paolo Abeni
4dcf38ae 0412cc84

+9 -4
+9 -4
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
··· 1357 1357 1358 1358 if (netif_running(secy->netdev)) { 1359 1359 /* Keys cannot be changed after creation */ 1360 - err = cn10k_write_tx_sa_pn(pfvf, txsc, sa_num, 1361 - sw_tx_sa->next_pn); 1362 - if (err) 1363 - return err; 1360 + if (ctx->sa.update_pn) { 1361 + err = cn10k_write_tx_sa_pn(pfvf, txsc, sa_num, 1362 + sw_tx_sa->next_pn); 1363 + if (err) 1364 + return err; 1365 + } 1364 1366 1365 1367 err = cn10k_mcs_link_tx_sa2sc(pfvf, secy, txsc, 1366 1368 sa_num, sw_tx_sa->active); ··· 1530 1528 err = cn10k_mcs_write_rx_sa_plcy(pfvf, secy, rxsc, sa_num, sa_in_use); 1531 1529 if (err) 1532 1530 return err; 1531 + 1532 + if (!ctx->sa.update_pn) 1533 + return 0; 1533 1534 1534 1535 err = cn10k_mcs_write_rx_sa_pn(pfvf, rxsc, sa_num, 1535 1536 rx_sa->next_pn);