macsec: fix secy->n_rx_sc accounting
authorSabrina Dubroca <sd@queasysnail.net>
Wed, 2 Nov 2022 21:33:14 +0000 (22:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Nov 2022 08:58:16 +0000 (09:58 +0100)
commit3070a880eb030f1a8de9008afe1e7a3cdb40ea55
tree8fff7b18d878a9c91714c65f3eeb1a9599274934
parente957555a36946552c7cb79fbd27aefec179d189a
macsec: fix secy->n_rx_sc accounting

[ Upstream commit 73a4b31c9d11f98ae3bc5286d5382930adb0e9c7 ]

secy->n_rx_sc is supposed to be the number of _active_ rxsc's within a
secy. This is then used by macsec_send_sci to help decide if we should
add the SCI to the header or not.

This logic is currently broken when we create a new RXSC and turn it
off at creation, as create_rx_sc always sets ->active to true (and
immediately uses that to increment n_rx_sc), and only later
macsec_add_rxsc sets rx_sc->active.

Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/macsec.c