Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1076558rwb; Wed, 7 Dec 2022 08:20:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5u0eokwwQBxzbtUOZXsKAL4JX7w9AdGhJ/hLHP05IrL/n2OMO4bTIQ+90qNnz/A1dNhz6W X-Received: by 2002:a17:903:26d1:b0:189:c429:f61c with SMTP id jg17-20020a17090326d100b00189c429f61cmr21886872plb.63.1670430038922; Wed, 07 Dec 2022 08:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670430038; cv=none; d=google.com; s=arc-20160816; b=e6Pfioauvl7PouSb9eF5zhesTXd4aFYC7QPng6aWd80COI0iFIg8iGXS5YxxshF9TG MdqsP+piEwS68m4YsRVfEpxV0btybIXtF44mtkEO6pJjrnzMpe5qNl1ePWKAb8+4Yu+2 XiB2d1+dAlktM2e+/KROThBuhvKpakFQ2oAQjPfpgK0kBs/nTlkTo2UtJP0+XW2rBZoK OMztzyu1qMzmxKKLG5EI+hygSOXeh/6Iy0hpaOfmYG9jJQrU1LsascwMssNd7T/enxl4 i1v4j6/zUowpAqriUdqounxDOa+ULcn30b/OPb08k7DZLugwY3HVeFdwbOtb9RAWCYgO gs+Q== 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=DicKZSgecVXJHV+Lit3VE5BcCi9KjDiIKPM3MDsR7u8=; b=yh/sm1AQXkqdVgEic8ed+EA6uPjQj9tl/Ic+eJPcMKBkzQMZFTdyW0HsRUiHGVroY0 +iBfMzRs+rjQyU/Fe1X5/eoeky0aQsfqfBWkwB4UsEiaEFkIsnL/g19K9OG4uWZJNRa1 r90x0nPHKqkY666a6wEHxpANFEfkL33fZVlH0FGofYPNe+lUVttfkKYKEgVFK1XZGVAr RRJoTkpsBjd6/z9oXVjwYHyzIB7KvLOgdFnDScPhRaLaaCk8TvPpe/9ec76D7t3dhcTe /6VJ0JXIaZ1oVOrif4LmoNWRv5TkaEDwThsmepIQRmKyNdQNmlDfGRh0b0JZE8YAGNSF GMPQ== 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 t2-20020a634442000000b00461f124bc4csi19993137pgk.86.2022.12.07.08.20.26; Wed, 07 Dec 2022 08:20:38 -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 S229787AbiLGPrB (ORCPT + 76 others); Wed, 7 Dec 2022 10:47:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbiLGPq6 (ORCPT ); Wed, 7 Dec 2022 10:46:58 -0500 X-Greylist: delayed 84899 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 07 Dec 2022 07:46:57 PST Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5A6727CF2 for ; Wed, 7 Dec 2022 07:46:57 -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-35-0aD-SJymO32BngtIO0bklA-1; Wed, 07 Dec 2022 10:46:39 -0500 X-MC-Unique: 0aD-SJymO32BngtIO0bklA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D760858F13; Wed, 7 Dec 2022 15:46:39 +0000 (UTC) Received: from hog (unknown [10.39.192.162]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 424B3141510A; Wed, 7 Dec 2022 15:46:37 +0000 (UTC) Date: Wed, 7 Dec 2022 16:45:34 +0100 From: Sabrina Dubroca To: ehakim@nvidia.com Cc: linux-kernel@vger.kernel.org, raeds@nvidia.com, 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: <20221207101017.533-1-ehakim@nvidia.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_RPBL,RDNS_NONE,SPF_HELO_NONE,SPF_NONE autolearn=no 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-07, 12:10:16 +0200, ehakim@nvidia.com wrote: > From: Emeel Hakim > > Add support for changing Macsec offload selection through the > netlink layer by implementing the relevant changes in > macsec_change link. nit: macsec_changelink [...] > +static int macsec_update_offload(struct macsec_dev *macsec, enum macsec_offload offload) > +{ > + enum macsec_offload prev_offload; > + const struct macsec_ops *ops; > + struct macsec_context ctx; > + int ret = 0; > + > + prev_offload = macsec->offload; > + > + /* Check if the device already has rules configured: we do not support > + * rules migration. > + */ > + if (macsec_is_configured(macsec)) > + return -EBUSY; > + > + ops = __macsec_get_ops(offload == MACSEC_OFFLOAD_OFF ? prev_offload : offload, > + macsec, &ctx); > + if (!ops) > + return -EOPNOTSUPP; > + > + macsec->offload = offload; > + > + ctx.secy = &macsec->secy; > + ret = (offload == MACSEC_OFFLOAD_OFF) ? macsec_offload(ops->mdo_del_secy, &ctx) : > + macsec_offload(ops->mdo_add_secy, &ctx); I think aligning the two macsec_offload(...) calls would make this a bit easier to read: ret = offload == MACSEC_OFFLOAD_OFF ? macsec_offload(ops->mdo_del_secy, &ctx) : macsec_offload(ops->mdo_add_secy, &ctx); (and remove the unnecessary ()) > + > + if (ret) > + macsec->offload = prev_offload; > + > + return ret; > +} > + [...] > +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) > + 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