Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1677317pxb; Wed, 9 Feb 2022 01:57:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwuMcEcRaMkIOYG/GEwySZCNAu2AkhHKbfLKK3GKNrpW/NNTbxI6W3g8AHEGNCr94mH8f5n X-Received: by 2002:a17:90a:b795:: with SMTP id m21mr1660726pjr.57.1644400656585; Wed, 09 Feb 2022 01:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400656; cv=none; d=google.com; s=arc-20160816; b=nKeeR3/G10qwCB9SITP6fRoetn9Kt/Bcb7UFNXGJ6BZaghMtmoS6c3mzPbZhICp+s3 IsFrAKGJ0yUxuVdFkBoIHJO0x+X0Qj00VjLSdUXBgLEyQyGhwuUPbZi/5vaPAYRUGCe0 TeXk4akmmChXfXM7Sd4gxBr6OITBVRrZtHhWxnaWM1NtdLBMeq4AZ6jNMcsu5WsKV6XZ EE8cjSCGewc9LBdN/G4fESDfA9DhSllOT8iMsG5raQBMpJHmifaMK1MNmWFmN3y631Dv faiwXhp0UEldwwENgfsmZFVXm7bq9suiv08qaQyCBvKv5JPl9XCAerxOr/P0z5m58l3+ Q8xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KjkMkK9l1be57aCsn3h1cBolGBgIx7PS0dtF8I3FC6I=; b=BImTBWccVdFvEl+3u5MvvL+kvrlF7UV9H0CCRovP7ol5uW160yNfsQ3gBaN9M1YhUL XCfWArh2HQg9jGI5+2Wi3t2J3ZdNqIXb3RyFuH/AN4g9OiNyVrZwyXniDKPhBhaSxo2l syKVxUvgcpoY0gri6ICHrU92/7nXr+QziaxOxkpLVY2267jM/0lJUd/73MLT2I2m+05j N3bJXfiAgnjlyqi25kY59oRF03QJtwf91DX4o+adwB7Lkh4jGzJuZmYZ5IOiSd9D/SaN 1DbOiaQB5Xgq220fj+jCWMl9IrVQdbWM5UVcQity6pDPcDxHrQzyitD9Lcr1yBYyaREl lqRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1e9wP5hQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si4288131pfh.109.2022.02.09.01.57.18; Wed, 09 Feb 2022 01:57:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1e9wP5hQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389112AbiBGLqJ (ORCPT + 99 others); Mon, 7 Feb 2022 06:46:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386194AbiBGLdz (ORCPT ); Mon, 7 Feb 2022 06:33:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02AA9C043181; Mon, 7 Feb 2022 03:33:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B36C1B811BD; Mon, 7 Feb 2022 11:33:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D765BC004E1; Mon, 7 Feb 2022 11:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233631; bh=a/ZBpKbDDQqi+MpGt1DElsti8XZTAvY6yZ+reuerCY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1e9wP5hQXHZbKyQJuQARp7gBbJ9zkcCDm4iFfSTODniHj6bwn4kllJFstheV/8nYQ rk+dnp8wBpOyJ8pvaPqLKKIZda2/K9Qj9vsOXJotdroEa5TcgFOy93V7hH9qehpO5r PK9zUZ7AsZCRrcWRGE9DxmQ6uvMka2mXBNaWcg4U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lior Nahmanson , Raed Salem , Antoine Tenart , Jakub Kicinski Subject: [PATCH 5.16 073/126] net: macsec: Fix offload support for NETDEV_UNREGISTER event Date: Mon, 7 Feb 2022 12:06:44 +0100 Message-Id: <20220207103806.631360833@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lior Nahmanson commit 9cef24c8b76c1f6effe499d2f131807c90f7ce9a upstream. 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 Reviewed-by: Raed Salem Signed-off-by: Raed Salem Reviewed-by: Antoine Tenart Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/macsec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct 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_de 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)) {