Skip to content

Commit 9cef24c

Browse files
Lior Nahmansonkuba-moo
authored andcommitted
net: macsec: Fix offload support for NETDEV_UNREGISTER event
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: 3cf3227 ("net: macsec: hardware offloading infrastructure") Signed-off-by: Lior Nahmanson <[email protected]> Reviewed-by: Raed Salem <[email protected]> Signed-off-by: Raed Salem <[email protected]> Reviewed-by: Antoine Tenart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7af037c commit 9cef24c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/net/macsec.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct net_device *dev, struct list_head *head
38703870
struct macsec_dev *macsec = macsec_priv(dev);
38713871
struct net_device *real_dev = macsec->real_dev;
38723872

3873+
/* If h/w offloading is available, propagate to the device */
3874+
if (macsec_is_offloaded(macsec)) {
3875+
const struct macsec_ops *ops;
3876+
struct macsec_context ctx;
3877+
3878+
ops = macsec_get_ops(netdev_priv(dev), &ctx);
3879+
if (ops) {
3880+
ctx.secy = &macsec->secy;
3881+
macsec_offload(ops->mdo_del_secy, &ctx);
3882+
}
3883+
}
3884+
38733885
unregister_netdevice_queue(dev, head);
38743886
list_del_rcu(&macsec->secys);
38753887
macsec_del_dev(macsec);
@@ -3884,18 +3896,6 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
38843896
struct net_device *real_dev = macsec->real_dev;
38853897
struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);
38863898

3887-
/* If h/w offloading is available, propagate to the device */
3888-
if (macsec_is_offloaded(macsec)) {
3889-
const struct macsec_ops *ops;
3890-
struct macsec_context ctx;
3891-
3892-
ops = macsec_get_ops(netdev_priv(dev), &ctx);
3893-
if (ops) {
3894-
ctx.secy = &macsec->secy;
3895-
macsec_offload(ops->mdo_del_secy, &ctx);
3896-
}
3897-
}
3898-
38993899
macsec_common_dellink(dev, head);
39003900

39013901
if (list_empty(&rxd->secys)) {

0 commit comments

Comments
 (0)