From patchwork Wed Aug 1 19:03:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10552825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCD5E174A for ; Wed, 1 Aug 2018 19:04:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB07C2BACC for ; Wed, 1 Aug 2018 19:04:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF7B82BAD6; Wed, 1 Aug 2018 19:04:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFF992BACC for ; Wed, 1 Aug 2018 19:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387496AbeHAUv3 (ORCPT ); Wed, 1 Aug 2018 16:51:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35063 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732033AbeHAUv3 (ORCPT ); Wed, 1 Aug 2018 16:51:29 -0400 Received: by mail-wr1-f66.google.com with SMTP id a3-v6so21140922wrt.2 for ; Wed, 01 Aug 2018 12:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=lBeVjYjQ2C39rIHLnnW0oF4VTicOZP9lUD3hTVIATMY=; b=mSJr/XntKvZcdVFFqfdxhlax80x7TxPJVEKr6rROaJbgSNR7bo2lRpZHDj5NuZ7Uq6 K5I9bJ02CXjagi2u0vjeHdceyMGHFXl5H9HXLiAAgxH7OUFspjVQB6kJphphUzyGl/Bp DiflRGuygYOMbA+1R6Z1scMhKuCYbkgrnfrZ0RrAlE9p22FibUL94GR2K3lxkFqTtCUG NfNqn2W4x2yrlmlI5TbG9n/zlr/zt0Gw0y+Z3p0ywVKCJAF0B6PJq9oxuHe47xcP8XLc o8nn9sqoHwwfO1RCJqDTgb+ETq2L87hfvPvR5tSL4d4w8thSpHmhrez7e1FUHTBMmu+p Zxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=lBeVjYjQ2C39rIHLnnW0oF4VTicOZP9lUD3hTVIATMY=; b=KZCtS0xRMb1LkEjHBbOBeyRm9kdnFbbNoGz0rYosHvmQ9W8/o3Dq3ymTchV4E59QBz rWuUSVQO05cnHXzm1lmEG8JAhF+BKnSHrmRrQ2mljoPns/Np0d9U83H/eCdP8AveK3yU ZzfF58c4x6vO28qBX+sgO6Ft/RAplRh7aZxgkNDroW3YBJRMCgEyb3jEuCoIerfqwdYQ aQNXeq2QNrJ/D8eESOjVB3i/au5uF05GSaaWwETInpIOuFb9S8Q2GPmUtBqJvBAE5olm Yo6TIzeu9vFnmDWetp90CKefaAsME5X8U9cSm0HYuCd6eLdXEPtuWylVqBhawxmASu4u ionQ== X-Gm-Message-State: AOUpUlFFH52xkeBVXWEG+fVKV+XSwrgndq+4pbkCpovfG2ALb+KaIhWx P3vTkp//piwqYMqQVw7sQ6Fgc22i X-Google-Smtp-Source: AAOMgpfOoZDiRsPhZmuGloNzJarcq3D/+a9ROB8NyP+1K1Q4dUmTqex267pipPGgEVky8l5bxXHXDg== X-Received: by 2002:adf:92c3:: with SMTP id 61-v6mr26296409wrn.231.1533150255889; Wed, 01 Aug 2018 12:04:15 -0700 (PDT) Received: from orange.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id r17-v6sm15401322wrt.44.2018.08.01.12.04.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 12:04:15 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 1/8] libceph: store ceph_auth_handshake pointer in ceph_connection Date: Wed, 1 Aug 2018 21:03:43 +0200 Message-Id: <20180801190350.857-2-idryomov@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180801190350.857-1-idryomov@gmail.com> References: <20180801190350.857-1-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 a718b877c597..021718570b50 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h @@ -286,9 +286,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 3f6336248509..b6ebd2cc16a1 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1434,24 +1434,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; } /* @@ -1471,8 +1473,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: @@ -1499,20 +1500,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); @@ -1781,11 +1777,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, @@ -1793,7 +1792,6 @@ static int read_partial_connect(struct ceph_connection *con) le32_to_cpu(con->in_reply.global_seq)); out: return ret; - } /* @@ -2076,7 +2074,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().