From: Leon Romanovsky <leon@kernel.org>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: netdev@vger.kernel.org, Antoine Tenart <atenart@kernel.org>
Subject: Re: [PATCH net 3/5] macsec: fix secy->n_rx_sc accounting
Date: Fri, 14 Oct 2022 09:16:56 +0300 [thread overview]
Message-ID: <Y0j+2J2uBqrhqRtg@unreal> (raw)
In-Reply-To: <1879f6c8a7fcb5d7bb58ffb3d9fed26c8d7ec5cb.1665416630.git.sd@queasysnail.net>
On Thu, Oct 13, 2022 at 04:15:41PM +0200, Sabrina Dubroca wrote:
> 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>
> ---
> drivers/net/macsec.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index 0d6fe34b91ae..cdee342e42cd 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -1413,7 +1413,8 @@ static struct macsec_rx_sc *del_rx_sc(struct macsec_secy *secy, sci_t sci)
> return NULL;
> }
>
> -static struct macsec_rx_sc *create_rx_sc(struct net_device *dev, sci_t sci)
> +static struct macsec_rx_sc *create_rx_sc(struct net_device *dev, sci_t sci,
> + bool active)
> {
> struct macsec_rx_sc *rx_sc;
> struct macsec_dev *macsec;
> @@ -1437,7 +1438,7 @@ static struct macsec_rx_sc *create_rx_sc(struct net_device *dev, sci_t sci)
> }
>
> rx_sc->sci = sci;
> - rx_sc->active = true;
> + rx_sc->active = active;
> refcount_set(&rx_sc->refcnt, 1);
>
> secy = &macsec_priv(dev)->secy;
> @@ -1876,6 +1877,7 @@ static int macsec_add_rxsc(struct sk_buff *skb, struct genl_info *info)
> struct macsec_rx_sc *rx_sc;
> struct nlattr *tb_rxsc[MACSEC_RXSC_ATTR_MAX + 1];
> struct macsec_secy *secy;
> + bool active = true;
> int ret;
>
> if (!attrs[MACSEC_ATTR_IFINDEX])
> @@ -1897,15 +1899,16 @@ static int macsec_add_rxsc(struct sk_buff *skb, struct genl_info *info)
> secy = &macsec_priv(dev)->secy;
> sci = nla_get_sci(tb_rxsc[MACSEC_RXSC_ATTR_SCI]);
>
> - rx_sc = create_rx_sc(dev, sci);
> +
> + if (tb_rxsc[MACSEC_RXSC_ATTR_ACTIVE])
> + active = !!nla_get_u8(tb_rxsc[MACSEC_RXSC_ATTR_ACTIVE]);
You don't need !! to assign to bool variables and can safely omit them.
thanks
> +
> + rx_sc = create_rx_sc(dev, sci, active);
> if (IS_ERR(rx_sc)) {
> rtnl_unlock();
> return PTR_ERR(rx_sc);
> }
>
> - if (tb_rxsc[MACSEC_RXSC_ATTR_ACTIVE])
> - rx_sc->active = !!nla_get_u8(tb_rxsc[MACSEC_RXSC_ATTR_ACTIVE]);
> -
> if (macsec_is_offloaded(netdev_priv(dev))) {
> const struct macsec_ops *ops;
> struct macsec_context ctx;
> --
> 2.38.0
>
next prev parent reply other threads:[~2022-10-14 6:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 14:15 [PATCH net 0/5] macsec: offload-related fixes Sabrina Dubroca
2022-10-13 14:15 ` [PATCH net 1/5] Revert "net: macsec: report real_dev features when HW offloading is enabled" Sabrina Dubroca
2022-10-13 14:15 ` [PATCH net 2/5] macsec: delete new rxsc when offload fails Sabrina Dubroca
2022-10-13 14:15 ` [PATCH net 3/5] macsec: fix secy->n_rx_sc accounting Sabrina Dubroca
2022-10-14 6:16 ` Leon Romanovsky [this message]
2022-10-14 7:43 ` Sabrina Dubroca
2022-10-14 11:08 ` Leon Romanovsky
2022-10-13 14:15 ` [PATCH net 4/5] macsec: fix detection of RXSCs when toggling offloading Sabrina Dubroca
2022-10-13 14:15 ` [PATCH net 5/5] macsec: clear encryption keys from the stack after setting up offload Sabrina Dubroca
2022-10-14 6:13 ` [PATCH net 0/5] macsec: offload-related fixes Leon Romanovsky
2022-10-14 7:43 ` Sabrina Dubroca
2022-10-14 11:03 ` Leon Romanovsky
2022-10-14 14:03 ` Antoine Tenart
2022-10-18 6:28 ` Leon Romanovsky
2022-10-20 13:54 ` Sabrina Dubroca
2022-10-23 7:52 ` Leon Romanovsky
2022-10-24 8:24 ` Sabrina Dubroca
2022-10-24 8:43 ` Leon Romanovsky
2022-10-24 22:05 ` Sabrina Dubroca
2022-10-25 6:55 ` Leon Romanovsky
2022-10-14 14:44 ` Sabrina Dubroca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y0j+2J2uBqrhqRtg@unreal \
--to=leon@kernel.org \
--cc=atenart@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox