netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emeel Hakim <ehakim@nvidia.com>
To: Antoine Tenart <atenart@kernel.org>,
	Sabrina Dubroca <sd@queasysnail.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Raed Salem <raeds@nvidia.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>
Subject: RE: [PATCH net-next v7 1/2] macsec: add support for IFLA_MACSEC_OFFLOAD in macsec_changelink
Date: Tue, 10 Jan 2023 09:05:36 +0000	[thread overview]
Message-ID: <IA1PR12MB6353C7C5FA91CAB18B267444ABFF9@IA1PR12MB6353.namprd12.prod.outlook.com> (raw)
In-Reply-To: <167334021775.17820.2386827809582589477@kwain.local>



> -----Original Message-----
> From: Antoine Tenart <atenart@kernel.org>
> Sent: Tuesday, 10 January 2023 10:44
> To: Sabrina Dubroca <sd@queasysnail.net>; Emeel Hakim <ehakim@nvidia.com>
> Cc: netdev@vger.kernel.org; Raed Salem <raeds@nvidia.com>;
> davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com
> Subject: Re: [PATCH net-next v7 1/2] macsec: add support for
> IFLA_MACSEC_OFFLOAD in macsec_changelink
> 
> External email: Use caution opening links or attachments
> 
> 
> Quoting Sabrina Dubroca (2023-01-09 16:14:32)
> > 2023-01-09, 10:55:56 +0200, ehakim@nvidia.com wrote:
> > > @@ -3840,6 +3835,12 @@ static int macsec_changelink(struct net_device
> *dev, struct nlattr *tb[],
> > >       if (ret)
> > >               goto cleanup;
> > >
> > > +     if (data[IFLA_MACSEC_OFFLOAD]) {
> > > +             ret = macsec_update_offload(dev,
> nla_get_u8(data[IFLA_MACSEC_OFFLOAD]));
> > > +             if (ret)
> > > +                     goto cleanup;
> > > +     }
> > > +
> > >       /* If h/w offloading is available, propagate to the device */
> > >       if (macsec_is_offloaded(macsec)) {
> > >               const struct macsec_ops *ops;
> >
> > There's a missing rollback of the offloading status in the (probably
> > quite unlikely) case that mdo_upd_secy fails, no? We can't fail
> > macsec_get_ops because macsec_update_offload would have failed
> > already, but I guess the driver could fail in mdo_upd_secy, and then
> > "goto cleanup" doesn't restore the offloading state.  Sorry I didn't
> > notice this earlier.
> >
> > In case the IFLA_MACSEC_OFFLOAD attribute is provided and we're
> > enabling offload, we also end up calling the driver's mdo_add_secy,
> > and then immediately afterwards mdo_upd_secy, which probably doesn't
> > make much sense.
> >
> > Maybe we could turn that into:
> >
> >     if (data[IFLA_MACSEC_OFFLOAD]) {
> 
> If data[IFLA_MACSEC_OFFLOAD] is provided but doesn't change the offloading
> state, then macsec_update_offload will return early and mdo_upd_secy won't be
> called.
> 
> >         ... macsec_update_offload
> >     } else if (macsec_is_offloaded(macsec)) {
> >         /* If h/w offloading is available, propagate to the device */
> >         ... mdo_upd_secy
> >     }
> >
> > Antoine, does that look reasonable to you?
> 
> But yes I agree we can improve the logic. Maybe something like:

Ack , I can do the change

>   prev_offload = macsec->offload;
>   offload = data[IFLA_MACSEC_OFFLOAD];
> 
>   if (prev_offload != offload) {
>       macsec_update_offload(...)
>   } else if (macsec_is_offloaded(macsec)) {
>       ...
>       prev_offload can be used to restore the offloading state on
>       failure here.

why do we need to restore offloading state here in case of failure?
we get to this case when prev_offload == offload.

>   }
> 
> Thanks,
> Antoine

  reply	other threads:[~2023-01-10  9:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09  8:55 [PATCH net-next v7 0/2] Add support to offload macsec using netlink update ehakim
2023-01-09  8:55 ` [PATCH net-next v7 1/2] macsec: add support for IFLA_MACSEC_OFFLOAD in macsec_changelink ehakim
2023-01-09 15:14   ` Sabrina Dubroca
2023-01-10  8:43     ` Antoine Tenart
2023-01-10  9:05       ` Emeel Hakim [this message]
     [not found]         ` <167334656781.17820.3219445403317381657@kwain.local>
2023-01-10 11:46           ` Sabrina Dubroca
2023-01-10 10:44       ` Sabrina Dubroca
2023-01-10 13:55         ` Antoine Tenart
2023-01-10 16:16           ` Emeel Hakim
2023-01-09  8:55 ` [PATCH net-next v7 2/2] macsec: dump IFLA_MACSEC_OFFLOAD attribute as part of macsec dump ehakim

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=IA1PR12MB6353C7C5FA91CAB18B267444ABFF9@IA1PR12MB6353.namprd12.prod.outlook.com \
    --to=ehakim@nvidia.com \
    --cc=atenart@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=raeds@nvidia.com \
    --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;
as well as URLs for NNTP newsgroup(s).