blob: b3e59302cb1ef14664f7abb0d271bc742e821a7b [file] [log] [blame]
developer7e32f7e2022-05-18 21:10:08 +08001From 9cef24c8b76c1f6effe499d2f131807c90f7ce9a Mon Sep 17 00:00:00 2001
2From: Lior Nahmanson <liorna@nvidia.com>
3Date: Sun, 30 Jan 2022 13:29:01 +0200
4Subject: net: macsec: Fix offload support for NETDEV_UNREGISTER event
5
6Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
7releasing relevant SW resources only, this causes resources leak in case
8of macsec HW offload, as the underlay driver was not notified to clean
9it's macsec offload resources.
10
11Fix by calling the underlay driver to clean it's relevant resources
12by moving offload handling from macsec_dellink() to macsec_common_dellink()
13when handling NETDEV_UNREGISTER event.
14
15Fixes: 3cf3227a21d1 ("net: macsec: hardware offloading infrastructure")
16Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
17Reviewed-by: Raed Salem <raeds@nvidia.com>
18Signed-off-by: Raed Salem <raeds@nvidia.com>
19Reviewed-by: Antoine Tenart <atenart@kernel.org>
20Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvidia.com
21Signed-off-by: Jakub Kicinski <kuba@kernel.org>
22---
23 drivers/net/macsec.c | 24 ++++++++++++------------
24 1 file changed, 12 insertions(+), 12 deletions(-)
25
26diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
27index 16aa3a478e9e8..33ff33c05aabc 100644
28--- a/drivers/net/macsec.c
29+++ b/drivers/net/macsec.c
30@@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct net_device *dev, struct list_head *head
31 struct macsec_dev *macsec = macsec_priv(dev);
32 struct net_device *real_dev = macsec->real_dev;
33
34+ /* If h/w offloading is available, propagate to the device */
35+ if (macsec_is_offloaded(macsec)) {
36+ const struct macsec_ops *ops;
37+ struct macsec_context ctx;
38+
39+ ops = macsec_get_ops(netdev_priv(dev), &ctx);
40+ if (ops) {
41+ ctx.secy = &macsec->secy;
42+ macsec_offload(ops->mdo_del_secy, &ctx);
43+ }
44+ }
45+
46 unregister_netdevice_queue(dev, head);
47 list_del_rcu(&macsec->secys);
48 macsec_del_dev(macsec);
49@@ -3884,18 +3896,6 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
50 struct net_device *real_dev = macsec->real_dev;
51 struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);
52
53- /* If h/w offloading is available, propagate to the device */
54- if (macsec_is_offloaded(macsec)) {
55- const struct macsec_ops *ops;
56- struct macsec_context ctx;
57-
58- ops = macsec_get_ops(netdev_priv(dev), &ctx);
59- if (ops) {
60- ctx.secy = &macsec->secy;
61- macsec_offload(ops->mdo_del_secy, &ctx);
62- }
63- }
64-
65 macsec_common_dellink(dev, head);
66
67 if (list_empty(&rxd->secys)) {
68--
69cgit 1.2.3-1.el7
70