lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <167023407010.4545.3574025885845288724@kwain.local>
Date:   Mon, 05 Dec 2022 10:54:30 +0100
From:   Antoine Tenart <atenart@...nel.org>
To:     ehakim@...dia.com, linux-kernel@...r.kernel.org
Cc:     raeds@...dia.com, davem@...emloft.net, edumazet@...gle.com,
        kuba@...nel.org, pabeni@...hat.com, netdev@...r.kernel.org,
        sd@...asysnail.net, Emeel Hakim <ehakim@...dia.com>
Subject: Re: [PATCH net-next] macsec: Add support for IFLA_MACSEC_OFFLOAD in the netlink layer

Hello,

Quoting ehakim@...dia.com (2022-12-04 11:06:53)
>  
> +static int macsec_changelink_upd_offload(struct net_device *dev, struct nlattr *data[])
> +{
> +       enum macsec_offload offload, prev_offload;
> +       const struct macsec_ops *ops;
> +       struct macsec_context ctx;
> +       struct macsec_dev *macsec;
> +       int ret = 0;
> +
> +       macsec = macsec_priv(dev);
> +       offload = nla_get_u8(data[IFLA_MACSEC_OFFLOAD]);
> +
> +       /* Check if the offloading mode is supported by the underlying layers */
> +       if (offload != MACSEC_OFFLOAD_OFF &&
> +           !macsec_check_offload(offload, macsec))
> +               return -EOPNOTSUPP;
> +
> +       /* Check if the net device is busy. */
> +       if (netif_running(dev))
> +               return -EBUSY;
> +
> +       if (macsec->offload == offload)
> +               return 0;
> +
> +       prev_offload = macsec->offload;
> +
> +       /* Check if the device already has rules configured: we do not support
> +        * rules migration.
> +        */
> +       if (macsec_is_configured(macsec))
> +               return -EBUSY;
> +
> +       ops = __macsec_get_ops(offload == MACSEC_OFFLOAD_OFF ? prev_offload : offload,
> +                              macsec, &ctx);
> +       if (!ops)
> +               return -EOPNOTSUPP;
> +
> +       macsec->offload = offload;
> +
> +       ctx.secy = &macsec->secy;
> +       ret = (offload == MACSEC_OFFLOAD_OFF) ? macsec_offload(ops->mdo_del_secy, &ctx) :
> +                     macsec_offload(ops->mdo_add_secy, &ctx);
> +
> +       if (ret)
> +               macsec->offload = prev_offload;
> +
> +       return ret;
> +}

The logic above is very close to what is done in macsec_upd_offload,
except for the use of the rtnl lock. You can merge the two in a common
helper and use that to avoid duplication.

Thanks,
Antoine

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ