* [PATCH net] net: macsec: Fix offload support for NETDEV_UNREGISTER event
@ 2022-01-30 11:29 Raed Salem
2022-01-31 8:44 ` Antoine Tenart
2022-02-01 5:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Raed Salem @ 2022-01-30 11:29 UTC (permalink / raw)
To: atenart, kuba; +Cc: davem, netdev, linux-kernel, Lior Nahmanson, Raed Salem
From: Lior Nahmanson <liorna@nvidia.com>
Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
releasing relevant SW resources only, this causes resources leak in case
of macsec HW offload, as the underlay driver was not notified to clean
it's macsec offload resources.
Fix by calling the underlay driver to clean it's relevant resources
by moving offload handling from macsec_dellink() to macsec_common_dellink()
when handling NETDEV_UNREGISTER event.
Fixes: 3cf3227a21d1 ("net: macsec: hardware offloading infrastructure")
Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Raed Salem <raeds@nvidia.com>
---
drivers/net/macsec.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 16aa3a4..33ff33c 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct net_device *dev, struct list_head *head
struct macsec_dev *macsec = macsec_priv(dev);
struct net_device *real_dev = macsec->real_dev;
+ /* If h/w offloading is available, propagate to the device */
+ if (macsec_is_offloaded(macsec)) {
+ const struct macsec_ops *ops;
+ struct macsec_context ctx;
+
+ ops = macsec_get_ops(netdev_priv(dev), &ctx);
+ if (ops) {
+ ctx.secy = &macsec->secy;
+ macsec_offload(ops->mdo_del_secy, &ctx);
+ }
+ }
+
unregister_netdevice_queue(dev, head);
list_del_rcu(&macsec->secys);
macsec_del_dev(macsec);
@@ -3884,18 +3896,6 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
struct net_device *real_dev = macsec->real_dev;
struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);
- /* If h/w offloading is available, propagate to the device */
- if (macsec_is_offloaded(macsec)) {
- const struct macsec_ops *ops;
- struct macsec_context ctx;
-
- ops = macsec_get_ops(netdev_priv(dev), &ctx);
- if (ops) {
- ctx.secy = &macsec->secy;
- macsec_offload(ops->mdo_del_secy, &ctx);
- }
- }
-
macsec_common_dellink(dev, head);
if (list_empty(&rxd->secys)) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: macsec: Fix offload support for NETDEV_UNREGISTER event
2022-01-30 11:29 [PATCH net] net: macsec: Fix offload support for NETDEV_UNREGISTER event Raed Salem
@ 2022-01-31 8:44 ` Antoine Tenart
2022-02-01 5:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Antoine Tenart @ 2022-01-31 8:44 UTC (permalink / raw)
To: Raed Salem, kuba; +Cc: davem, netdev, linux-kernel, Lior Nahmanson, Raed Salem
Quoting Raed Salem (2022-01-30 12:29:01)
> From: Lior Nahmanson <liorna@nvidia.com>
>
> Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
> releasing relevant SW resources only, this causes resources leak in case
> of macsec HW offload, as the underlay driver was not notified to clean
> it's macsec offload resources.
>
> Fix by calling the underlay driver to clean it's relevant resources
> by moving offload handling from macsec_dellink() to macsec_common_dellink()
> when handling NETDEV_UNREGISTER event.
>
> Fixes: 3cf3227a21d1 ("net: macsec: hardware offloading infrastructure")
> Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
> Reviewed-by: Raed Salem <raeds@nvidia.com>
> Signed-off-by: Raed Salem <raeds@nvidia.com>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Thanks!
Antoine
> ---
> drivers/net/macsec.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index 16aa3a4..33ff33c 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct net_device *dev, struct list_head *head
> struct macsec_dev *macsec = macsec_priv(dev);
> struct net_device *real_dev = macsec->real_dev;
>
> + /* If h/w offloading is available, propagate to the device */
> + if (macsec_is_offloaded(macsec)) {
> + const struct macsec_ops *ops;
> + struct macsec_context ctx;
> +
> + ops = macsec_get_ops(netdev_priv(dev), &ctx);
> + if (ops) {
> + ctx.secy = &macsec->secy;
> + macsec_offload(ops->mdo_del_secy, &ctx);
> + }
> + }
> +
> unregister_netdevice_queue(dev, head);
> list_del_rcu(&macsec->secys);
> macsec_del_dev(macsec);
> @@ -3884,18 +3896,6 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
> struct net_device *real_dev = macsec->real_dev;
> struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);
>
> - /* If h/w offloading is available, propagate to the device */
> - if (macsec_is_offloaded(macsec)) {
> - const struct macsec_ops *ops;
> - struct macsec_context ctx;
> -
> - ops = macsec_get_ops(netdev_priv(dev), &ctx);
> - if (ops) {
> - ctx.secy = &macsec->secy;
> - macsec_offload(ops->mdo_del_secy, &ctx);
> - }
> - }
> -
> macsec_common_dellink(dev, head);
>
> if (list_empty(&rxd->secys)) {
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: macsec: Fix offload support for NETDEV_UNREGISTER event
2022-01-30 11:29 [PATCH net] net: macsec: Fix offload support for NETDEV_UNREGISTER event Raed Salem
2022-01-31 8:44 ` Antoine Tenart
@ 2022-02-01 5:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-01 5:40 UTC (permalink / raw)
To: Raed Salem; +Cc: atenart, kuba, davem, netdev, linux-kernel, liorna
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 30 Jan 2022 13:29:01 +0200 you wrote:
> From: Lior Nahmanson <liorna@nvidia.com>
>
> Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
> releasing relevant SW resources only, this causes resources leak in case
> of macsec HW offload, as the underlay driver was not notified to clean
> it's macsec offload resources.
>
> [...]
Here is the summary with links:
- [net] net: macsec: Fix offload support for NETDEV_UNREGISTER event
https://git.kernel.org/netdev/net/c/9cef24c8b76c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-01 5:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-30 11:29 [PATCH net] net: macsec: Fix offload support for NETDEV_UNREGISTER event Raed Salem
2022-01-31 8:44 ` Antoine Tenart
2022-02-01 5:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox