Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10785427imu; Thu, 6 Dec 2018 06:47:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/UJJKaC5+uY0A7c/+4C7ydQWOfTbwD6ZNxIx+bs7K5YNDp6qTY3tKvF56S6TmHK5wuKMcRG X-Received: by 2002:a63:1c61:: with SMTP id c33mr23750477pgm.354.1544107679921; Thu, 06 Dec 2018 06:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107679; cv=none; d=google.com; s=arc-20160816; b=m+aFJ1kdpHbhzRdvKdSAdw6VMwAr9Y/SHXJ81yai7oL7vx703/PezYkWFVWxNSXo8D XfqKjVewWgMEMdHaw/jMTkt74zNLpH1I3UY+33R9nnWM+IeFGdE0bp5mvoNXKWnOLjlI lt/oLPXb/zIApYH5uDqik6xT5CGfbhEhu09YrVV9owIGkOTUJy/ogYH8DR/AdnQEWvb3 ZBBUF1mE28lwEfUTb1JhLk2AGaxpaFcwbCx6SBVs59Vq6upKdYb9EDFFPq9rQ7cNWZPA h+IEno34FyeRt1BH1akiGdZoJy0G7oPLIWOhGjFv9ZhRTB+l/sBCXY6qC1Z7s8qEp6kG bCHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n5gtvKsamIqXsEFjrFTuN5fZIVEAAx8koSC1uAnECqE=; b=fsNYbBNGADahmzS6sjukWWtBksboqB8kh7nkrB6Sj3nt+pKfJq52gOp3CvuLJNmZrk IPJuJ6DK6yJHDS6LaNpmXSXAl8AMQBCM71QpzWcy4rJBHDheJIejWnCynM+3JIUZMBpu 3u1q0eMgCOfTsaCM8VI6PxzmExLzwPsNO2AXFXYH35jmOc5IoPi9Mun1wNTFs1vpFsx8 Oik9aMyhVIGWMxPcXfWGqlzbhTWekD4fktWt+4O7xURTL5fjYxvIXbKx3I4RFOMSz4eq LxpEbWk31s9WIiCn1Qj1+Oh/ryz03pbD25IZUspDgcI/Q8z8vUKqgEDHPt3kYWvln4F/ VBrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ps7rqsIv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u195si383130pgb.550.2018.12.06.06.47.43; Thu, 06 Dec 2018 06:47:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ps7rqsIv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731168AbeLFOpz (ORCPT + 99 others); Thu, 6 Dec 2018 09:45:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:50570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731150AbeLFOpx (ORCPT ); Thu, 6 Dec 2018 09:45:53 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 770FB2146D; Thu, 6 Dec 2018 14:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107552; bh=MTLRkr0re1AlR6zo89GXQ4n+lckIwumSKxZKlPbAIKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ps7rqsIvINbH31PACFn5ziqYkvrj6DixZhpGcJ5aYgUgvcY9u9zMoiZnN6lMtFkyg qDfULz+rriL8w4UhgF+q3nu4rlxJGX5fOGPty7xUUbKt87ipR8ty15mhsVx7jCm26F g5Mmx9jIVz8I6vKTMsrwJ5uFjDWmg01Ra5OgfuBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Sage Weil , Ben Hutchings Subject: [PATCH 4.9 050/101] libceph: store ceph_auth_handshake pointer in ceph_connection Date: Thu, 6 Dec 2018 15:38:49 +0100 Message-Id: <20181206143014.434108260@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143011.174892052@linuxfoundation.org> References: <20181206143011.174892052@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilya Dryomov commit 262614c4294d33b1f19e0d18c0091d9c329b544a upstream. We already copy authorizer_reply_buf and authorizer_reply_buf_len into ceph_connection. Factoring out __prepare_write_connect() requires two more: authorizer_buf and authorizer_buf_len. Store the pointer to the handshake in con->auth rather than piling on. Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- include/linux/ceph/messenger.h | 3 -- net/ceph/messenger.c | 54 +++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 30 deletions(-) --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h @@ -200,9 +200,8 @@ struct ceph_connection { attempt for this connection, client */ u32 peer_global_seq; /* peer's global seq for this connection */ + struct ceph_auth_handshake *auth; int auth_retry; /* true if we need a newer authorizer */ - void *auth_reply_buf; /* where to put the authorizer reply */ - int auth_reply_buf_len; struct mutex mutex; --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1394,24 +1394,26 @@ static void prepare_write_keepalive(stru * Connection negotiation. */ -static struct ceph_auth_handshake *get_connect_authorizer(struct ceph_connection *con, - int *auth_proto) +static int get_connect_authorizer(struct ceph_connection *con) { struct ceph_auth_handshake *auth; + int auth_proto; if (!con->ops->get_authorizer) { + con->auth = NULL; con->out_connect.authorizer_protocol = CEPH_AUTH_UNKNOWN; con->out_connect.authorizer_len = 0; - return NULL; + return 0; } - auth = con->ops->get_authorizer(con, auth_proto, con->auth_retry); + auth = con->ops->get_authorizer(con, &auth_proto, con->auth_retry); if (IS_ERR(auth)) - return auth; + return PTR_ERR(auth); - con->auth_reply_buf = auth->authorizer_reply_buf; - con->auth_reply_buf_len = auth->authorizer_reply_buf_len; - return auth; + con->auth = auth; + con->out_connect.authorizer_protocol = cpu_to_le32(auth_proto); + con->out_connect.authorizer_len = cpu_to_le32(auth->authorizer_buf_len); + return 0; } /* @@ -1431,8 +1433,7 @@ static int prepare_write_connect(struct { unsigned int global_seq = get_global_seq(con->msgr, 0); int proto; - int auth_proto; - struct ceph_auth_handshake *auth; + int ret; switch (con->peer_name.type) { case CEPH_ENTITY_TYPE_MON: @@ -1459,20 +1460,15 @@ static int prepare_write_connect(struct con->out_connect.protocol_version = cpu_to_le32(proto); con->out_connect.flags = 0; - auth_proto = CEPH_AUTH_UNKNOWN; - auth = get_connect_authorizer(con, &auth_proto); - if (IS_ERR(auth)) - return PTR_ERR(auth); - - con->out_connect.authorizer_protocol = cpu_to_le32(auth_proto); - con->out_connect.authorizer_len = auth ? - cpu_to_le32(auth->authorizer_buf_len) : 0; + ret = get_connect_authorizer(con); + if (ret) + return ret; con_out_kvec_add(con, sizeof (con->out_connect), &con->out_connect); - if (auth && auth->authorizer_buf_len) - con_out_kvec_add(con, auth->authorizer_buf_len, - auth->authorizer_buf); + if (con->auth) + con_out_kvec_add(con, con->auth->authorizer_buf_len, + con->auth->authorizer_buf); con->out_more = 0; con_flag_set(con, CON_FLAG_WRITE_PENDING); @@ -1737,11 +1733,14 @@ static int read_partial_connect(struct c if (ret <= 0) goto out; - size = le32_to_cpu(con->in_reply.authorizer_len); - end += size; - ret = read_partial(con, end, size, con->auth_reply_buf); - if (ret <= 0) - goto out; + if (con->auth) { + size = le32_to_cpu(con->in_reply.authorizer_len); + end += size; + ret = read_partial(con, end, size, + con->auth->authorizer_reply_buf); + if (ret <= 0) + goto out; + } dout("read_partial_connect %p tag %d, con_seq = %u, g_seq = %u\n", con, (int)con->in_reply.tag, @@ -1749,7 +1748,6 @@ static int read_partial_connect(struct c le32_to_cpu(con->in_reply.global_seq)); out: return ret; - } /* @@ -2033,7 +2031,7 @@ static int process_connect(struct ceph_c dout("process_connect on %p tag %d\n", con, (int)con->in_tag); - if (con->auth_reply_buf) { + if (con->auth) { /* * Any connection that defines ->get_authorizer() * should also define ->verify_authorizer_reply().