From patchwork Wed Nov 11 23:29:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898835 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 C5A6CC388F9 for ; Thu, 12 Nov 2020 01:50:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F1A920791 for ; Thu, 12 Nov 2020 01:50:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gYm11KBC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728394AbgKLBc1 (ORCPT ); Wed, 11 Nov 2020 20:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727917AbgKKX3k (ORCPT ); Wed, 11 Nov 2020 18:29:40 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57814C0613D6 for ; Wed, 11 Nov 2020 15:29:39 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id e142so755492ybf.16 for ; Wed, 11 Nov 2020 15:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=LpVxdvBMcmSDcbss/la6MvnV7rivL9P1LqACanV9DxE=; b=gYm11KBCnvUBSfr0tIjz7sMC0JtFCq5cKhT7zk25yIClnkcBLjesoASk3XebkNzmtM xlrUnTxT+IfA+593M0+obMQ9uMGD4LmK3xpy6rTQQH66GDSgT+/sEK7fZgqFx/L3KaP3 4AZ6YUxaa2m5ODOvmWT5lYnnu3AS1x6Bedv6aBK9tBjx51Zo/fb/5+tlxy4k035raqQB H2WMy6RQM3sjKMHi5z/si3BrBGOKbp3umVIUHL5USbOgpUEIQlDR72qeXtZ84IyqlOn+ 9QlHF+KzdxKpL8ueNUBK8a1nuNuFhG2GwXz3Lwq1jlZh9CiE/0A1swvfLbG/ffg5f9+J hSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=LpVxdvBMcmSDcbss/la6MvnV7rivL9P1LqACanV9DxE=; b=IV0ajf7mbE9f/2fZWVtK0FN9U71vNndsJs/Hu0GPzKuoajhTcopdSd36LL667RKNlO v4ax9VefKiD9ALtvtP9C1n3wU9TJMPjizJO0IfTsKNHb/WNbjQopdiW94F+5R0Om6xR6 OJRrs/jQ5hazWcDc8XKDflZydzF12k285j5cglNWXZImLbmBs0UYSoTbvN7gxtfBMwjs 7UbHnd2JKOtHbdPQzi3qjMg0D/8/fH13cJ9GNefUrTUvcEndOFIdX5o3GPe7CMDwDXoY IkfeCtwVB+pVjcm2+O4PcqB/L0uz3cOziKqCZ45HDHADzN5gvSOj2b9cMPWP37Qk2ik3 mvAQ== X-Gm-Message-State: AOAM533EqVPEU2SQCKzFZjmrtHzzZYPXAsWbwh4PLedAhSFndVHL+4wJ jv3lk8kKOdJCxkCjMqubeilXsd/Q3bRN3yAbyG5CpwPh5wg5mWXFSclogZba/45bAvTIDRtxAZq o8qkPgDVUG5EtCp90ix6ZUm2TvnD4vmS1sQVL1w4TxogMXpCM/4PkwC7/1D1z4i8= X-Google-Smtp-Source: ABdhPJxIV0Rk5fOuQQRJCRMKXhUTofhk3JLqqrEllVU8yb9naPXGijkc4rcMUtZ3TKYozDyRsOKr37UfnLJ/Zg== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a25:6dc6:: with SMTP id i189mr36502472ybc.299.1605137378530; Wed, 11 Nov 2020 15:29:38 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:24 -0800 In-Reply-To: Message-Id: <184cabb6f5d56f4c7cc744fc311428f1ab13d93b.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 01/11] docs: new capability to advertise session IDs From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In future patches, we will add the ability for Git servers and clients to advertise unique session IDs via protocol capabilities. This allows for easier debugging when both client and server logs are available. Signed-off-by: Josh Steadmon --- .../technical/protocol-capabilities.txt | 17 +++++++++++++++-- Documentation/technical/protocol-v2.txt | 13 +++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt index ba869a7d36..9dfade930d 100644 --- a/Documentation/technical/protocol-capabilities.txt +++ b/Documentation/technical/protocol-capabilities.txt @@ -27,8 +27,8 @@ and 'push-cert' capabilities are sent and recognized by the receive-pack (push to server) process. The 'ofs-delta' and 'side-band-64k' capabilities are sent and recognized -by both upload-pack and receive-pack protocols. The 'agent' capability -may optionally be sent in both protocols. +by both upload-pack and receive-pack protocols. The 'agent' and 'session-id' +capabilities may optionally be sent in both protocols. All other capabilities are only recognized by the upload-pack (fetch from server) process. @@ -365,3 +365,16 @@ If the upload-pack server advertises the 'filter' capability, fetch-pack may send "filter" commands to request a partial clone or partial fetch and request that the server omit various objects from the packfile. + +session-id= +----------------------- + +The server may advertise a session ID that can be used to identify this process +across multiple requests. The client may advertise its own session ID back to +the server as well. + +Session IDs should be unique to a given process. They must fit within a +packet-line, and must not contain non-printable or whitespace characters. The +current implementation uses trace2 session IDs (see +link:api-trace2.html[api-trace2] for details), but this may change and users of +the session ID should not rely on this fact. diff --git a/Documentation/technical/protocol-v2.txt b/Documentation/technical/protocol-v2.txt index e597b74da3..85daeb5d9e 100644 --- a/Documentation/technical/protocol-v2.txt +++ b/Documentation/technical/protocol-v2.txt @@ -492,3 +492,16 @@ form `object-format=X`) to notify the client that the server is able to deal with objects using hash algorithm X. If not specified, the server is assumed to only handle SHA-1. If the client would like to use a hash algorithm other than SHA-1, it should specify its object-format string. + +session-id= +~~~~~~~~~~~~~~~~~~~~~~~ + +The server may advertise a session ID that can be used to identify this process +across multiple requests. The client may advertise its own session ID back to +the server as well. + +Session IDs should be unique to a given process. They must fit within a +packet-line, and must not contain non-printable or whitespace characters. The +current implementation uses trace2 session IDs (see +link:api-trace2.html[api-trace2] for details), but this may change and users of +the session ID should not rely on this fact. From patchwork Wed Nov 11 23:29:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898831 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 24E2CC388F9 for ; Thu, 12 Nov 2020 01:50:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB8AD20791 for ; Thu, 12 Nov 2020 01:50:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UFa72zDp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbgKLBc2 (ORCPT ); Wed, 11 Nov 2020 20:32:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727918AbgKKX3l (ORCPT ); Wed, 11 Nov 2020 18:29:41 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 620B7C0617A6 for ; Wed, 11 Nov 2020 15:29:41 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id q5so2252407pgt.0 for ; Wed, 11 Nov 2020 15:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=q5sEuC3n8RveOdl6xjqIRa92pbUf7agPILK2zH4JUbk=; b=UFa72zDplsg1XcwjdhIWQGK0yMdFKImWRVw0Nk2jb+QsKoN3he2ynycOdgDAt85sDn f3emy0iEV8z0fbyxK2Pu1i2nuzNjqGB66V61TQgV6vLPFQwI320CQGZXeHcizO63/JOF 735zT0NlqpEEOyOaQnrZC6M57hOR4jqXRd+Hd5CWZQPXAAx2ZZ+tNLkjw3v03x4XES67 +738ObHJvK7Y44bE75vbb4pXbeevsRtvKW3huO0mePpO8z0VayaWPS3GnqoM8onuQxqs T1QT+rOXO7fy1kLL3kHDZ0kGkXvXTHXtsl1ZJ2zOrTdTHxDzYGTfjW70TzPTrhkZwMDm ddMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=q5sEuC3n8RveOdl6xjqIRa92pbUf7agPILK2zH4JUbk=; b=F9QCAXaiiGxo3eS4DDuRiR0y57Q5yuBWwZEOrYmcgkW8pkY7lWVmGESzkEexWSGpBy FmDMsL75O+StRwNWO0QO9IrAvDESRj1WKQt83hverAZl3Secpna/E6w0X4XmDfBPOcDQ QN5foUMYP7b+B+9dCfpsgZKYknKFBp79khcofL+PHtbjuDu1dKebKxFxZDCWnYbJMQar p8z11KubinVLY/OW65xVE/NTUUq6QFNFOLKrlZkOziXsgR2L8OIdSvGB/Gt1n+xIBrin 1ZfuLrL863z5fttc7WOFOU/oZTpZjze2JlLrDDi8OZeCeSb8IAaxtrjmhkmOEalX3vc+ ftVg== X-Gm-Message-State: AOAM533D5YZU5cBryPmJEcec/UGUZKC3Eb5U3dtylfG/3nRMCNlljY3Q ihPP8RsoifH7bFZeDO5Xd2czL1XPTyKrGrlI5AaYhIM7nTlRAuQyqQ3+3/wzzIby5wyXJgfrii6 ef/BNFlLrL8XByui+e/FrNUHk+GLODSNYKYzwf1iH+R5hOYPas1sOc5tHpHoV1OY= X-Google-Smtp-Source: ABdhPJxWcC+QdnJM4jIPo7evqzNsHjuzm1NxQW8092gXA/oaVnwfq+jgXPC9apliaVXr+oXxJI8PihTbBsIROQ== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a17:90b:293:: with SMTP id az19mr625042pjb.1.1605137380468; Wed, 11 Nov 2020 15:29:40 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:25 -0800 In-Reply-To: Message-Id: <937534065a9d5609f61fdcf7a8309418a07cb755.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 02/11] docs: new transfer.advertiseSID option From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Document a new config option that allows users to determine whether or not to advertise their session IDs to remote Git clients and servers. Signed-off-by: Josh Steadmon --- Documentation/config/transfer.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/config/transfer.txt b/Documentation/config/transfer.txt index f5b6245270..505126a780 100644 --- a/Documentation/config/transfer.txt +++ b/Documentation/config/transfer.txt @@ -69,3 +69,7 @@ transfer.unpackLimit:: When `fetch.unpackLimit` or `receive.unpackLimit` are not set, the value of this variable is used instead. The default value is 100. + +transfer.advertiseSID:: + Boolean. When true, client and server processes will advertise their + unique session IDs to their remote counterpart. Defaults to false. From patchwork Wed Nov 11 23:29:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898833 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 43339C4742C for ; Thu, 12 Nov 2020 01:50:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6ABD20791 for ; Thu, 12 Nov 2020 01:50:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CMHQpxp/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728408AbgKLBc3 (ORCPT ); Wed, 11 Nov 2020 20:32:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbgKKX3o (ORCPT ); Wed, 11 Nov 2020 18:29:44 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DF6C0617A7 for ; Wed, 11 Nov 2020 15:29:43 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id h9so3949660ybj.10 for ; Wed, 11 Nov 2020 15:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=yMa6nPQATK/YI7+9VIfxkNmcwemehrCcEEiiMSK6Tvw=; b=CMHQpxp/481Vp6sI9s4vI+cDxir0pWkSnGOs+kqZUw+GDFmB5UfrMsCiuRs35PNDdW bExpGKzIzn05aQBVUQj4kEmfEyNEN1OYINC2GEuINTazIAOk7D5+f9jcDtqOWtov5nhV b5rpGk8OBDz2ttNfypMuc/nnSWvCdcr8KSjBmr0/rcJ3YIDq93ox4xvFY/kRKSsJztPc iJolenNMsnEpzdTJ27/9wvdHRHxUiGLxZFYIgHtLIIHz5P+4OFmFSJ8EHCIUJehnCyTm Gm9IT9YHZXHPu7JBba+b1YUrRgNDAeQ4NtmJ+Ow135/xv48p9Mu22Jk/iDP50BpE0Q6z 4Rsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=yMa6nPQATK/YI7+9VIfxkNmcwemehrCcEEiiMSK6Tvw=; b=m0loFrtofaPzC8p3auwFtzeU2Iita43uHryKEmdaW1PThOejLc8Z8ZPBPs6lkF7/4q 8YBTjoK3MtjgZ3gROYvBS1gT8JBvCfn3t5Y15RgxnTogAF6rtvkHYcHyb9YVg2ApNjL/ gWdQ53MtqaxOtxHgD5nSQnwBvokTIMdsDBkFY0ONerTCHP9Je2fOsDtuoxlYlukfT7oT NVdqjlFFf1VewWKkM61IkiUqvxAZlHWgZIxi63/5c6vsVInygkl7C2DCM0hN4D/RgH6s DpcTmvrja5X4wknbHhTYB6/fOYE8RqeTPO3IgcK+EX4YZ8Va71LzF49BMwGahq1atCj8 uwQA== X-Gm-Message-State: AOAM531OFqQ2H/1iMqVNT9YqhYcdAIBZPIHAlDr8MsLKNZrt4UGGxbo/ FOi8LlWIskyQT+Gl9kgC56DyMcpEsU+bK7N0HilHTAychesU048lucBGq5u3Wo3WDpYEd5PAVaR 32PURiQR4pjrcXXRpp9NG9frgQTfE2zSSSf10yZlNDE6gDbLzAsgju7rLsQAmHL8= X-Google-Smtp-Source: ABdhPJzgsVHhd1VC08PSmN1szuTaRs1qUJypYaUf2ty5pRPjTv+NHG4uQ1S39tLWU4bNKEfgbxVCHYkDZlD3NA== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a25:384c:: with SMTP id f73mr35388026yba.135.1605137382450; Wed, 11 Nov 2020 15:29:42 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:26 -0800 In-Reply-To: Message-Id: <227c709ba54ee457f05704e52310b39edeaae1ca.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 03/11] trace2: add a public function for getting the SID From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a public wrapper, trace2_session_id(), around tr2_sid_get(), which is intended to be private trace2 implementation. Signed-off-by: Josh Steadmon --- trace2.c | 5 +++++ trace2.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/trace2.c b/trace2.c index 2c6b570077..256120c7fd 100644 --- a/trace2.c +++ b/trace2.c @@ -792,3 +792,8 @@ void trace2_printf(const char *fmt, ...) va_end(ap); } #endif + +const char *trace2_session_id(void) +{ + return tr2_sid_get(); +} diff --git a/trace2.h b/trace2.h index b18bc5529c..ede18c2e06 100644 --- a/trace2.h +++ b/trace2.h @@ -500,4 +500,6 @@ void trace2_collect_process_info(enum trace2_process_info_reason reason); } while (0) #endif +const char *trace2_session_id(void); + #endif /* TRACE2_H */ From patchwork Wed Nov 11 23:29:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898837 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 B893DC388F9 for ; Thu, 12 Nov 2020 01:50:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45F7720791 for ; Thu, 12 Nov 2020 01:50:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MJ/kWAKB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728414AbgKLBca (ORCPT ); Wed, 11 Nov 2020 20:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727920AbgKKX3q (ORCPT ); Wed, 11 Nov 2020 18:29:46 -0500 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BBEFC061A04 for ; Wed, 11 Nov 2020 15:29:45 -0800 (PST) Received: by mail-qt1-x84a.google.com with SMTP id h26so2247185qtm.2 for ; Wed, 11 Nov 2020 15:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=skzlVKFzG6D61ggv/OQ/6vDZJ3tABONq6LxAY7QxIlE=; b=MJ/kWAKBF7E5bHr8jv6lVWCidZ0w4e5iYO1bn0Z7idRL3Co9anclO0otaBFOr5HjWv BnvFrguTIHhUSwaNNgU64Bhie141etC9UdQg2p2rvFwZvdag1WM30dqaLZU8qlGCXRZh ulOnVZGu5B/XsfxTOBVT3UmQ45Hcu1+Wr+1tE5sWHkcBuZ5ARRpxL+EKHQBiK4hTha91 6Je6DS+GMyXFv+8wcTzAOKa70eD+21PAP+tAEZ+e6A6B2kC26TqyKB2luRaHAPHcKyt1 fguXFE0t/nNw6li/T+mnsU6v+kZtS8qqlSEX6sE1sOlV1xIC1m8f+LlAk9y2p1u9euzs dsow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=skzlVKFzG6D61ggv/OQ/6vDZJ3tABONq6LxAY7QxIlE=; b=KBPxxguXBAozdmsqHlsmBYJD36tnbZ39MVDGq5jylqcEsEPh4Dt5N9SBOQKP7O9KWz Y/Fn6hrGKimRuS1+Z75LnkYTbFt6mDLX8nX9SqJOxGANhb5R1YZqGqbJmknnD09QARz7 2MXXX/JH4awxU8tDwLbtsEyQ9mcxE2PW+JRm69U+fInBWrJRqweXR2+5uZ06mLDnG6d0 MZ2bq7U63x35JwTvp+2xOG/C3ZzKDOm9Z1soOWp4XeIJ5rUsBnncsK0bYlsdyxdZX/J+ 7nnylDT1wpMw+o5saF+B/s1caJpJG9jRdDV7Uezhu9H1mbmsBiXWuA+uulbhiNXlohr6 M/yQ== X-Gm-Message-State: AOAM532Y8yWG/NPlKlJObniGTSmjNah+hBre/9IOXMvX1C+nOR5ihu3i kMVkGpfx2WOokauPpGWlPCswjNbJxLa3L7BUeMv928InvbNH1YEgWw6YhOqMpUwO/DDR/HwN31S 0YQsLDRlo5NG0fNRn3FtiVuNoGw6k8vg6owmUl1XqJnchKZw/83Rq7ftafdHvVDQ= X-Google-Smtp-Source: ABdhPJzboFtGFppGaAFXh23dpX3NianwDcEhcm9sElEaCXOL4U6XsLFSC+RI4lmbevj43shonu9GDuu0kF/NPA== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a0c:eb91:: with SMTP id x17mr11983372qvo.36.1605137384235; Wed, 11 Nov 2020 15:29:44 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:27 -0800 In-Reply-To: Message-Id: <612957b9d56a30a22b4b05c46d9050e3fd2979d8.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 04/11] upload-pack: advertise session ID in v0 capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When transfer.advertiseSID is true, advertise upload-pack's session ID via the new session-id capability. Signed-off-by: Josh Steadmon --- upload-pack.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/upload-pack.c b/upload-pack.c index 3b858eb457..ebb4099268 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -110,6 +110,7 @@ struct upload_pack_data { unsigned done : 1; /* v2 only */ unsigned allow_ref_in_want : 1; /* v2 only */ unsigned allow_sideband_all : 1; /* v2 only */ + unsigned advertise_sid : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -141,6 +142,7 @@ static void upload_pack_data_init(struct upload_pack_data *data) packet_writer_init(&data->writer, 1); data->keepalive = 5; + data->advertise_sid = 0; } static void upload_pack_data_clear(struct upload_pack_data *data) @@ -1178,6 +1180,11 @@ static void format_symref_info(struct strbuf *buf, struct string_list *symref) strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util); } +static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) { + if (d->advertise_sid) + strbuf_addf(buf, " session-id=%s", trace2_session_id()); +} + static int send_ref(const char *refname, const struct object_id *oid, int flag, void *cb_data) { @@ -1193,9 +1200,11 @@ static int send_ref(const char *refname, const struct object_id *oid, if (capabilities) { struct strbuf symref_info = STRBUF_INIT; + struct strbuf session_id = STRBUF_INIT; format_symref_info(&symref_info, &data->symref); - packet_write_fmt(1, "%s %s%c%s%s%s%s%s%s object-format=%s agent=%s\n", + format_session_id(&session_id, data); + packet_write_fmt(1, "%s %s%c%s%s%s%s%s%s%s object-format=%s agent=%s\n", oid_to_hex(oid), refname_nons, 0, capabilities, (data->allow_uor & ALLOW_TIP_SHA1) ? @@ -1205,9 +1214,11 @@ static int send_ref(const char *refname, const struct object_id *oid, data->stateless_rpc ? " no-done" : "", symref_info.buf, data->allow_filter ? " filter" : "", + session_id.buf, the_hash_algo->name, git_user_agent_sanitized()); strbuf_release(&symref_info); + strbuf_release(&session_id); } else { packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons); } @@ -1299,6 +1310,8 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data) data->allow_sideband_all = git_config_bool(var, value); } else if (!strcmp("core.precomposeunicode", var)) { precomposed_unicode = git_config_bool(var, value); + } else if (!strcmp("transfer.advertisesid", var)) { + data->advertise_sid = git_config_bool(var, value); } if (current_config_scope() != CONFIG_SCOPE_LOCAL && From patchwork Wed Nov 11 23:29:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898827 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 9CBBDC4742C for ; Thu, 12 Nov 2020 01:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3488B205ED for ; Thu, 12 Nov 2020 01:50:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hsix0zsH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728425AbgKLBca (ORCPT ); Wed, 11 Nov 2020 20:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727923AbgKKXaS (ORCPT ); Wed, 11 Nov 2020 18:30:18 -0500 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00ED2C061A47 for ; Wed, 11 Nov 2020 15:29:47 -0800 (PST) Received: by mail-qv1-xf49.google.com with SMTP id m11so2047263qvu.6 for ; Wed, 11 Nov 2020 15:29:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=nLiYW/2IgWYFFH2gz421GCoVsN1fZ0JN5aKM7M8F1ew=; b=hsix0zsHScS3eE6fRgWC7chCB0DV/xMc5vorqKSvJ5Y3EjJ5zwktmCwFfPIIoqltj/ XCHMvlFQ8pggKb5q1/iX5ZjPeBf1KOxeLDzJtd6RUNezuoGfJn8RjKQhpFbuk5q+FFM7 CpFwzO1Z4OwDphC3wg8Xj6PejuSiij4f1Ci2QjwqXOZ7CDgA/fMKCg8bAIchpBwrEnoz nVCiYFV6jFLbSmYZcTMU/R6UlAotHCUhNMuYOtf2B6p1oLKxaSpAKwn5roND69htAzvj hj8EaDCkrGdCBNRYsvFMNb77FgzIZ4Bsbr1a9NBYkbixEGf+DcClXgPQ08O5ql07j+1U Kigg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=nLiYW/2IgWYFFH2gz421GCoVsN1fZ0JN5aKM7M8F1ew=; b=lUGrvkefk2YivnQq5uk5s5wGWAmt1KaQrmjeoi6/47m8uT6iMwrZVtc5sCpmlfrRaG eOIk9Efh0d4kNNtEkwaUE6X9oR6ND0ykEwOXQGXqlVO7AbHvmjvq2L977H67dMnVEzrY YLUmMK7kePgekhlYeEmfvK4/iUsxecE1W12DoxTMXA27t5rP28sFE2U0G/OF/RREbw38 QSx91jDZv5+7mENmTw9dwFe1ojjSl+7l63zpe88Vc6/VsR0rVUgRKjZ88AMnWh9eONx2 /ebHk/YIGtBpUJ9jO4TggeLXkpztgusY6F5FyXlzobHHLhC6tj0xxT5p1hnYPq/AKKU3 9NZg== X-Gm-Message-State: AOAM5321h+td3xnpaLQmTHVVaTr9Qb5QO79LxTA19hV5UqmUz9zLmQDj 1p15we1WkDNg463WR0LD7GIs6+pwXBkPkBLytmLLdwi3Ct9BhTwz4Z6zXfZff6sOwgyOq/nQAir f3lSPDGM+4FWeKrY30nKFNXv5gVmAbpILu+Z0JPFFDivpfJLngyirhyUii5KVREU= X-Google-Smtp-Source: ABdhPJzVGamHO3ZsToVb9fGi37UoETwWs1uUhAXi/YiG2Po+6TRk0R6oEvU/KKVJRT8majYxo4qBwqolGqQRMg== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a0c:f050:: with SMTP id b16mr21553767qvl.34.1605137385969; Wed, 11 Nov 2020 15:29:45 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:28 -0800 In-Reply-To: Message-Id: <32fe78f3e95334197e73230169a9b0a292ec47bf.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 05/11] receive-pack: advertise session ID in v0 capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When transfer.advertiseSID is true, advertise receive-pack's session ID via the new session-id capability. Signed-off-by: Josh Steadmon --- builtin/receive-pack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index bb9909c52e..6ed498b6c7 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -54,6 +54,7 @@ static int receive_unpack_limit = -1; static int transfer_unpack_limit = -1; static int advertise_atomic_push = 1; static int advertise_push_options; +static int advertise_sid; static int unpack_limit = 100; static off_t max_input_size; static int report_status; @@ -248,6 +249,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb) return 0; } + if (strcmp(var, "transfer.advertisesid") == 0) { + advertise_sid = git_config_bool(var, value); + return 0; + } + return git_default_config(var, value, cb); } @@ -268,6 +274,8 @@ static void show_ref(const char *path, const struct object_id *oid) strbuf_addf(&cap, " push-cert=%s", push_cert_nonce); if (advertise_push_options) strbuf_addstr(&cap, " push-options"); + if (advertise_sid) + strbuf_addf(&cap, " session-id=%s", trace2_session_id()); strbuf_addf(&cap, " object-format=%s", the_hash_algo->name); strbuf_addf(&cap, " agent=%s", git_user_agent_sanitized()); packet_write_fmt(1, "%s %s%c%s\n", From patchwork Wed Nov 11 23:29:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898745 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 044CAC4742C for ; Thu, 12 Nov 2020 01:32:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5ADF208B3 for ; Thu, 12 Nov 2020 01:32:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ggqSLrmf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728431AbgKLBcb (ORCPT ); Wed, 11 Nov 2020 20:32:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727924AbgKKXaU (ORCPT ); Wed, 11 Nov 2020 18:30:20 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD599C061A48 for ; Wed, 11 Nov 2020 15:29:48 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id a1so2548580qvj.3 for ; Wed, 11 Nov 2020 15:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=3JnLb44Hcl2AEq7btI9/QWLzUhYEnzSwZeFrrY9880s=; b=ggqSLrmfYrBiVW4vCgUlDC1+ksphJYNPpzPVZtbuxAbILvbvwV6KLVRh2eKFCR6S7h rnPdzgUAlldFyo1Z+3Q3pvm9uu0Yxl8dgsyX91XIHvsqWt2qk51Vod2UNJNe6B+oKOBl iSKQbVBeJPF7QFpqRwmuxoHRWaGCT9ZagOyFeVTaw8pzhckgydhOv8h5SI64wgNTkSTX 3m0WbCoufqOj+N2vcrBhO1HymzJtg86J9uL7byQRmiWyRqmv/YtmJWM9emuLUn8WKSA+ QrKertc6tD7BYOtYBxHuAPExEVFHO5eiQIoDWi0+GYIQGCpwmenl/hf4VJK+DvfwoApB 5DLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=3JnLb44Hcl2AEq7btI9/QWLzUhYEnzSwZeFrrY9880s=; b=Ph00ARi5AKN0rrZ9CkrMElbNFDWXOhjXfOkbbkYKyUGuW6G1AEBWXjvNSC2zYK2dkZ fV8J39FBsfcVwGoI9LNrHfS6WZgFV3JQzRIuvEDN/sLPy/33Yewe5g93Ac/NaJeZdl0a aJin89DaCoUv/DzJoQkgPb/LGfZ+jiSFTqpMl+SxKdzeeni1ZcW68rGdcAr1GVsO0Ynp YS2XOzzIzQZZXDM2NwiuRGxfbXAgnOQzhPorKo48X0I1ZH764PaTHwOM+dRJ6W0LsvyH R9MTZI9Gf5kdXXE2QAPLOOpwLonvgFfe7dwtsbtccykqb0OXGwG6oUVSn9oa3Sh8SEfd Dtgw== X-Gm-Message-State: AOAM532RuYeCDRWN0WUpIcj6cFMPVwcaQuxbG/k31GLsaF//saX5tskV xSEd/CE9mIWUMbp4I4tbp0anc2qJH57tT+RGTPYTnjyuJi4gSUoKBWDa5i759quF5jDh3Bgvo7y Xw6LLbwfUyO17LO9nVCijtvqdqOI+TDawk7T10roOj49UUX71ATPFJK6mm2gqGlI= X-Google-Smtp-Source: ABdhPJwLunP8i68VRX7NCF7StnDoAwuIShLzv5dyfznCWp39FG4NXZbZl/6mkyYsmbeVUSKFsrhRMJcrS0TRkg== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a05:6214:1507:: with SMTP id e7mr26783772qvy.50.1605137387810; Wed, 11 Nov 2020 15:29:47 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:29 -0800 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 06/11] serve: advertise session ID in v2 capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When transfer.advertiseSID is true, advertise the server's session ID for all protocol v2 connections via the new session-id capability. Signed-off-by: Josh Steadmon --- serve.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/serve.c b/serve.c index f6341206c4..8c0bb84f37 100644 --- a/serve.c +++ b/serve.c @@ -8,6 +8,8 @@ #include "serve.h" #include "upload-pack.h" +static int advertise_sid; + static int always_advertise(struct repository *r, struct strbuf *value) { @@ -30,6 +32,15 @@ static int object_format_advertise(struct repository *r, return 1; } +static int session_id_advertise(struct repository *r, struct strbuf *value) +{ + if (!advertise_sid) + return 0; + if (value) + strbuf_addstr(value, trace2_session_id()); + return 1; +} + struct protocol_capability { /* * The name of the capability. The server uses this name when @@ -66,6 +77,7 @@ static struct protocol_capability capabilities[] = { { "fetch", upload_pack_advertise, upload_pack_v2 }, { "server-option", always_advertise, NULL }, { "object-format", object_format_advertise, NULL }, + { "session-id", session_id_advertise, NULL }, }; static void advertise_capabilities(void) @@ -261,6 +273,8 @@ static int process_request(void) /* Main serve loop for protocol version 2 */ void serve(struct serve_options *options) { + git_config_get_bool("transfer.advertisesid", &advertise_sid); + if (options->advertise_capabilities || !options->stateless_rpc) { /* serve by default supports v2 */ packet_write_fmt(1, "version 2\n"); From patchwork Wed Nov 11 23:29:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898739 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 A3E67C388F9 for ; Thu, 12 Nov 2020 01:32:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C5A520809 for ; Thu, 12 Nov 2020 01:32:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IZpLjLa5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728448AbgKLBcf (ORCPT ); Wed, 11 Nov 2020 20:32:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727927AbgKKXbj (ORCPT ); Wed, 11 Nov 2020 18:31:39 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A19C061A49 for ; Wed, 11 Nov 2020 15:29:50 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id h9so3949852ybj.10 for ; Wed, 11 Nov 2020 15:29:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=SPTfoDU7oaS1izrTItAOGX8PlPGtVfveZVP2zs6SoLE=; b=IZpLjLa550r1zFU7t+n8+E3MV5JxyNQa98o/Z/SBkP70YXbtVdJ1rOVhM/JOZEQm1f OnuzfsTBexu+cO+8SAY+GtMzFIdXhKiYWbMzAHI9bRdYPWwchQYOxbcZ0uho/Gs02NsT 4ZOvN7x3yhAXdoLlK5S9FUMinzn/UHVROcHRXAJPMuKvmlqdxsF+DQrmeuoMqKqvjLNU 7iz+Qiwjc6vrtue1oypb2hEIWsWDcBr2sGgaJlcM8Cs/t9XMvhg/RmEZc6/kekXiP7Cv 3rf51ZEHcqjNE3a7fyNWIxG4A4VOt9yVejCpcbN0UhmMnRSlM33xQiiZqV0DBXNxq1Cg ANXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=SPTfoDU7oaS1izrTItAOGX8PlPGtVfveZVP2zs6SoLE=; b=pFcCW1HZx2XDeiqBryamDn/6QMzqLEBUTwByBsqF5ds0EaQ8o6bCNpTF0UW9n6ny1C KdsphUYAHG1oEx+/cdOpuJU/bCuGqMFMYvnZ9wcKYaighs1eR65OyWMFhm/93ZweQF0g G+4ZPKBnZDFc9o4YtFGFBhyI27/hddEa0+vV4GauhDd6EOiKc7cmB+/vrn/11LjqoX9G dyYP9XRE72qA/rxzKuw2X9l5Gbnvi8B9VsFTG9K0wJqGqUS250mN1+mTuedQlfWwRrt1 Ulj6qNC1xHgvX+5gYfquYGemVM8l3HdQpu5HOSxQvAuRfCFIYYxqGCDq2chHz1GPCr+b LFTA== X-Gm-Message-State: AOAM533fYmowgJbIUScSGMRlMFY740L8CnWlyE0YVRMT2nwPOjNWAFFA 7G8sUj2qzrYfLO1Yz0qgvYxby8GL8ghSxnGOg6djXmOuq97ygRMycVZpisE9jF0XW7hpzeKrp4C bUmNPFl2zbNb1A+MuoFV07nFHeeVmrof68SjE4908iolwO+tu8Xn9Z3Xm0xGacGE= X-Google-Smtp-Source: ABdhPJzbtGj223IGG9YX12/P6CXpA5COFw/hnDYYyukQtgi32bINojnd6lhQp1TQkOynAR4UFOwYqlOAJSmVWw== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a25:10c5:: with SMTP id 188mr37704606ybq.181.1605137389612; Wed, 11 Nov 2020 15:29:49 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:30 -0800 In-Reply-To: Message-Id: <014cae8dc1c3e03e149f8abc98f2f1a50bb0cb98.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 07/11] transport: log received server session ID From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When a client receives a session-id capability from a protocol v0, v1, or v2 server, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon --- t/t5705-session-id-in-capabilities.sh | 64 +++++++++++++++++++++++++++ transport.c | 10 +++++ 2 files changed, 74 insertions(+) create mode 100755 t/t5705-session-id-in-capabilities.sh diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh new file mode 100755 index 0000000000..9e782f4413 --- /dev/null +++ b/t/t5705-session-id-in-capabilities.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +test_description='session ID in capabilities' + +. ./test-lib.sh + +REPO="$(pwd)/repo" +LOCAL_PRISTINE="$(pwd)/local_pristine" + +test_expect_success 'setup repos for session ID capability tests' ' + git init "$REPO" && + test_commit -C "$REPO" a && + git clone "file://$REPO" "$LOCAL_PRISTINE" && + test_commit -C "$REPO" b +' + +for PROTO in 0 1 2 +do + test_expect_success "session IDs not advertised by default (fetch v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local fetch origin && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + ' + + test_expect_success "session IDs not advertised by default (push v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + git -C local pull --no-rebase origin && + GIT_TRACE2_EVENT_NESTING=5 \ + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local push origin && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + ' +done + +test_expect_success 'enable SID advertisement' ' + git -C "$REPO" config transfer.advertiseSID true && + git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true +' + +for PROTO in 0 1 2 +do + test_expect_success "session IDs advertised (fetch v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local fetch origin && + grep \"key\":\"server-sid\" tr2-client-events + ' + + test_expect_success "session IDs advertised (push v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + git -C local pull --no-rebase origin && + GIT_TRACE2_EVENT_NESTING=5 \ + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local push origin && + grep \"key\":\"server-sid\" tr2-client-events + ' +done + +test_done diff --git a/transport.c b/transport.c index 47da955e4f..679a35e7c1 100644 --- a/transport.c +++ b/transport.c @@ -286,6 +286,8 @@ static struct ref *handshake(struct transport *transport, int for_push, struct git_transport_data *data = transport->data; struct ref *refs = NULL; struct packet_reader reader; + int sid_len; + const char *server_sid; connect_setup(transport, for_push); @@ -297,6 +299,8 @@ static struct ref *handshake(struct transport *transport, int for_push, data->version = discover_version(&reader); switch (data->version) { case protocol_v2: + if (server_feature_v2("session-id", &server_sid)) + trace2_data_string("transfer", NULL, "server-sid", server_sid); if (must_list_refs) get_remote_refs(data->fd[1], &reader, &refs, for_push, ref_prefixes, @@ -310,6 +314,12 @@ static struct ref *handshake(struct transport *transport, int for_push, for_push ? REF_NORMAL : 0, &data->extra_have, &data->shallow); + server_sid = server_feature_value("session-id", &sid_len); + if (server_sid) { + char *sid = xstrndup(server_sid, sid_len); + trace2_data_string("transfer", NULL, "server-sid", sid); + free(sid); + } break; case protocol_unknown_version: BUG("unknown protocol version"); From patchwork Wed Nov 11 23:29:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898743 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 C35D0C56202 for ; Thu, 12 Nov 2020 01:32:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E981208B3 for ; Thu, 12 Nov 2020 01:32:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wNtIfUM8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728440AbgKLBce (ORCPT ); Wed, 11 Nov 2020 20:32:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727928AbgKKXbj (ORCPT ); Wed, 11 Nov 2020 18:31:39 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67693C061A4A for ; Wed, 11 Nov 2020 15:29:52 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id l3so2066034ply.6 for ; Wed, 11 Nov 2020 15:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=RjYi5iI4sTMiG22bwX7nd17To2hO8p9K44Ntn5LCF+Q=; b=wNtIfUM8T1WxYJyvqVBBDqjgknrWVQKlEDl7HiOz+z4Rg0F3pXrz3Tkpw8HIbgv6YE 7h1hOEkxpuPMLwyPE+zBMVm/C7jqYA+PhR52hEtJbPGddxdmrnzVnmyj0rZAna2EeVTt 01jWAzOubfHe2XEj793HBLwsJVdyXCU/IXDxKGxAUXmmtS1luAy6lIW4WkjnQDcseM2t fDnJRagJu7PG0i3H1B48ZJD7bFcImwJDOrRjla/eIbc+NVAXm44aoNju4rZ23vnrrlYE o7BMjqjXrx7hh0TWqz4f8q4OHRe/qgpWxJv1rIT4KtCbvEMYhaoyKizlSv4rozfK/Ivs WSyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=RjYi5iI4sTMiG22bwX7nd17To2hO8p9K44Ntn5LCF+Q=; b=TbreUboaVC0AwjIfiDSM8V9hsf9YzMJ5kWFurryEfmV07y6L2TV+uapL5NOLwzJpyO 2AzViWDpycn1v6ueuNqhOi/WdblF5ODiC0MMqiOVDFZV0wWm7PHpIlNTrdCg5BfzuJCW jnmRUgEA17t+P1Pfv6i3to3ntOLPprU+JRu5ycSaWfq1hAHxhU2GJ2SGZt+O/gbeySeg MYGGI6BXsB516DXUNeEYo2HREZ78lAWwEGoxyzWjuc5vAp9Kyscxo7cyzjlNk1m1UHVR znisZSSZJr7x7gv7vX+H7aBfGMggfxxNlAUCfLZNNa315y2Ici7Ppi9gM7LatHlMGeT8 JYVg== X-Gm-Message-State: AOAM533eIMR3QV8wHE4ur/7LlfTYQ7lYhYXGT6aHDJz5pVE6+h10bjKP ijIsVUQFEQlgk6JYO9Pmc2qRswp74T8bEeAVQUL+EZJEqTNTZ4cECC8DLQ6nw0UBG9ORVnmlhFc AnATVBV8ty2UkyOdhBLsDfmPod6IMTqV5aq/gQnOSvW3Gne/L0QhOctgu8Ghprcs= X-Google-Smtp-Source: ABdhPJzLEhGY3MBQZutT8tGyWaOpTc4t4H2CMLh/lu4TSZD1R0vIxArvmm7+q6JHPPcleXHfde4RpNnEwJCweg== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a17:90b:293:: with SMTP id az19mr625130pjb.1.1605137391658; Wed, 11 Nov 2020 15:29:51 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:31 -0800 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 08/11] fetch-pack: advertise session ID in capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the server sent a session-id capability and transfer.advertiseSID is true, advertise fetch-pack's own session ID back to the server. Signed-off-by: Josh Steadmon --- fetch-pack.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fetch-pack.c b/fetch-pack.c index b10c432315..23179b8dd0 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -35,6 +35,7 @@ static int fetch_fsck_objects = -1; static int transfer_fsck_objects = -1; static int agent_supported; static int server_supports_filtering; +static int advertise_sid; static struct shallow_lock shallow_lock; static const char *alternate_shallow_file; static struct strbuf fsck_msg_types = STRBUF_INIT; @@ -326,6 +327,8 @@ static int find_common(struct fetch_negotiator *negotiator, if (deepen_not_ok) strbuf_addstr(&c, " deepen-not"); if (agent_supported) strbuf_addf(&c, " agent=%s", git_user_agent_sanitized()); + if (advertise_sid) + strbuf_addf(&c, " session-id=%s", trace2_session_id()); if (args->filter_options.choice) strbuf_addstr(&c, " filter"); packet_buf_write(&req_buf, "want %s%s\n", remote_hex, c.buf); @@ -979,6 +982,9 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, agent_len, agent_feature); } + if (!server_supports("session-id")) + advertise_sid = 0; + if (server_supports("shallow")) print_verbose(args, _("Server supports %s"), "shallow"); else if (args->depth > 0 || is_repository_shallow(r)) @@ -1191,6 +1197,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out, packet_buf_write(&req_buf, "command=fetch"); if (server_supports_v2("agent", 0)) packet_buf_write(&req_buf, "agent=%s", git_user_agent_sanitized()); + if (advertise_sid && server_supports_v2("session-id", 0)) + packet_buf_write(&req_buf, "session-id=%s", trace2_session_id()); if (args->server_options && args->server_options->nr && server_supports_v2("server-option", 1)) { int i; @@ -1711,6 +1719,7 @@ static void fetch_pack_config(void) git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta); git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects); git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects); + git_config_get_bool("transfer.advertisesid", &advertise_sid); if (!uri_protocols.nr) { char *str; From patchwork Wed Nov 11 23:29:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898741 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 8579FC4742C for ; Thu, 12 Nov 2020 01:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 287CE20809 for ; Thu, 12 Nov 2020 01:32:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XcUD/VZF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728479AbgKLBcp (ORCPT ); Wed, 11 Nov 2020 20:32:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727932AbgKKXbm (ORCPT ); Wed, 11 Nov 2020 18:31:42 -0500 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57332C061A4B for ; Wed, 11 Nov 2020 15:29:54 -0800 (PST) Received: by mail-qt1-x84a.google.com with SMTP id r29so146287qtu.21 for ; Wed, 11 Nov 2020 15:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=EZ1S8he6bsQtn6muv0AwuEDICejKhOzYgoSAnkb6c4g=; b=XcUD/VZF50Ozih5mSO9iJFhgKaY4JYohpfeUiDI7hVXbapEcoFQThQdGrF6Bu11wZO +uXqRIETXfe9NC2ltFekFeR/oOmUu5be0kEPdeH++KI8YN8jWFyIYuFR2is8ts+pXmTB xdoOaLx0LGWzm4KJ/z0mVTID9pdvSdjtEax32xBr/smV0ufEnDXFAkI2IXxW7NQGlNNz QjJyqgdhfkwcpZ1Di7PXx+Idx5ahVfjZwQxnDaJIZrZiOfQTOHTU8Yuf7Wd45xW93IiD jE+/MfXrv0bzE+gGunvJ7a/b61Jsj4nrccOWt6uWZAADKMj9mgjRCgo/vem4dG/fU+HS yOnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=EZ1S8he6bsQtn6muv0AwuEDICejKhOzYgoSAnkb6c4g=; b=TPBsAo5VDETEegkyGmW8bK1Gbxl9LHiXrm9tgv3dgIGYgjSvSeIJ8EXvWVXcWL6dgk 54R6pB2TQX8isrcn1WDjejrUKxaNjNLhUBDDS5uDUf6H5eMeQqqg5nkrO0w5H3z1B9Ca TELzac3KcIu9wXEL+a/6slV1b1E7ohNsf3JmAmv4wLWx7v0nBv0zc0c7KjiirXlLYquN 4L+hX4aeUReohU1iqGtsPGdwuAOl3YBmN395wqrVY6Z6/bqzsm/qYatN3wRGQ3w7fWdT /xl6S99ilEOVVDwn+azcZD+qpRSBqnB53y4t1GhyWY0hlboz7CvPC5pXlbeh1DCqyzW+ hl0Q== X-Gm-Message-State: AOAM533Ey5+K0Mrp/6wkFpB6RWXZ8nYMzAFCJbHkWm9oIawzLg3VXkMD 6eZ9NFRFPlWWLR66IHuRYnUxNXBdODAOd84c6RLXYFd63GQ7EeAFdD/WsMVUSFxiBnRdbRKagiT V+DxbDlOAV0owIUFp9NFFlsbuwOJEGpqpjiDc//EhFWBYSYs6MgTtcEV/Sn1jDeo= X-Google-Smtp-Source: ABdhPJywprrN3NyD9NBsQqcYov8l4UhyNUD1XOb2AkX5wPyf1Ih1kfjHkTbwnXsz0IwlE+TyoUByqwL619zs2g== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a0c:fca7:: with SMTP id h7mr22017304qvq.18.1605137393502; Wed, 11 Nov 2020 15:29:53 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:32 -0800 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 09/11] upload-pack, serve: log received client session ID From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When upload-pack (protocol v0/v1) or a protocol v2 server receives a session-id capability from a client, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon --- serve.c | 4 ++++ t/t5705-session-id-in-capabilities.sh | 18 ++++++++++++------ upload-pack.c | 8 ++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/serve.c b/serve.c index 8c0bb84f37..eec2fe6f29 100644 --- a/serve.c +++ b/serve.c @@ -201,6 +201,7 @@ static int process_request(void) struct packet_reader reader; struct strvec keys = STRVEC_INIT; struct protocol_capability *command = NULL; + const char *client_sid; packet_reader_init(&reader, 0, NULL, 0, PACKET_READ_CHOMP_NEWLINE | @@ -264,6 +265,9 @@ static int process_request(void) check_algorithm(the_repository, &keys); + if (has_capability(&keys, "session-id", &client_sid)) + trace2_data_string("transfer", NULL, "client-sid", client_sid); + command->command(the_repository, &keys, &reader); strvec_clear(&keys); diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh index 9e782f4413..afa2159657 100755 --- a/t/t5705-session-id-in-capabilities.sh +++ b/t/t5705-session-id-in-capabilities.sh @@ -17,11 +17,14 @@ test_expect_success 'setup repos for session ID capability tests' ' for PROTO in 0 1 2 do test_expect_success "session IDs not advertised by default (fetch v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && cp -r "$LOCAL_PRISTINE" local && GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local fetch origin && - test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + git -c protocol.version=$PROTO -C local fetch \ + --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \ + origin && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" && + test -z "$(grep \"key\":\"client-sid\" tr2-server-events)" ' test_expect_success "session IDs not advertised by default (push v${PROTO})" ' @@ -43,11 +46,14 @@ test_expect_success 'enable SID advertisement' ' for PROTO in 0 1 2 do test_expect_success "session IDs advertised (fetch v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && cp -r "$LOCAL_PRISTINE" local && GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local fetch origin && - grep \"key\":\"server-sid\" tr2-client-events + git -c protocol.version=$PROTO -C local fetch \ + --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \ + origin && + grep \"key\":\"server-sid\" tr2-client-events && + grep \"key\":\"client-sid\" tr2-server-events ' test_expect_success "session IDs advertised (push v${PROTO})" ' diff --git a/upload-pack.c b/upload-pack.c index ebb4099268..dcd429dc01 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1058,6 +1058,7 @@ static void receive_needs(struct upload_pack_data *data, const char *features; struct object_id oid_buf; const char *arg; + int feature_len; reset_timeout(data->timeout); if (packet_reader_read(reader) != PACKET_READ_NORMAL) @@ -1110,6 +1111,13 @@ static void receive_needs(struct upload_pack_data *data, parse_feature_request(features, "filter")) data->filter_capability_requested = 1; + arg = parse_feature_value(features, "session-id", &feature_len, NULL); + if (arg) { + char *client_sid = xstrndup(arg, feature_len); + trace2_data_string("transfer", NULL, "client-sid", client_sid); + free(client_sid); + } + o = parse_object(the_repository, &oid_buf); if (!o) { packet_writer_error(&data->writer, From patchwork Wed Nov 11 23:29:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898747 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 AFA81C388F9 for ; Thu, 12 Nov 2020 01:32:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55004208B3 for ; Thu, 12 Nov 2020 01:32:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="a6Pc7ClP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbgKLBci (ORCPT ); Wed, 11 Nov 2020 20:32:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727930AbgKKXbk (ORCPT ); Wed, 11 Nov 2020 18:31:40 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA7EC061A4C for ; Wed, 11 Nov 2020 15:29:56 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id w4so2897709qki.20 for ; Wed, 11 Nov 2020 15:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=i+EAlozu6VIsnZugCRWqOwOMqEq9ylJlCNXpuvidHxE=; b=a6Pc7ClPvpjKan/IknDKt/TKhQuQ2v8kwPMn/cV0MeezbWa4noJGtWdL4U9FSWE6i6 vyA74HabuhFi9FxxnRWWRkmAV3kWrqkkSOdUOMQTYXtooR6mbWCwKtUkm4uVfju5I6DK /KlW8ck0MvrhDXMi6gGi8lhhjHlcYfl34cNulcnPLtOAT09GcmyqhlnlLwWFqXGHM2ZS WHdRppvF3CQl4NrlhBok8rKwvwkTBCj2T2bsIpcVEhQKf9nBEpq59UrZBIQMPIi6BFy5 yVUNOaBSxulp8roKLwFjhJFlt+/RLn1MsfCZBt4TiIWFjhz9w2OzT487mXcqXBYUp+IH PQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=i+EAlozu6VIsnZugCRWqOwOMqEq9ylJlCNXpuvidHxE=; b=FNKXuxjGJSvoX45w6JaKXT+SCiiXA/GaWV4hU89NvXELkgTYmTUaUJ4BU2rNlYJ6NJ u+BrWWkQdGq3LptkodtAQ909GajFTln1U26T5R6YItGNwmu8IQ+fGvWGmk32LiDsPBjS qcovWHwSg8Ii1ck04wY1KO9CrsFnC+0L07gL8hkvduXb5nN1SPTFU9oYeyvm5Sh9xcrb 9AFO/jMXLEhvuf+V64EsMkXOtAvL2SIut2AXCKZ+trx48wPzsEoMiw5uMYxplrRwnVsR Y8paKSPSIQIts52VLATwihhzMF0xCgzwk9zn3dT+Gc47CS1jS1TxJdYSTaDMGT+5toSU C7vQ== X-Gm-Message-State: AOAM530JtJM5SyZriQaCJJ7OUAV8IFiG67D5+LooQWGMa9me5MP3bWsJ sExRDtzSGEJXI29tQn6y4ULafd1qjKpti623lFJCL8SI3ZNpH/+CWpUBFANjOzQhLaIhS8JOql+ 83rGX6pG7aZWcJeRRnVk76y5f+mD/F7Aw2opoAqFZQJFn+gyiHx37v52QAgRlIt0= X-Google-Smtp-Source: ABdhPJzS1HinnbpEYenKnEDXRsTJFP6qfxymZqiTu+4dK85kiEq2JNgSCMc+Me54xkxCPP8MgQLzfrWBHSCf4Q== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:a0c:f951:: with SMTP id i17mr13130324qvo.22.1605137395431; Wed, 11 Nov 2020 15:29:55 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:33 -0800 In-Reply-To: Message-Id: <012949e7da24a9f9b8bb7ac7c098f04a1d35d6f7.1605136908.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 10/11] send-pack: advertise session ID in capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the server sent a session-id capability and transfer.advertiseSID is true, advertise send-pack's own session ID back to the server. Signed-off-by: Josh Steadmon --- send-pack.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/send-pack.c b/send-pack.c index eb4a44270b..bda65c98f9 100644 --- a/send-pack.c +++ b/send-pack.c @@ -424,6 +424,7 @@ int send_pack(struct send_pack_args *args, int use_sideband = 0; int quiet_supported = 0; int agent_supported = 0; + int advertise_sid = 0; int use_atomic = 0; int atomic_supported = 0; int use_push_options = 0; @@ -435,6 +436,8 @@ int send_pack(struct send_pack_args *args, const char *push_cert_nonce = NULL; struct packet_reader reader; + git_config_get_bool("transfer.advertisesid", &advertise_sid); + /* Does the other end support the reporting? */ if (server_supports("report-status-v2")) status_report = 2; @@ -450,6 +453,8 @@ int send_pack(struct send_pack_args *args, quiet_supported = 1; if (server_supports("agent")) agent_supported = 1; + if (!server_supports("session-id")) + advertise_sid = 0; if (server_supports("no-thin")) args->use_thin_pack = 0; if (server_supports("atomic")) @@ -506,6 +511,8 @@ int send_pack(struct send_pack_args *args, strbuf_addf(&cap_buf, " object-format=%s", the_hash_algo->name); if (agent_supported) strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized()); + if (advertise_sid) + strbuf_addf(&cap_buf, " session-id=%s", trace2_session_id()); /* * NEEDSWORK: why does delete-refs have to be so specific to From patchwork Wed Nov 11 23:29:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11898829 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 3A21EC4742C for ; Thu, 12 Nov 2020 01:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6A5920791 for ; Thu, 12 Nov 2020 01:49:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mw0OwTDE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728471AbgKLBcm (ORCPT ); Wed, 11 Nov 2020 20:32:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727931AbgKKXbl (ORCPT ); Wed, 11 Nov 2020 18:31:41 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1DBC061A4D for ; Wed, 11 Nov 2020 15:29:58 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id w6so2534721qvr.15 for ; Wed, 11 Nov 2020 15:29:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=9tzZ/0P2yNnNcgxjKVsU3Tbe+lcp5eVVL3uTZgYDgTU=; b=Mw0OwTDE5pTylcq3yGYjftmxkVuId/E/BPiljiwbu9+9VGPeEKKm7mjUognHWuyq0D dpNIwbFGF0cVTSYS0TiUe+C13fLCYWoionnXQ8KeKfRLSguXgrA9rWTxVR/lvjHeCIcE YFhvzmGwxhIUkqLzX8rSe287kvtVjxChNifa8ATzTsA5hHgznWn+lnVMnz8uIHDq1Ppe 0udS7WNl17NyoBzhfg2LYVMk3yUBGiR68+u9N2OQ6YvxZBi3GqfLbU0oITHaHZZzolvu hzM5Vau6ZG5/zLWJFCSDo+3kHMFU5Ze2sQ3czQXqC4M2A/cqtLrJwH0GoxDxgxuzzol3 e1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=9tzZ/0P2yNnNcgxjKVsU3Tbe+lcp5eVVL3uTZgYDgTU=; b=o7kDDrJyavo6UwQiT+WGcNVVQKJuWdfXaFEYtHf+hELkUQdludMbRWpIVhx4/lZl/m EudQfqIUd/M9dfWTHzFrqh3oFH4q+op1hJfcTfIkVXf9BJWwZWu2eOYmOHJBpr8Uw1Kj 9NnV7OulQURhJXfAWed1kW6tAwp8bXuyvcBCNLyHhMxYcjXXCUnHYCjm1lwdQ9KIIodG jdvf4/slk9Ail3bVvvfQgJrlX15UVLDpokBjB0f4vlVDj0F9lwjEoFKDX8L5IOE2rPFH /kLmyLV8TtUPjxXbR4Pzn1BQuH41HbXhxqenE73i9He2faa0zn/sBBo5Fy3FB+Nlhwl3 a4Gg== X-Gm-Message-State: AOAM533Mv+/4EwQMnpsk4Ss+CQGCXYQhPgTj3clNiM3+sjY6avOZzIQm lU1yKS7r1Dhdcqt+SSW2GL2Nb/X2yhdx0F6NH5VlkxcCQAQb7k0v5TeT9Dc5s4ycL8TtcXHmodv IBu0DWlVbc9+QazRJjNT3cTiqem/N+pPw8VJENoQu0tXwl21eLIF6lqaMzlhoYLA= X-Google-Smtp-Source: ABdhPJzn5FXtaH6l97RCZzgZs97oG2aty8h5GQEDOglJ3Edbyt6hEu7YyC7WSA1bYXL1ydPcBHfOzMyI/QrQFw== Sender: "steadmon via sendgmr" X-Received: from lunarfall.svl.corp.google.com ([2620:15c:2ce:200:1ea0:b8ff:fe74:b4c1]) (user=steadmon job=sendgmr) by 2002:ad4:56f2:: with SMTP id cr18mr17637175qvb.62.1605137397157; Wed, 11 Nov 2020 15:29:57 -0800 (PST) Date: Wed, 11 Nov 2020 15:29:34 -0800 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v3 11/11] receive-pack: log received client session ID From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When receive-pack receives a session-id capability from the client, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon --- builtin/receive-pack.c | 7 +++++++ t/t5705-session-id-in-capabilities.sh | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 6ed498b6c7..deb5f859a9 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2039,6 +2039,7 @@ static struct command *read_head_info(struct packet_reader *reader, if (linelen < reader->pktlen) { const char *feature_list = reader->line + linelen + 1; const char *hash = NULL; + const char *client_sid; int len = 0; if (parse_feature_request(feature_list, "report-status")) report_status = 1; @@ -2061,6 +2062,12 @@ static struct command *read_head_info(struct packet_reader *reader, } if (xstrncmpz(the_hash_algo->name, hash, len)) die("error: unsupported object format '%s'", hash); + client_sid = parse_feature_value(feature_list, "session-id", &len, NULL); + if (client_sid) { + char *sid = xstrndup(client_sid, len); + trace2_data_string("transfer", NULL, "client-sid", client_sid); + free(sid); + } } if (!strcmp(reader->line, "push-cert")) { diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh index afa2159657..f1d189d5bc 100755 --- a/t/t5705-session-id-in-capabilities.sh +++ b/t/t5705-session-id-in-capabilities.sh @@ -28,13 +28,17 @@ do ' test_expect_success "session IDs not advertised by default (push v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && + test_when_finished "git -C local push --delete origin new-branch" && cp -r "$LOCAL_PRISTINE" local && git -C local pull --no-rebase origin && GIT_TRACE2_EVENT_NESTING=5 \ GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local push origin && - test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + git -c protocol.version=$PROTO -C local push \ + --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \ + origin HEAD:new-branch && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" && + test -z "$(grep \"key\":\"client-sid\" tr2-server-events)" ' done @@ -57,13 +61,17 @@ do ' test_expect_success "session IDs advertised (push v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && + test_when_finished "git -C local push --delete origin new-branch" && cp -r "$LOCAL_PRISTINE" local && git -C local pull --no-rebase origin && GIT_TRACE2_EVENT_NESTING=5 \ GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local push origin && - grep \"key\":\"server-sid\" tr2-client-events + git -c protocol.version=$PROTO -C local push \ + --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \ + origin HEAD:new-branch && + grep \"key\":\"server-sid\" tr2-client-events && + grep \"key\":\"client-sid\" tr2-server-events ' done