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=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT 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 18343C43381 for ; Sun, 3 Mar 2019 09:55:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3BBE20818 for ; Sun, 3 Mar 2019 09:55:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="swjdhB6s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726096AbfCCJzV (ORCPT ); Sun, 3 Mar 2019 04:55:21 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44371 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbfCCJzV (ORCPT ); Sun, 3 Mar 2019 04:55:21 -0500 Received: by mail-pl1-f193.google.com with SMTP id c4so1091391pls.11; Sun, 03 Mar 2019 01:55:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=b3guASaDRBEpvJg8ed0MapZBt+zrUiTC1JGRcMZAUXQ=; b=swjdhB6sT6s4YwB8GjaOrzdYhg72SPQEgTdVA3FnRuS5TModLNxyOze1b/w1qdsYy1 pPvlxyWyOgtYk9ywAgWOzAZZkpoDvuscCnmywntFqM1y2czKKJIZIgGluN30xjza5r7x F6OKatyqmYZqz/5eOAbnec/6GSM58uBhrQ7Nqd3Css/yJ7zqdcgOrBwrVuRumF5Ap3RI l+cuB3/S/y/qvzTHijiaSP62+K/5blcB5L6v4gglWuWfma5NLwcZgSda+JN32h5uS1pl P/gcTJc7g/4g2Rf9tbrfA8S0UJj+nFlSLkNbb3HrBjcNFdacxg6hMwvIpDoby3QOM0Ee OCsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=b3guASaDRBEpvJg8ed0MapZBt+zrUiTC1JGRcMZAUXQ=; b=q1Q8KoctjUgZfBhqWZHC7HF2iM/POOhqAjkh7VIJrFmFC5p1aCj+LQ0ewEsMesIvwS QppkzFiJlJASlyMzr6XSehCPDDr1ahqT+WN7hnREOkkTspYkmwU65e93QtRLaZOa+SN6 oJ5U0xBuaVy/OalQAPoTyZAOYhRJRwCMvvRC+WfeQTQ56fqEbDsGPXMTVuuu63d27an+ a4nzixzqkka9RJI1dIWOKZNCAl0xzJI/JuuX0qFDUcVsNoBrqEuSsmPDlV7YS7DV5L1f AXMW0Jq3xMkzzX53FCBL8AExUMo6KWEqULoiiYHNAICvlFfXPzOWEVsRti+PYzs369qE guBg== X-Gm-Message-State: APjAAAUEJheSBmOo/hkfG6piN2da20iyCAlwCKARvqwPYqhWQDEstJIH bYpiKVPB+7926d3OFCbNs2ZtF5E6 X-Google-Smtp-Source: APXvYqzlktoMlRiz2yBe60so9+inz7yQJm0uWIlFCqhfoC7hWAMVCfGEXQYDqW1o8eUZjYWvU1By1g== X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr14814497plb.101.1551606920698; Sun, 03 Mar 2019 01:55:20 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id i79sm5035783pfj.28.2019.03.03.01.55.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 01:55:20 -0800 (PST) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, Marcelo Ricardo Leitner , Neil Horman Subject: [PATCH net 2/3] sctp: move up sctp_auth_init_hmacs() in sctp_endpoint_init() Date: Sun, 3 Mar 2019 17:54:54 +0800 Message-Id: <408620556c373e59442bf68f97cba3a03ac3267a.1551606805.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <6837e72485125c8740900fd17fa84ac68b8892a5.1551606805.git.lucien.xin@gmail.com> References: <6837e72485125c8740900fd17fa84ac68b8892a5.1551606805.git.lucien.xin@gmail.com> In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xin Long Date: Sun, 03 Mar 2019 09:54:54 +0000 Subject: [PATCH net 2/3] sctp: move up sctp_auth_init_hmacs() in sctp_endpoint_init() Message-Id: <408620556c373e59442bf68f97cba3a03ac3267a.1551606805.git.lucien.xin@gmail.com> List-Id: References: <6837e72485125c8740900fd17fa84ac68b8892a5.1551606805.git.lucien.xin@gmail.com> In-Reply-To: <6837e72485125c8740900fd17fa84ac68b8892a5.1551606805.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, Marcelo Ricardo Leitner , Neil Horman 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