Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp787418rwb; Thu, 8 Dec 2022 03:01:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf6pvPNJHZt8DXPC3XmfzsLxLwsbMCydQJYdRRQUNTxRxVF0nOu6CY6+nvAamo2ZOK9sW7Sd X-Received: by 2002:aa7:d314:0:b0:46c:fc3f:cf8a with SMTP id p20-20020aa7d314000000b0046cfc3fcf8amr10231170edq.386.1670497310077; Thu, 08 Dec 2022 03:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670497310; cv=none; d=google.com; s=arc-20160816; b=MPUbSkms3a3YsKCOAFSBJJHpgDu9LLx8w64JIo/il5HO+rqfyBtjThMnNFn11YlUC1 lyvKXcS3OkX2wCE1VQTephSCTYihIkk7CoTLSnnGwu8P6xTl+dwprcF2yRlGnV8eM9Kx 4aAb1xblS2qWfi3KJ1cKThBTSlfLUKX/Pbx6RkIpNBsyWbd0XmMf/xz7km1N4DdLkOMe ZS/0DwA+EFjtGwsRYD9+onQvlrdlmXGdYO5pZsM19ym3B4SlAvmPQBU2VelgtAcuuH/p qk1BUhPj0bH/gexYRe/fsXM5jx/xFXAosilq7mlPsTpj3u47E38w2ovmgKRJUW5OE/XW GJkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=4Tj3g+Q/kQBA09ctddFo9Wj3f59QxOp25QY6yAEgkM4=; b=p52oiBeT7B37a+MiIxF+IP62tEiOUXUwCYrov7qTobvxBUEpfuwew+pUE9uwP4nzz9 USplFI8mwTauC0WzhgE98+SdSDUoCVjVMqDLuIJLC6SPxdU95ZTkIZ+h3TZToNXAPwdF 1dzInxinQE7MVwp+LfuREIZlSTxV6S9m0ucLqegM/+we8tH3m5Lj4Z/l1wwJqzhIn8oz fNg1AsY+i/A9FhCGmnc9VwBsvsVFyquqkvcn7rxzvT0OM5ETtl6fgGvlXP2j1tKluhud RCPiJTMhn6uXgGzo7ZAMLFIYtEG1EU77yahHYHli6k56gKBKBztD898p5rJK90frowSr UQfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji16-20020a170907981000b007c08ec95eafsi21773171ejc.572.2022.12.08.03.01.32; Thu, 08 Dec 2022 03:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbiLHKm4 (ORCPT + 72 others); Thu, 8 Dec 2022 05:42:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbiLHKm0 (ORCPT ); Thu, 8 Dec 2022 05:42:26 -0500 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9667E880F7 for ; Thu, 8 Dec 2022 02:39:03 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-x9BSR9g2NXiugIB-TXS_rg-1; Thu, 08 Dec 2022 05:38:56 -0500 X-MC-Unique: x9BSR9g2NXiugIB-TXS_rg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AF52805AC5; Thu, 8 Dec 2022 10:38:56 +0000 (UTC) Received: from hog (unknown [10.39.192.162]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3439640C2065; Thu, 8 Dec 2022 10:38:52 +0000 (UTC) Date: Thu, 8 Dec 2022 11:37:49 +0100 From: Sabrina Dubroca To: Emeel Hakim Cc: "linux-kernel@vger.kernel.org" , Raed Salem , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "netdev@vger.kernel.org" , "atenart@kernel.org" , "jiri@resnulli.us" Subject: Re: [PATCH net-next v3 1/2] macsec: add support for IFLA_MACSEC_OFFLOAD in macsec_changelink Message-ID: References: <20221207101017.533-1-ehakim@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 2022-12-08, 06:53:18 +0000, Emeel Hakim wrote: > > > > -----Original Message----- > > From: Sabrina Dubroca > > Sent: Thursday, 8 December 2022 0:04 > > To: Emeel Hakim > > Cc: linux-kernel@vger.kernel.org; Raed Salem ; > > davem@davemloft.net; edumazet@google.com; kuba@kernel.org; > > pabeni@redhat.com; netdev@vger.kernel.org; atenart@kernel.org; jiri@resnulli.us > > Subject: Re: [PATCH net-next v3 1/2] macsec: add support for > > IFLA_MACSEC_OFFLOAD in macsec_changelink > > > > External email: Use caution opening links or attachments > > > > > > 2022-12-07, 15:52:15 +0000, Emeel Hakim wrote: > > > > > > > > > > -----Original Message----- > > > > From: Sabrina Dubroca > > > > Sent: Wednesday, 7 December 2022 17:46 > > > > To: Emeel Hakim > > > > Cc: linux-kernel@vger.kernel.org; Raed Salem ; > > > > davem@davemloft.net; edumazet@google.com; kuba@kernel.org; > > > > pabeni@redhat.com; netdev@vger.kernel.org; atenart@kernel.org; > > > > jiri@resnulli.us > > > > Subject: Re: [PATCH net-next v3 1/2] macsec: add support for > > > > IFLA_MACSEC_OFFLOAD in macsec_changelink > > > > > > > > External email: Use caution opening links or attachments > > > > > > > > > > > > 2022-12-07, 12:10:16 +0200, ehakim@nvidia.com wrote: > > > > [...] > > > > > +static int macsec_changelink_upd_offload(struct net_device *dev, > > > > > +struct nlattr *data[]) { > > > > > + enum macsec_offload offload; > > > > > + struct macsec_dev *macsec; > > > > > + > > > > > + macsec = macsec_priv(dev); > > > > > + offload = nla_get_u8(data[IFLA_MACSEC_OFFLOAD]); > > > > > > > > All those checks are also present in macsec_upd_offload, why not > > > > move them into macsec_update_offload as well? (and then you don't > > > > really need macsec_changelink_upd_offload anymore) > > > > > > > > > > Right, I thought about it , but I realized that those checks are done > > > before holding the lock in macsec_upd_offload and if I move them to > > > macsec_update_offload I will hold the lock for a longer time , I want to minimize > > the time of holding the lock. > > > > Those couple of tests are probably lost in the noise compared to what > > mdo_add_secy ends up doing. It also looks like a race condition between the > > "macsec->offload == offload" test in macsec_upd_offload (outside rtnl_lock) and > > updating macsec->offload via macsec_changelink is possible. (Currently we can > > only change it with macsec_upd_offload (called under genl_lock) so there's no issue > > until we add this patch) > > Ack, > so getting rid of macsec_changelink_upd_offload and moving the locking inside macsec_update_offload > should handle this issue You mean moving rtnl_lock()/unlock inside macsec_update_offload? changelink is already under rtnl_lock. Just move the checks that you currently have in macsec_changelink_upd_offload into macsec_update_offload, and remove them from macsec_upd_offload. > > > > > > > + if (macsec->offload == offload) > > > > > + return 0; > > > > > + > > > > > + /* 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; > > > > > + > > > > > + return macsec_update_offload(macsec, offload); } > > > > > + > > > > > > > > -- > > > > Sabrina > > > > > > > -- > > Sabrina > -- Sabrina