From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB30C43381 for ; Wed, 6 Mar 2019 18:24:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D48C205F4 for ; Wed, 6 Mar 2019 18:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726660AbfCFSYw (ORCPT ); Wed, 6 Mar 2019 13:24:52 -0500 Received: from charlotte.tuxdriver.com ([70.61.120.58]:49373 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfCFSYw (ORCPT ); Wed, 6 Mar 2019 13:24:52 -0500 Received: from [216.85.170.145] (helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1h1bDj-00036T-08; Wed, 06 Mar 2019 13:24:49 -0500 Date: Wed, 6 Mar 2019 13:24:41 -0500 From: Neil Horman To: Xin Long Cc: network dev , linux-sctp@vger.kernel.org, davem@davemloft.net, Marcelo Ricardo Leitner Subject: Re: [PATCH net 2/3] sctp: move up sctp_auth_init_hmacs() in sctp_endpoint_init() Message-ID: <20190306182441.GC10683@neilslaptop.think-freely.org> References: <408620556c373e59442bf68f97cba3a03ac3267a.1551606805.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <408620556c373e59442bf68f97cba3a03ac3267a.1551606805.git.lucien.xin@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sun, Mar 03, 2019 at 05:54:54PM +0800, Xin Long wrote: > sctp_auth_init_hmacs() is called only when ep->auth_enable is set. > It better to move up sctp_auth_init_hmacs() and remove auth_enable > check in it and check auth_enable only once in sctp_endpoint_init(). > > Signed-off-by: Xin Long > --- > net/sctp/auth.c | 6 ------ > net/sctp/endpointola.c | 18 ++++++++++-------- > 2 files changed, 10 insertions(+), 14 deletions(-) > > diff --git a/net/sctp/auth.c b/net/sctp/auth.c > index 5b53761..39d72e5 100644 > --- a/net/sctp/auth.c > +++ b/net/sctp/auth.c > @@ -471,12 +471,6 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) > struct crypto_shash *tfm = NULL; > __u16 id; > > - /* If AUTH extension is disabled, we are done */ > - if (!ep->auth_enable) { > - ep->auth_hmacs = NULL; > - return 0; > - } > - > /* If the transforms are already allocated, we are done */ > if (ep->auth_hmacs) > return 0; > diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c > index 40c7eb9..0448b68 100644 > --- a/net/sctp/endpointola.c > +++ b/net/sctp/endpointola.c > @@ -107,6 +107,13 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, > auth_chunks->param_hdr.length = > htons(sizeof(struct sctp_paramhdr) + 2); > } > + > + /* Allocate and initialize transorms arrays for supported > + * HMACs. > + */ > + err = sctp_auth_init_hmacs(ep, gfp); > + if (err) > + goto nomem; > } > > /* Initialize the base structure. */ > @@ -150,15 +157,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, > INIT_LIST_HEAD(&ep->endpoint_shared_keys); > null_key = sctp_auth_shkey_create(0, gfp); > if (!null_key) > - goto nomem; > + goto nomem_shkey; > > list_add(&null_key->key_list, &ep->endpoint_shared_keys); > > - /* Allocate and initialize transorms arrays for supported HMACs. */ > - err = sctp_auth_init_hmacs(ep, gfp); > - if (err) > - goto nomem_hmacs; > - > /* Add the null key to the endpoint shared keys list and > * set the hmcas and chunks pointers. > */ > @@ -169,8 +171,8 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, > > return ep; > > -nomem_hmacs: > - sctp_auth_destroy_keys(&ep->endpoint_shared_keys); > +nomem_shkey: > + sctp_auth_destroy_hmacs(ep->auth_hmacs); > nomem: > /* Free all allocations */ > kfree(auth_hmacs); > -- > 2.1.0 > > Acked-by: Neil Horman From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Horman Date: Wed, 06 Mar 2019 18:24:41 +0000 Subject: Re: [PATCH net 2/3] sctp: move up sctp_auth_init_hmacs() in sctp_endpoint_init() Message-Id: <20190306182441.GC10683@neilslaptop.think-freely.org> List-Id: References: <408620556c373e59442bf68f97cba3a03ac3267a.1551606805.git.lucien.xin@gmail.com> In-Reply-To: <408620556c373e59442bf68f97cba3a03ac3267a.1551606805.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Xin Long Cc: network dev , linux-sctp@vger.kernel.org, davem@davemloft.net, Marcelo Ricardo Leitner On Sun, Mar 03, 2019 at 05:54:54PM +0800, Xin Long wrote: > sctp_auth_init_hmacs() is called only when ep->auth_enable is set. > It better to move up sctp_auth_init_hmacs() and remove auth_enable > check in it and check auth_enable only once in sctp_endpoint_init(). > > Signed-off-by: Xin Long > --- > net/sctp/auth.c | 6 ------ > net/sctp/endpointola.c | 18 ++++++++++-------- > 2 files changed, 10 insertions(+), 14 deletions(-) > > diff --git a/net/sctp/auth.c b/net/sctp/auth.c > index 5b53761..39d72e5 100644 > --- a/net/sctp/auth.c > +++ b/net/sctp/auth.c > @@ -471,12 +471,6 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) > struct crypto_shash *tfm = NULL; > __u16 id; > > - /* If AUTH extension is disabled, we are done */ > - if (!ep->auth_enable) { > - ep->auth_hmacs = NULL; > - return 0; > - } > - > /* If the transforms are already allocated, we are done */ > if (ep->auth_hmacs) > return 0; > diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c > index 40c7eb9..0448b68 100644 > --- a/net/sctp/endpointola.c > +++ b/net/sctp/endpointola.c > @@ -107,6 +107,13 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, > auth_chunks->param_hdr.length > htons(sizeof(struct sctp_paramhdr) + 2); > } > + > + /* Allocate and initialize transorms arrays for supported > + * HMACs. > + */ > + err = sctp_auth_init_hmacs(ep, gfp); > + if (err) > + goto nomem; > } > > /* Initialize the base structure. */ > @@ -150,15 +157,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, > INIT_LIST_HEAD(&ep->endpoint_shared_keys); > null_key = sctp_auth_shkey_create(0, gfp); > if (!null_key) > - goto nomem; > + goto nomem_shkey; > > list_add(&null_key->key_list, &ep->endpoint_shared_keys); > > - /* Allocate and initialize transorms arrays for supported HMACs. */ > - err = sctp_auth_init_hmacs(ep, gfp); > - if (err) > - goto nomem_hmacs; > - > /* Add the null key to the endpoint shared keys list and > * set the hmcas and chunks pointers. > */ > @@ -169,8 +171,8 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, > > return ep; > > -nomem_hmacs: > - sctp_auth_destroy_keys(&ep->endpoint_shared_keys); > +nomem_shkey: > + sctp_auth_destroy_hmacs(ep->auth_hmacs); > nomem: > /* Free all allocations */ > kfree(auth_hmacs); > -- > 2.1.0 > > Acked-by: Neil Horman