Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8123687imu; Tue, 4 Dec 2018 03:24:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/XdpUoGNg18fyApiVY+ERExegO0b0zj/Q+yyAhwGNGjKRQ3XvOZb3OrNn9NnRPmqk7c0gZZ X-Received: by 2002:aa7:81d0:: with SMTP id c16mr19466007pfn.153.1543922683455; Tue, 04 Dec 2018 03:24:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922683; cv=none; d=google.com; s=arc-20160816; b=tU30B5WEtCDtNbh7q3wj0YwNnQlvSMtX9KgP/+JH0/W8e/45DkSCaEHNVxhIKYg/LU 22Q4F3Vg/UP6NEx/MK9CEpCcpHFflHcND6yDGkHh1FQF9nCQAwvhMxqVPam5k06l4VJo 66I4Me8MU2W4EAslJW1gXEc2RkuTNq/W7uymd95AWnp1txNdfXKXFyRRACs5/V/zIhLi R/HwsTASVMIGbcKJhqSiOMPUWlbvSg+fTtawtDhIaykJbygVTXmUaTVyeS+0PqV/xIIn SVVlnHOKWU+ufreDjbYhQifTPQM5Dptt4DVJwlLIhztDiQN6pVh6OR+NOZPEw/OtzeGW QhQw== 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=CaqoyHqe5na7YLRtAsUN9PLE425RZZRBd4DnYFab8+0=; b=IC1F+FY1l6OwhuB6GJTJ5Ib1Ak32JhGyWtTMNgALDfLQTI8T5CqrgD388KVz3G/K8x gHWrkYH4mpWG6rxRCCNvlZ1DucCUweCCyGy5VNFRquZ8ViQpJ0KKdp7aN+hOKuS+WUQX qmksRswSdjXiMxeI4Y8YpaF/dsgUIuq3bD2gqDeEETLs1kn2pKz/YMzTrNP4AkU9qN4x 15Us7ILBTWuYgwfrUO+a2N6Y/UmPI+J55xdvCKf5zhlvDtzkxCjlyviknUq7xwLjF0E2 Dy95u0ne5bIo1GHvAFHbyfEiaHMT9/qO5H75A72QUA9w9dI8EN+rl/2FDhK0wssF/Ra4 RkDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="R/QtY6at"; 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 c10si16932235pla.173.2018.12.04.03.24.28; Tue, 04 Dec 2018 03:24:43 -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="R/QtY6at"; 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 S1726417AbeLDLB2 (ORCPT + 99 others); Tue, 4 Dec 2018 06:01:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:46914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbeLDLB0 (ORCPT ); Tue, 4 Dec 2018 06:01:26 -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 2D1CD214DB; Tue, 4 Dec 2018 11:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921285; bh=La+zjfgQNhJVu72zUzQWQBTF14Wof2GaLd+eVTNWoLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/QtY6atCBa4IX+yvT6OkyZlPOWWC3k4kW38AZmRymdewDYtOzc6kc25KiFDBnU6Q i+VKcQQMap+C4GLu9df9cCOu74U2sGJdALAmMu2EdKK8kAbxLHLnkUw1dchsDTjBDc 83Q53XJvvK5oUVugQnv8c18bnorb6Touk/tS8tZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Sage Weil , Ben Hutchings , Sasha Levin Subject: [PATCH 4.14 013/146] libceph: store ceph_auth_handshake pointer in ceph_connection Date: Tue, 4 Dec 2018 11:48:19 +0100 Message-Id: <20181204103727.334279597@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103726.750894136@linuxfoundation.org> References: <20181204103726.750894136@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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: Sasha Levin --- include/linux/ceph/messenger.h | 3 +- net/ceph/messenger.c | 54 ++++++++++++++++------------------ 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h index ead9d85f1c11..9056077c023f 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h @@ -203,9 +203,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; diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 5281da82371a..3a82e6d2864b 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1411,24 +1411,26 @@ static void prepare_write_keepalive(struct ceph_connection *con) * 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; } /* @@ -1448,8 +1450,7 @@ static int prepare_write_connect(struct ceph_connection *con) { 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: @@ -1476,20 +1477,15 @@ static int prepare_write_connect(struct ceph_connection *con) 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); @@ -1753,11 +1749,14 @@ static int read_partial_connect(struct ceph_connection *con) 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, @@ -1765,7 +1764,6 @@ static int read_partial_connect(struct ceph_connection *con) le32_to_cpu(con->in_reply.global_seq)); out: return ret; - } /* @@ -2048,7 +2046,7 @@ static int process_connect(struct ceph_connection *con) 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(). -- 2.17.1