From patchwork Thu Oct 29 21:32: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: 11867587 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 79EAFC2D0A3 for ; Thu, 29 Oct 2020 21:32:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D80220838 for ; Thu, 29 Oct 2020 21:32:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ah1AMHFv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725980AbgJ2Vcu (ORCPT ); Thu, 29 Oct 2020 17:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgJ2Vcq (ORCPT ); Thu, 29 Oct 2020 17:32:46 -0400 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 A2DBFC0613CF for ; Thu, 29 Oct 2020 14:32:44 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id t13so2576619qvm.14 for ; Thu, 29 Oct 2020 14:32:44 -0700 (PDT) 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=jNpZYdfA2v8kViHg5yyabr+u6XDxnMcDU78apOksAVo=; b=Ah1AMHFvVCLYjJg+rwMZiaS4q7Nb3JNs6whIOZctSmTlRPZR/RfJ/yW98A0yRqe7G/ 7XBqBRIwpMOkaf0dt68CrM/wBTbMI97ro9bfG4QMZAAWYDHpMHJdUuAli9tLzCbruweL my98+rQa6kODALQqeSOPdKUVcv5oJqzsZhzCfboWVlv2RKSP17//ZqKV4QEZeXCCtdkL H4Ixc+XSleoZxnC2ExQmCq+W/tutS9PehZ5GkonJvLUIIshO4o6OUQcdwlSFbc9gFkTO R31MXbV7CurgYbjRkGQXM5iz/f6NnFFJKpMT1cQFDz2zPp8VN9TWNVgYcy/RiDhwymKG vBpg== 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=jNpZYdfA2v8kViHg5yyabr+u6XDxnMcDU78apOksAVo=; b=EnC3QUzDMhtkInCqJ4kWBQv5eK2ZCiq8vbBGwLt/9IbDHrH1Vi2oJcYXqKEfTxS9FS i5G3kzu0oraHLq8lDy+EZr4dI8BcOa06sMyfUPtx20+Ej9ZbcGy1wfQ46BiwVTGFUzts R3o3wiX9GBPWAhfZr5OuoHXE7ZTqm7PVTD7K0g8lMI/IrjEWs4KjrcZT7+zKGLdhOzZZ QlLcQgbpkNIOz/uv1QjCU4KV18ww/jP1Td2haKD7AlUk+QSwjd8d4xVlRApR3LPIXCDj /FZc6b0o0jXsYPhYn1VArohs5Vg1ilj3tp0vlpL0Lnk5fddHPTu5ym2kwfAu2OixAjxT DB9A== X-Gm-Message-State: AOAM530coM0qomI81Zb6KI5/gljlyylfahHxzuX9teO2lXEf6V+INDul ZVRo309EkCe3qVeeUz4eO7ksFUWQeI8vCYrGRax2BHQslJRt08SjOwOzNq2aCSlif/iJQ8UjPnf 5mZB/speGqN3SdmkBCsmM2W2T4VPlt8aEHdznQGCMqstnQCQlYMdVWslc44uXbo0= X-Google-Smtp-Source: ABdhPJy/9ijQgWZCvuWSZpDSNGPYtFlvynBxqBuCPGSL6iEv+KPfwffN9OE6480s9alIUS2EmHublvey2fIwAQ== 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:951:: with SMTP id dn17mr6598451qvb.9.1604007163795; Thu, 29 Oct 2020 14:32:43 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:31 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 01/10] docs: new capability to advertise trace2 SIDs 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 their trace2 session IDs via protocol capabilities. This allows for easier debugging when both client and server logs are available. Signed-off-by: Josh Steadmon --- Documentation/technical/protocol-capabilities.txt | 13 +++++++++++-- Documentation/technical/protocol-v2.txt | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt index ba869a7d36..73d4ee7f27 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 'trace2-sid' +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,12 @@ 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. + +trace2-sid= +----------------------- + +If trace2 tracing is enabled on the server, it may advertise its session ID via +this capability. The client may choose to log the server's session ID in its +trace logs, and advertise its own session ID back to the server for it to log +as well. This allows for easier debugging of remote sessions when both client +and server logs are available. diff --git a/Documentation/technical/protocol-v2.txt b/Documentation/technical/protocol-v2.txt index e597b74da3..a5b9ef04f6 100644 --- a/Documentation/technical/protocol-v2.txt +++ b/Documentation/technical/protocol-v2.txt @@ -492,3 +492,12 @@ 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. + +trace2-sid= +~~~~~~~~~~~~~~~~~~~~~~~ + +If trace2 tracing is enabled on the server, it may advertise its session ID via +this capability. The client may choose to log the server's session ID in its +trace logs, and advertise its own session ID back to the server for it to log +as well. This allows for easier debugging of remote sessions when both client +and server logs are available. From patchwork Thu Oct 29 21:32: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: 11867591 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 BE69FC4741F for ; Thu, 29 Oct 2020 21:32:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CB1F2087E for ; Thu, 29 Oct 2020 21:32:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IWnAhbix" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726796AbgJ2Vcv (ORCPT ); Thu, 29 Oct 2020 17:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbgJ2Vcs (ORCPT ); Thu, 29 Oct 2020 17:32:48 -0400 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 62640C0613D2 for ; Thu, 29 Oct 2020 14:32:46 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id y11so4085156ybm.22 for ; Thu, 29 Oct 2020 14:32:46 -0700 (PDT) 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=Y6MHdBdPxqowdqb96wr1JWEY0Xk0KmoTvIXiei+qIyg=; b=IWnAhbixeb9JjVMYUhLeOOjM7EciW3LjC3dBG8ozpLGTBTRJHglfRf441jjbigkT17 FdGuTC/9DtqSvmGl4aKWcIosO/WMZLR4J7oC8YU0owi3S9dQ5ybnFsSybU8iCOrJplIY 2GSWlBSKXkCBgBeyqi4VIUFpiR1Xmb+SnBa7+jA3ScoKCAUT09p3BntuFB3PTxZlTymH UcuWdJiqGWllD7HZdaLXKIVpxE7XRuwC4KNzYTnTAqab05bFKgJgCX8JZ9fD5pSEtu/y tMX3/MOOYjIaY/Xu7dQtyGtXr84VgE4EzzBL+CYRWpzvbbnC+o1T+YgFUE6pFOhswDQq 21Eg== 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=Y6MHdBdPxqowdqb96wr1JWEY0Xk0KmoTvIXiei+qIyg=; b=nt5H2JbjsJS84u0jKBuz0KeUZpBowPnop5NvLmYmFbiJWIkhpgKqomAVTSfak0oe5s X/2yGYrXdIDbkHpyvSH0VlF70TH8KIymQ04fTkDAbQGHNazeW3NA0cCdFgFcs+XUeLgD uYRbwhuphEELs8CId0bPwUgFkxyePZsGuFtov1bfxhdbAxfJ2NA5jV8W1jHNkRdrbb8u kFhAT3ERtR0hgCHyPhN0+QZ1p29oI3EUBiXK/+njSNZIl42cy0ZXnnPkO99YBVbETbUw gAt3gDWWdqYeY74OV1Ihx2xk+vY0V2CfRQTRJe1nsmPQVUSyOITXOR5ndOvo4kAwsVrL uwPA== X-Gm-Message-State: AOAM5330VZXeL9Qa9bA8YC3xwHI2BxivWZqGYGRvtF8DDx/QaC79tjLi gOZqyLNLMsrWwoFylYCs4jtEkLLKKi28IalkwaecVQyamkKLo5wM/zMMMthIiyssG5lsK9BnJDC OaWp/lY8Ms5G1HUIVjV/MI0t3ePeObv62LJHXoRdGgaI8hUAWXwu2jtVwq5hcJcE= X-Google-Smtp-Source: ABdhPJyb/+1i/Qvl4wukXofh/oTI5RNrOAMuMDW5INKzWMydbt7Wum2SYX+Q9qcCWOeveOUEJRnGKjhPmtuCmQ== 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:bbc4:: with SMTP id c4mr8991472ybk.178.1604007165584; Thu, 29 Oct 2020 14:32:45 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:32 -0700 In-Reply-To: Message-Id: <5d5097b67109554e0763724633810ea616b5e2b2.1604006121.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 02/10] docs: new trace2.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 trace2 session IDs to remote Git clients and servers. Signed-off-by: Josh Steadmon --- Documentation/config/trace2.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/config/trace2.txt b/Documentation/config/trace2.txt index 01d3afd8a8..3f2e3b4425 100644 --- a/Documentation/config/trace2.txt +++ b/Documentation/config/trace2.txt @@ -69,3 +69,7 @@ trace2.maxFiles:: write additional traces if we would exceed this many files. Instead, write a sentinel file that will block further tracing to this directory. Defaults to 0, which disables this check. + +trace2.advertiseSID:: + Boolean. When true, client and server processes will advertise their + trace2 session IDs to their remote counterpart. Defaults to false. From patchwork Thu Oct 29 21:32: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: 11867585 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 86E90C4742C for ; Thu, 29 Oct 2020 21:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2938A20838 for ; Thu, 29 Oct 2020 21:32:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MLSZqHmP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbgJ2Vcw (ORCPT ); Thu, 29 Oct 2020 17:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgJ2Vcu (ORCPT ); Thu, 29 Oct 2020 17:32:50 -0400 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 4DC2AC0613D3 for ; Thu, 29 Oct 2020 14:32:48 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id l23so4094596ybl.23 for ; Thu, 29 Oct 2020 14:32:48 -0700 (PDT) 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=Bg7U+or+Hq+U9HC9U1C4iUziwAjC3NWcXNQcFIlFUVI=; b=MLSZqHmPEhwTojwrkX+kEyFKrt65b0ZSiagETgD5revzVIa1edKE43Al2nWXkFNNLG 3ryCd5q/1Gmu1xJLM5jbL35vdUnrAQEDN5QhPDbwkZSYCR6CeNtgscqHMDqiQDlwSd+P MckswqeRkmXNXWO4kE3DXz1INY9sx00WU8LPI/dFQ2AG65+eDtMqRUyR5m3oHsu64I0k 5IyQ27Yd5E9E3izbCpyoG13zfKJQzPoMS/GeDxTvs7rY4NrjUY2zuQkCI7jTCfjCDmYV DKx+SRJkFl80TIg/qVIwzdx2JSsSxzeBCMwV4QpAGQV6DOVO4LHLxk/71Eu1CqukyOqX 4XpA== 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=Bg7U+or+Hq+U9HC9U1C4iUziwAjC3NWcXNQcFIlFUVI=; b=Sn0NLMyWUCXL2DfuWIn3CiK4rzP9Owbz19ksnDvbskdGr1SHq57VHK5LnaO8CRa1+O vzIuvAaTOnnDg2cHBfis6KhHcX0SFHh85ospA+2SH2qkDEBwTv1GYkvMvEy7BGeE+UHD XpFLPSfyvrB79mtk98CL2ebiLIempqo3LTP3jWwCu4J/XqRFrAGX6Rgde0NNnxHTOdf4 sKbX9DMGj8GEHznk5uUs8E8W6vmUw++X8CSg5+imyzhcIXigSU4TJ7X/sY3J+cx/pzi8 EiZ7wJKf3/yGlyxgzwpIXCDIRVjUxBxoltZc8r+KweIZMFiJTp4oD50MZY7vGKVSm4bq f8VQ== X-Gm-Message-State: AOAM532m3Pr/4wRBtUxYzO74g6478kFg+5eymGHAtELIz5q0PPJoA1kj gJgyDss5oa4aAKUSYulWanbnqpkpV8EnMpIDBVrADKrJUkHcz2sNFP+XngaFhcIf7oAc5LOPv04 j2ZjPO6l4ZJOGaBGcOoAnu/7W2w+vVl/Hk40EBaLzByqYxvZBei4qjYQSL0H+fRw= X-Google-Smtp-Source: ABdhPJyO1s5rIQnfkG7rIqAp0vqQBq9kmxgMaKWGuvX4Dmci1/mgojZZhC8mrRNI5DWgTPkO6YZfoqTsJprqZQ== 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:c7c9:: with SMTP id w192mr9021721ybe.244.1604007167515; Thu, 29 Oct 2020 14:32:47 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:33 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 03/10] upload-pack: advertise trace2 SID in v0 capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When trace2 is enabled and trace2.advertiseSID is true, advertise upload-pack's trace2 session ID via the new trace2-sid capability. Signed-off-by: Josh Steadmon --- upload-pack.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/upload-pack.c b/upload-pack.c index 3b858eb457..862656010c 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -27,6 +27,7 @@ #include "commit-graph.h" #include "commit-reach.h" #include "shallow.h" +#include "trace2/tr2_sid.h" /* Remember to update object flag allocation in object.h */ #define THEY_HAVE (1u << 11) @@ -110,6 +111,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_trace2_sid : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -141,6 +143,7 @@ static void upload_pack_data_init(struct upload_pack_data *data) packet_writer_init(&data->writer, 1); data->keepalive = 5; + data->advertise_trace2_sid = 0; } static void upload_pack_data_clear(struct upload_pack_data *data) @@ -1178,6 +1181,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_trace2_info(struct strbuf *buf, struct upload_pack_data *d) { + if (d->advertise_trace2_sid && trace2_is_enabled()) + strbuf_addf(buf, " trace2-sid=%s", tr2_sid_get()); +} + static int send_ref(const char *refname, const struct object_id *oid, int flag, void *cb_data) { @@ -1193,9 +1201,11 @@ static int send_ref(const char *refname, const struct object_id *oid, if (capabilities) { struct strbuf symref_info = STRBUF_INIT; + struct strbuf trace2_info = 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_trace2_info(&trace2_info, 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 +1215,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" : "", + trace2_info.buf, the_hash_algo->name, git_user_agent_sanitized()); strbuf_release(&symref_info); + strbuf_release(&trace2_info); } else { packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons); } @@ -1299,6 +1311,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("trace2.advertisesid", var)) { + data->advertise_trace2_sid = git_config_bool(var, value); } if (current_config_scope() != CONFIG_SCOPE_LOCAL && From patchwork Thu Oct 29 21:32: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: 11867599 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=-17.6 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, UNWANTED_LANGUAGE_BODY,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 99D29C2D0A3 for ; Thu, 29 Oct 2020 21:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C5192087D for ; Thu, 29 Oct 2020 21:32:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OO3V+O9w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726813AbgJ2Vcx (ORCPT ); Thu, 29 Oct 2020 17:32:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgJ2Vcu (ORCPT ); Thu, 29 Oct 2020 17:32:50 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10839C0613D4 for ; Thu, 29 Oct 2020 14:32:50 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id o11so1599348pgj.21 for ; Thu, 29 Oct 2020 14:32:50 -0700 (PDT) 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=T/+8dSyhHsNX7jrTAMmHIeDrylgrmPZIYhwQz1plHU0=; b=OO3V+O9wDuTvGHWok5Waet6E/3XdaAXUhJDAsZCjSe9jHJHI/0Q+l/sDVCbe1C/swP Zs9T2Ki7We4ehnHJkD9GxAXcXPVjQ3O6qETHDc+7lLPuNHVrwL/fKzuGxyixp7y1sk5n KY/hoQgYpDgTPiLRKh3kyJCD7lDshMu4114VK3f8X2BDEq0IF21xxqvWKrT0V7QSpD3s Z0jsJTYrqpWXcAZR1LPaA77Vka2/1v5BgB6iHzolOmF45KEs3orVRs5GNAlwLrw3ap6B +G7xmE6VTaxHYLNIL7dgFtj1PAqaEhw3gb5rDIAqEKhrUFC4cFqsh7wAtNPmsyFE0DlR XQlQ== 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=T/+8dSyhHsNX7jrTAMmHIeDrylgrmPZIYhwQz1plHU0=; b=H194x4h/czaEzD3zau+X2sPnrUYJL56MLsIrSoEmmHe1W+yr6SzT5Ol6YpJh80F3Yl 3eqGpSZunABggZpe2p1vwlBgj+W4cNHXl7USMv33du+qrDMGItbbPYHvKdX+EsYBw+Yu nrOzpONjYxTTZd9tG56EjpX+i0HmD5SEtb06dehCVVMlIK+/ZvCpE10rk5L8oHjd/ZGg abQMfBBC+cUNKsZm0EMc6ivWSCnxv0Rl3eDJ9Q3WXh5jlacPT5KX2dH9eJCThf1EUDe3 3Dd5kw7eoqsGaAxYGk8ifxtdzsmvJx0XNmreWijF4TQFCbvqLWKCUXzzM41Nn+eWJVjP HRLA== X-Gm-Message-State: AOAM533qWwrTv70BD7H5CphtYbKIRowVGXW6eIGU/Hcl8Ame+fOwAVh3 9qB4fVIWRyJdcnMaU5R2WqCxIoFbdN7XwJ/o91po+2YZiYtOrNWQPYtSuDBywVaHSc/qYwLMrvj V/miwla92+9+8Pb65fPo4jbNJMf92bm0QB5iAMkUldkTls0BydFUEWv1JXTmphS0= X-Google-Smtp-Source: ABdhPJxG7iB53eQxlOxv5Q3nyWzWl1TNJMtz7n9DAqo6vzg9sHNacl2R3QrxsDJmukxPJ3a4AGa+PqfdWZDLEQ== 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:90a:c588:: with SMTP id l8mr1677691pjt.205.1604007169517; Thu, 29 Oct 2020 14:32:49 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:34 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 04/10] receive-pack: advertise trace2 SID in v0 capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When trace2 is enabled and trace2.advertiseSID is true, advertise receive-pack's trace2 session ID via the new trace2-sid capability. Signed-off-by: Josh Steadmon --- builtin/receive-pack.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index bb9909c52e..1ff83c874b 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -29,6 +29,7 @@ #include "commit-reach.h" #include "worktree.h" #include "shallow.h" +#include "trace2/tr2_sid.h" static const char * const receive_pack_usage[] = { N_("git receive-pack "), @@ -54,6 +55,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_trace2_sid; static int unpack_limit = 100; static off_t max_input_size; static int report_status; @@ -248,6 +250,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb) return 0; } + if (strcmp(var, "trace2.advertisesid") == 0) { + advertise_trace2_sid = git_config_bool(var, value); + return 0; + } + return git_default_config(var, value, cb); } @@ -268,6 +275,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_trace2_sid && trace2_is_enabled()) + strbuf_addf(&cap, " trace2-sid=%s", tr2_sid_get()); 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 Thu Oct 29 21:32:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11867589 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 E8B00C4742C for ; Thu, 29 Oct 2020 21:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E5ED20838 for ; Thu, 29 Oct 2020 21:32:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L11w2wNE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgJ2Vcy (ORCPT ); Thu, 29 Oct 2020 17:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgJ2Vcw (ORCPT ); Thu, 29 Oct 2020 17:32:52 -0400 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 23F64C0613CF for ; Thu, 29 Oct 2020 14:32:52 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id l1so2601293qvr.5 for ; Thu, 29 Oct 2020 14:32:52 -0700 (PDT) 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=slkhbjCg3Mgmo4W6YmHzUeRTBQJw9wSMrA+Jj2oqGiY=; b=L11w2wNEYCYAkp7dO4YLIZ8dZ6MOzw9yke4WZo+gcXKM3C4bA6ueG2TeqHyYgM1mo+ CV28R/FDerB0cv5stQzDQBhG2Ztqa4YIN9VXbiQjUr9ZqJpVONSIh58cJ9Ubjs0RJct8 zc0Oh/t/dg3ICz1EGboVh0CSLnZzqPWUmKWivZPiTQ5CNubfoDVkMWzJ6aD+VQiG2KNt r+axOiaF4eaDaWxhl6JHuLWhn21uBpB1Yl3LSECHaBgOnnLagheNWgi43WBDYyfT7wVA 3mU1OjUL3Z6Djca3465rTd5Rv35gi4CXMkrWStdreLZzLgb+g44aAPulhpqsG/0EfWNK TK2w== 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=slkhbjCg3Mgmo4W6YmHzUeRTBQJw9wSMrA+Jj2oqGiY=; b=uGE69ynOZYBGsrF2GCmVzJOnV8+2MACjN/+wVHl3FwoN8uOS/DWRiQY7DvMbnBzliN wrgcsHkFINvHSDySA6y7G4H5gQQ8lLcNTBag3Bxy+lpLJiHxl0/tNAlrcVMQZ2hzHYgl nvbX03IhW+A25uTzXKLohmsmAnUe1Jo24DYu+qQsn3vBKsf10wZORLGBCv4vlUkDy2HC nYIkRUnfi9DOcmYDWSXXtvxEscLBX32AyefBLqwUY5z1EE53gjQwi5aprI7nv6ybmDUi EYezZwrtGfnootabikNZFWsgOEfU75OT7QiCoULlAbe3Bomq90G28FDv4hTHvNRlvz9z q33w== X-Gm-Message-State: AOAM531pExmwFI1vFhcGpX85SIRiLTsYbNf4gBwFShNcrxaFE0VkIQye egmGePJV/nD89cDxlsGLCPVqxYgoYrnv7Mb5ClTcFU5TVCQ5WuZlcaTMREWcdBNvrDU5LbHbeYV zKZgXF0YPZWlIvy+avDpXrQcTG+6UYItiPe3HZ6euBh0rwe41YII9VsfktVyYuLA= X-Google-Smtp-Source: ABdhPJw99/IzssIFhzlhMEcJ0tBupwsjJ4NJrZjLGE8JjILoZZlwuzcPm09Yk6fpRYDmgzN65ETGhzfdnnnm/Q== 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:ba85:: with SMTP id x5mr6465364qvf.7.1604007171263; Thu, 29 Oct 2020 14:32:51 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:35 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 05/10] serve: advertise trace2 SID in v2 capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When trace2 is enabled and trace2.advertiseSID is true, advertise the server's trace2 session ID for all protocol v2 connections via the new trace2-sid capability. Signed-off-by: Josh Steadmon --- serve.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/serve.c b/serve.c index f6341206c4..6ad73d69ab 100644 --- a/serve.c +++ b/serve.c @@ -7,6 +7,9 @@ #include "ls-refs.h" #include "serve.h" #include "upload-pack.h" +#include "trace2/tr2_sid.h" + +static int advertise_trace2_sid; static int always_advertise(struct repository *r, struct strbuf *value) @@ -30,6 +33,15 @@ static int object_format_advertise(struct repository *r, return 1; } +static int trace2_advertise(struct repository *r, struct strbuf *value) +{ + if (!advertise_trace2_sid || !trace2_is_enabled()) + return 0; + if (value) + strbuf_addstr(value, tr2_sid_get()); + return 1; +} + struct protocol_capability { /* * The name of the capability. The server uses this name when @@ -66,6 +78,7 @@ static struct protocol_capability capabilities[] = { { "fetch", upload_pack_advertise, upload_pack_v2 }, { "server-option", always_advertise, NULL }, { "object-format", object_format_advertise, NULL }, + { "trace2-sid", trace2_advertise, NULL }, }; static void advertise_capabilities(void) @@ -261,6 +274,8 @@ static int process_request(void) /* Main serve loop for protocol version 2 */ void serve(struct serve_options *options) { + git_config_get_bool("trace2.advertisesid", &advertise_trace2_sid); + if (options->advertise_capabilities || !options->stateless_rpc) { /* serve by default supports v2 */ packet_write_fmt(1, "version 2\n"); From patchwork Thu Oct 29 21:32:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11867601 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 B4EE7C2D0A3 for ; Thu, 29 Oct 2020 21:32:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56C3B20838 for ; Thu, 29 Oct 2020 21:32:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Scwfs8U9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726809AbgJ2Vc5 (ORCPT ); Thu, 29 Oct 2020 17:32:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgJ2Vcy (ORCPT ); Thu, 29 Oct 2020 17:32:54 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A653C0613D2 for ; Thu, 29 Oct 2020 14:32:54 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id t4so2694104qtd.23 for ; Thu, 29 Oct 2020 14:32:54 -0700 (PDT) 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=BNVRd5T93it6JWEErW0CeCqhga9rTnheZQpf84NSHvg=; b=Scwfs8U9rLRQvCfjCz4CzULg2J/DwDevA/4iF9hvTy+vWpzQMdLUWM1OO5k4u7Ucr1 r6tSzWDPGINsc8ZvOdaRObuaf8c6zqAMexMFvRySCUupJ8Bf4KBC3RQsttYW1uTC+Rl1 v0UX+EZ4SlH4Rx4MgyymHtCU2Zj9hwCjfZ60a/CNNoiL67/D8SfKfQxt0GN2vNrlqc+9 EFKSDtfYvKYTefiGtMULAqeTo6mlM2ahAAKIEoUzR82Jvhex8hjs+89ebRqzdz6lAGfr YW1m73/fl4VFq6iEdxLK4O9ZB9ROX9x8nIKnFMaVsWjuM27JaDDmhsGLplbzjBQObqr7 rASQ== 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=BNVRd5T93it6JWEErW0CeCqhga9rTnheZQpf84NSHvg=; b=K03mo7BTWMgfTjMMIrmfxsuybEHN0lPAkOL7EGjV5yIaCIHChEZ897Kol3kIghg282 Han2o1D2mN0PpflYk5lhV7REihohDCL6sQRAdiope1tYnHj7ZaWWfrqZQaPTsAKi9wSt 81s8N3mBsZwZVAyMHWygSulcqDnrMtHGyvYttr0ZpltF8FcPYzLJD/Ej8KfwFVKwKc/0 WWo3thsxMbnd9jgJsSxCeFh1f2Ci0wO/CizKNnKYYlrHnqDC6GiOLOm05vMyKfmh7NNl 73u3aRm+LYSOENwe72P0ypVKj8Gy+ELApcXX0OoVFXAaFZeIQ2DnqcVJOGPAbHg54V10 cpFw== X-Gm-Message-State: AOAM531AooDWJixEkLdN9FrJ2giVNz2sg5wprCKOPH/U/WBE6TKtGBHc /MTCNj2ZybwRvMSMxB3bo8PJLIG1qOltvZNnpT+42YkzNK9iqS74Gr0ogL3N/0sI5Q5iV5j1EVK FzDSDOsCPw/tPfZVf+G5sKWm0/cDVS57W1b1zJPPzj6AKB6NngiBJcv5sbNGwi40= X-Google-Smtp-Source: ABdhPJzwkkjvoxB8MYf1+Mq8PB5L4XzuYIvY+ZzU1YKd3RmDtJ5W6tF08mRKFh/6mz8MC50X8X0SfrE+VA2zaA== 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:b410:: with SMTP id u16mr6497624qve.52.1604007173253; Thu, 29 Oct 2020 14:32:53 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:36 -0700 In-Reply-To: Message-Id: <1519767eadc396fa8de66c8a60b163f005aac503.1604006121.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 06/10] transport: log received server trace2 SID From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When a client receives a trace2-sid 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-trace2-sid-in-capabilities.sh | 64 +++++++++++++++++++++++++++ transport.c | 10 +++++ 2 files changed, 74 insertions(+) create mode 100755 t/t5705-trace2-sid-in-capabilities.sh diff --git a/t/t5705-trace2-sid-in-capabilities.sh b/t/t5705-trace2-sid-in-capabilities.sh new file mode 100755 index 0000000000..0870e78f7c --- /dev/null +++ b/t/t5705-trace2-sid-in-capabilities.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +test_description='trace2 SID in capabilities' + +. ./test-lib.sh + +REPO="$(pwd)/repo" +LOCAL_PRISTINE="$(pwd)/local_pristine" + +test_expect_success 'setup repos for trace2 SID 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 "trace2 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 "trace2 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 trace2.advertiseSID true && + git -C "$LOCAL_PRISTINE" config trace2.advertiseSID true +' + +for PROTO in 0 1 2 +do + test_expect_success "trace2 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 "trace2 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..d16be597bd 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_trace2_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("trace2-sid", &server_trace2_sid)) + trace2_data_string("trace2", NULL, "server-sid", server_trace2_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_trace2_sid = server_feature_value("trace2-sid", &sid_len); + if (server_trace2_sid) { + char *server_sid = xstrndup(server_trace2_sid, sid_len); + trace2_data_string("trace2", NULL, "server-sid", server_sid); + free(server_sid); + } break; case protocol_unknown_version: BUG("unknown protocol version"); From patchwork Thu Oct 29 21:32:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11867593 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 6C2FBC4742C for ; Thu, 29 Oct 2020 21:33:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1401D20838 for ; Thu, 29 Oct 2020 21:33:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ac7zj8+v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbgJ2Vc7 (ORCPT ); Thu, 29 Oct 2020 17:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbgJ2Vc5 (ORCPT ); Thu, 29 Oct 2020 17:32:57 -0400 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 D249BC0613CF for ; Thu, 29 Oct 2020 14:32:55 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id z11so2906599pln.0 for ; Thu, 29 Oct 2020 14:32:55 -0700 (PDT) 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=5OJKcKg/Rw4YXtrZn7AEtmy0koKjFvf4Oob54ZmmK5E=; b=ac7zj8+v+x4zjaZlYFDZw7dbs/FEDZwnVUegQde9CpvlNztmNWmxqleZSZ1eC9IPey WbyJoMHtuTf9WQQSSKAFzxGImT6vqGdisstSRvJ8ze5Z6V3oaDp2PTqZT1HinsGL9CCE qD1wggiBs1r8mb70iVtFZAJLmX3Ks8rO8gTj6KzEvmSQ4ktzXHqJsi+GDaJ5j0nvnWTH y2NlKVdPoHgmc92GoblAFsz3Z1G2+cezgmDf+TOQoLWzCsz5J9hnAOoOWlsQbQaXuJZj pMuxxQRTMP8ykrgMY+oqfUaXjWG9XtY389ELJe0azgPiyEOCk/ki0IWH+ea55svXU91d h8BA== 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=5OJKcKg/Rw4YXtrZn7AEtmy0koKjFvf4Oob54ZmmK5E=; b=NbvrDWzZwUOSHrXrqwT8nM54TKrlY67OgOvF2wCnFM/LkCRaKR/TxAglptjrpmoWbJ KGOZ+yzssjHhypL9LCFFH3O3S74/7OxOHrw/+wIf2LNj7iLEjYOECaDNVdjokPiKgAYP QfPTVJqsCkNGnWURc+/wDMuIkyCUyo6uIKRnyiuq4MsP3684xZFVleNL6K8F/FD5J7eF q21Nm1Wkih46/pIysKbHL4S+h2no4ZE9XlcjrG4D1pErsyiI2B+hXwKYHkdHx6YavP1j fsxUvtfqxi1Sn/oS2dllv+EDLy/qL137SBEH96M7RvJAj+WnuHbNC7k2se/38LI3CrBv SkVQ== X-Gm-Message-State: AOAM532tsq/XXziF87y9Byi55/DZ1M22ti02ZbfI7gXCJqfybaF3Zf1g h69C/+m5Y3S1dmq9R5nKl8eSlwbCHjrYyp6hzLvlAYkQjK2isnbhXHbyrhDDVPtOSrLGCBsYJ/Z dsxjgAGQGwctD16kh7/URx9ZGSPaxm/IqKttBr8Tn/GMQLuNEzZclH7+wkuAIPKA= X-Google-Smtp-Source: ABdhPJzAfvgW8nKeF+ZUH/SVFVqpbL6daRlXyaJ23hB+mdb5STdYQP33Z0xZkiBlX59Y7vyuoClfXmVrerWDrQ== 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:a63:ec57:: with SMTP id r23mr5845982pgj.257.1604007175262; Thu, 29 Oct 2020 14:32:55 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:37 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 07/10] fetch-pack: advertise trace2 SID in capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When trace2 is enabled, the server sent a trace2-sid capability, and trace2.advertiseSID is true, advertise fetch-pack's own session ID back to the server. Signed-off-by: Josh Steadmon --- fetch-pack.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fetch-pack.c b/fetch-pack.c index b10c432315..40065fc7dd 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -23,6 +23,7 @@ #include "fetch-negotiator.h" #include "fsck.h" #include "shallow.h" +#include "trace2/tr2_sid.h" static int transfer_unpack_limit = -1; static int fetch_unpack_limit = -1; @@ -35,6 +36,8 @@ static int fetch_fsck_objects = -1; static int transfer_fsck_objects = -1; static int agent_supported; static int server_supports_filtering; +static int server_sent_trace2_sid; +static int advertise_trace2_sid; static struct shallow_lock shallow_lock; static const char *alternate_shallow_file; static struct strbuf fsck_msg_types = STRBUF_INIT; @@ -326,6 +329,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_trace2_sid && server_sent_trace2_sid && trace2_is_enabled()) + strbuf_addf(&c, " trace2-sid=%s", tr2_sid_get()); if (args->filter_options.choice) strbuf_addstr(&c, " filter"); packet_buf_write(&req_buf, "want %s%s\n", remote_hex, c.buf); @@ -979,6 +984,9 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, agent_len, agent_feature); } + if (server_supports("trace2-sid")) + server_sent_trace2_sid = 1; + if (server_supports("shallow")) print_verbose(args, _("Server supports %s"), "shallow"); else if (args->depth > 0 || is_repository_shallow(r)) @@ -1191,6 +1199,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_trace2_sid && server_supports_v2("trace2-sid", 0) && trace2_is_enabled()) + packet_buf_write(&req_buf, "trace2-sid=%s", tr2_sid_get()); if (args->server_options && args->server_options->nr && server_supports_v2("server-option", 1)) { int i; @@ -1711,6 +1721,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("trace2.advertisesid", &advertise_trace2_sid); if (!uri_protocols.nr) { char *str; From patchwork Thu Oct 29 21:32:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11867597 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 D62BFC2D0A3 for ; Thu, 29 Oct 2020 21:33:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75F7D2087D for ; Thu, 29 Oct 2020 21:33:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mWZRIEQO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbgJ2VdB (ORCPT ); Thu, 29 Oct 2020 17:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgJ2Vc6 (ORCPT ); Thu, 29 Oct 2020 17:32:58 -0400 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 0666AC0613CF for ; Thu, 29 Oct 2020 14:32:58 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b189so4150019ybh.5 for ; Thu, 29 Oct 2020 14:32:57 -0700 (PDT) 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=sY1kQGMYTG9GfYW35zzHamF/+N+T18FfArRU2GQ7NA0=; b=mWZRIEQOKCUnfIjD9eeigziLxYDK0FMXbh+J1GQSJnfL22QBWGHMIp6TV50QpDzHOc 1Yiu+afMNVRsgt/v0gFxzfIrh2lcb5DWrKZMUrn9kKI3faCSCrHPc/D1WGwqhDpHd4ek oY8DeUjGuoC9bgnkAvMLWL8u2ScmflrtiLRUHepFwRWmhFqyBXnv5YRjYaBUVxUlNINL DHPzG8snXFTVcelOYnE1YH9/7uPoK/vipgeKQiRf9XqONGXS5ZboAWyrmRXBQsmeCdsJ mAC3C+AMaI7XCQnS+CZ98bKdUabizuRppy/7VEq/L2ZDiS+bWvMHMoHnaCpvGiSW+Yk+ g+0g== 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=sY1kQGMYTG9GfYW35zzHamF/+N+T18FfArRU2GQ7NA0=; b=WzxCrgymSGzzR65kkd12PDmjUOI0quYmy46tu+d1tO9A+pL9t3oLl7ttFbSPJmZEf/ EuWHB8yrnlPwOb4Du7liycWrQSB0bHeGOgVh4sjYQBjdGUClqdOSt3kRUwCsNiV1enYb vbBn7gyOsR1SNRU26dlFjDuGzFtgQd15RY4EVjIVU2ZfGrxCCzHtsr48uHmyj8qqG0LI V6ssLy6TlyJrm47GIUqPfCx1pQqKyXkT1f38AdfTCGyvJYh4lUiefUgv9dOm+TM/hQpu 7r0FNrnhGagkHghY+p0WnIIxzZ07yjKedz+zfyfMS70tVof/MpVISdfnDaWpPrK1Q/Yx O/tA== X-Gm-Message-State: AOAM532Dk6vX2Uv5y9aWz6T4jXWGfZ4hWXDVbeiDscu+vSZZAQprcITO onbv+dq9afalkpdIIsgjkWpiRVkX+nhzr//YbLa2FaXI9l/56m6/vTBkmfD8AeRy9Y9I8oxJS9W RA12Q1U9/DSRq03yq259A/wyRIXA6JCFYqZkWKI51NTD1ZcrSVwxW4OjEPMZqDeo= X-Google-Smtp-Source: ABdhPJxJUKvO22uIj2hnHY4RB7rcSSufHWkSPU1pu5O/Y3ZSgYFLzp/fCUzyxMnHS/7245yCr1dd5WvmQBAfFQ== 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:a5b:286:: with SMTP id x6mr8886550ybl.78.1604007177195; Thu, 29 Oct 2020 14:32:57 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:38 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 08/10] upload-pack, serve: log received client trace2 SID 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 trace2-sid capability from a client, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon --- serve.c | 4 ++++ t/t5705-trace2-sid-in-capabilities.sh | 19 +++++++++++++------ upload-pack.c | 7 +++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/serve.c b/serve.c index 6ad73d69ab..6a4f0c64a9 100644 --- a/serve.c +++ b/serve.c @@ -202,6 +202,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 | @@ -265,6 +266,9 @@ static int process_request(void) check_algorithm(the_repository, &keys); + if (has_capability(&keys, "trace2-sid", &client_sid)) + trace2_data_string("trace2", NULL, "client-sid", client_sid); + command->command(the_repository, &keys, &reader); strvec_clear(&keys); diff --git a/t/t5705-trace2-sid-in-capabilities.sh b/t/t5705-trace2-sid-in-capabilities.sh index 0870e78f7c..3fad9462d3 100755 --- a/t/t5705-trace2-sid-in-capabilities.sh +++ b/t/t5705-trace2-sid-in-capabilities.sh @@ -17,11 +17,14 @@ test_expect_success 'setup repos for trace2 SID capability tests' ' for PROTO in 0 1 2 do test_expect_success "trace2 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 "trace2 session IDs not advertised by default (push v${PROTO})" ' @@ -43,11 +46,15 @@ test_expect_success 'enable SID advertisement' ' for PROTO in 0 1 2 do test_expect_success "trace2 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 -C local config trace2.advertiseSID true && 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 "trace2 session IDs advertised (push v${PROTO})" ' diff --git a/upload-pack.c b/upload-pack.c index 862656010c..4238e06510 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1059,6 +1059,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,12 @@ static void receive_needs(struct upload_pack_data *data, if (data->allow_filter && parse_feature_request(features, "filter")) data->filter_capability_requested = 1; + if ((arg = parse_feature_value(features, "trace2-sid", &feature_len, 0))) + { + char *client_sid = xstrndup(arg, feature_len); + trace2_data_string("trace2", NULL, "client-sid", client_sid); + free(client_sid); + } o = parse_object(the_repository, &oid_buf); if (!o) { From patchwork Thu Oct 29 21:32:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11867595 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 DEB93C55178 for ; Thu, 29 Oct 2020 21:33:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8266D20838 for ; Thu, 29 Oct 2020 21:33:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="duBzQK5s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgJ2VdD (ORCPT ); Thu, 29 Oct 2020 17:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbgJ2VdA (ORCPT ); Thu, 29 Oct 2020 17:33:00 -0400 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 DDB9CC0613CF for ; Thu, 29 Oct 2020 14:32:59 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id w1so2606260qvv.0 for ; Thu, 29 Oct 2020 14:32:59 -0700 (PDT) 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=TaxtZIDKG0UaCUh6/70wcULTQ2q/dbfS96QH9RZ+jR0=; b=duBzQK5sicZJ+eY5fG34Eph4FL7h2Tg3njRgAyPXS3CfeSkfjV5fZWXhjXNnVeM2n5 EODXMqnfguGR42vdNpNn3qc/CojnnZDLLlwc9pw6u8lLoXW58WwKJtkv7GakB8dnZZJF n/e1DybO6b6vuctwv/pSNpEhM1Htz+irITdT8UDEu2aEJ3SwpKh5TKjlvRhrlsl75nms SlayzgLsSPGIz5kTIfgEk7VJ7Rj2ZY7mlEjVOAlpbwhJok5m7cA3A4tNY4y83EN3aQ86 9FdICcmf+ecGxiAhp2SJ94kp1yfxOzD2xdAWAXJkQLGhB3kIUr3VTxTrvKtL5P2hMzz+ BTFQ== 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=TaxtZIDKG0UaCUh6/70wcULTQ2q/dbfS96QH9RZ+jR0=; b=tbE6fka5nhDWT77hP7QGKgA3Vzwj0V2b+Qu2hhEwFKir1CfxLX2vgpu1aFIdmTbreo SyqunQnEC1rd9BPKQBN9PcS4wi4nLw9hT0XzZF0ASsrUImt8rN0WvjmM3p1S4iUv/FWP fwwYGpgugKEzi1UDc9HDiK/gA+zVogWw+QT14UiZj6vgN+o8k59HVOOZ878e8pJBpjMG kOefVJP3rDeS9PeqeEuEdqNfH/tvqXnaaa8Ud1a+v//6xlnktnEgv6pZFhSt5m8bT+7s Oju8a60GQpcqJEyrQTQKBVh3Kutrs/utrcWD9xmHN5tY+JO+Jl7WsHzdbfEvlJipjxdL ebcA== X-Gm-Message-State: AOAM531mcAKRWaM62lTWcSbv3QrxZe/e/d4a1TdB6wK2XjYlAlFhpd/F tCQd1Qtu57cn52BO1HORSQ/vBaejhr7dy7peHCW0ekKuV897fQyljjQO2cFQIAQBl5zFXgdDGat pLfS9DcTGtY6eQ+KyKeGyrmrBbWH1hfXwMenPJJGR6YmWV3PMER5wWJ04w80X2WM= X-Google-Smtp-Source: ABdhPJyslGSzZaJIS+HpC3+0EBwioA9DF4lw9trZoYWM97aRlrL/JIMCkoaSMiUJ0fahBrcDVD4T8UEQ/g+28A== 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:f64b:: with SMTP id s11mr6232946qvm.47.1604007179069; Thu, 29 Oct 2020 14:32:59 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:39 -0700 In-Reply-To: Message-Id: <609958bd1a308c63cc1d5a526b6206745f390a45.1604006121.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 09/10] send-pack: advertise trace2 SID in capabilities From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When trace2 is enabled, the server sent a trace2-sid capability, and trace2.advertiseSID is true, advertise send-pack's own session ID back to the server. Signed-off-by: Josh Steadmon --- send-pack.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/send-pack.c b/send-pack.c index eb4a44270b..56c6740e65 100644 --- a/send-pack.c +++ b/send-pack.c @@ -16,6 +16,7 @@ #include "gpg-interface.h" #include "cache.h" #include "shallow.h" +#include "trace2/tr2_sid.h" int option_parse_push_signed(const struct option *opt, const char *arg, int unset) @@ -424,6 +425,8 @@ int send_pack(struct send_pack_args *args, int use_sideband = 0; int quiet_supported = 0; int agent_supported = 0; + int server_sent_trace2_sid = 0; + int advertise_trace2_sid = 0; int use_atomic = 0; int atomic_supported = 0; int use_push_options = 0; @@ -435,6 +438,8 @@ int send_pack(struct send_pack_args *args, const char *push_cert_nonce = NULL; struct packet_reader reader; + git_config_get_bool("trace2.advertisesid", &advertise_trace2_sid); + /* Does the other end support the reporting? */ if (server_supports("report-status-v2")) status_report = 2; @@ -450,6 +455,8 @@ int send_pack(struct send_pack_args *args, quiet_supported = 1; if (server_supports("agent")) agent_supported = 1; + if (server_supports("trace2-sid")) + server_sent_trace2_sid = 1; if (server_supports("no-thin")) args->use_thin_pack = 0; if (server_supports("atomic")) @@ -506,6 +513,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_trace2_sid && server_sent_trace2_sid && trace2_is_enabled()) + strbuf_addf(&cap_buf, " trace2-sid=%s", tr2_sid_get()); /* * NEEDSWORK: why does delete-refs have to be so specific to From patchwork Thu Oct 29 21:32:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11867603 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 60EB2C2D0A3 for ; Thu, 29 Oct 2020 21:33:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08AA520838 for ; Thu, 29 Oct 2020 21:33:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JlPUYXAi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbgJ2VdF (ORCPT ); Thu, 29 Oct 2020 17:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbgJ2VdD (ORCPT ); Thu, 29 Oct 2020 17:33:03 -0400 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 AF7E1C0613D2 for ; Thu, 29 Oct 2020 14:33:01 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id z9so2566626qvo.20 for ; Thu, 29 Oct 2020 14:33:01 -0700 (PDT) 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=B2VBxg7Va4v7/Oqd7E2X7HjmghjR5vMiOw/hZdmldgA=; b=JlPUYXAiYuamia5+Sp1ph3q2KWD6KE7BNwvHxQPGoaWwYdBHVJAMrAHEEpVqAFUya/ Y/5UDGlFGfcqKyFrAAy/OVYcs3VqT9LJ4m1kTU91yaMXBCGzAKNDZkt4OMCPzPVkOt7I MvOwZa/3uGJp6xtyrjfFwPGWisdXRiyJX+5kWe/PTUWC2oJ4SbZdQ+6uhk9UmATn1Z2F kZU4BErUXFxfzCWKGVuD8aH8V+3STBO0TFACplrPEidh0Z5PqlAi+r/DoiScYcaF4ysh HFMMUt7UloXxP1H83fVezQjrqzSHDw9iErQasPuXJZtZmkU170v2y1Lbz+TwHdObC5bP oIGw== 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=B2VBxg7Va4v7/Oqd7E2X7HjmghjR5vMiOw/hZdmldgA=; b=WZ9Ld7yIjz7qDIZfGKGBG2GUzJM6YmiFDwnlPjHs0kBZtM9hI2rrR65i1eoHBIqQFP icHo4kuF5MfDOR/IfsJqiRXICiv+9eMWnONshv4DDTAFdYs4CUV+kxPuhb/cyHjY9VgF CZ6Yr0B5Xs3nxGbN+nFFrdp+CmniO4I9bE+6/KTMU8IPNCqwdraF33N6sWSjLPdaEw8M 64p6+Y+O0gOM+ffZ+elMvkAXrtx78iZ9fCZE52vK7wR8RmJkbJkkxlL+a8wX/RwtHQSz V3IW9ulyxHdKNTm1yYFTCBP8Zvl+cpvq/DhPd7kZvrti6AyJY36HtqmMks6VZrfyIgxS NAQQ== X-Gm-Message-State: AOAM532xwHbHb5wew+/fNNcbgzhxV8zeanrc11z7TZO7Kzd2/aW+yCG9 haAvJ0Un+5pHCZDSpyb6Ngzfnw6P34l0cSquB8TsrpBKl1y/l+6/SpGxNqS2nNTn1e79wq/VXnH KfnVJYDFJRQDpleiJFKiX3gLS81ahHhxAhi4hkKBfvPlQhFcXavQkF8mI42Cza44= X-Google-Smtp-Source: ABdhPJzhZBFctdDg/dy7kRMJuK5PzjUbseCPyyPP76BxSgn+noO6c4dQKb8jXT/cHUiAGCS7btbZ+Dtm7COA0A== 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:d42:: with SMTP id 2mr6576671qvr.29.1604007180822; Thu, 29 Oct 2020 14:33:00 -0700 (PDT) Date: Thu, 29 Oct 2020 14:32:40 -0700 In-Reply-To: Message-Id: <3bc412fc390afd0af1d6700609f899064b6d2844.1604006121.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 10/10] receive-pack: log received client trace2 SID From: Josh Steadmon To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When receive-pack receives a trace2-sid 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-trace2-sid-in-capabilities.sh | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 1ff83c874b..34199e4933 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2040,6 +2040,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_trace2_sid; int len = 0; if (parse_feature_request(feature_list, "report-status")) report_status = 1; @@ -2062,6 +2063,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_trace2_sid = parse_feature_value(feature_list, "trace2-sid", &len, NULL); + if (client_trace2_sid) { + char *client_sid = xstrndup(client_trace2_sid, len); + trace2_data_string("trace2", NULL, "client-sid", client_sid); + free(client_sid); + } } if (!strcmp(reader->line, "push-cert")) { diff --git a/t/t5705-trace2-sid-in-capabilities.sh b/t/t5705-trace2-sid-in-capabilities.sh index 3fad9462d3..15f78cb7d2 100755 --- a/t/t5705-trace2-sid-in-capabilities.sh +++ b/t/t5705-trace2-sid-in-capabilities.sh @@ -28,13 +28,17 @@ do ' test_expect_success "trace2 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 @@ -58,13 +62,17 @@ do ' test_expect_success "trace2 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