From patchwork Tue Jun 20 16:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3793254vqr; Tue, 20 Jun 2023 09:36:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KL5tJgH7N25dZonMj+o6fc/rTpj/5dKModUzfRtH2EKhutc+U8evg3+wCiCER/upejIu6 X-Received: by 2002:a92:c143:0:b0:33d:6988:bfea with SMTP id b3-20020a92c143000000b0033d6988bfeamr9047617ilh.21.1687278986265; Tue, 20 Jun 2023 09:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687278986; cv=none; d=google.com; s=arc-20160816; b=IUANFJiWOSLZdr5at4Khnf5wNFZi34m73fWmCHC2oUTF1UGo5pENKJqHXeTRrGX8Am 95hTkOSU2OVi3mnLLPd++bDO2g0M6LKAEKQIGbRW1s1nlbpLFYtCwEQT32gh626WOqSR RlLWuH5j6yDoTts6iadUwTH0BBtbaQabUZSqO1p7dlOqndxWrvDy48Rrw1im8+Gbi2M1 69uYZQd3GDS8TdmBVXCiticP9ar/mGMAD/jQy3+OBU3Fw9Fsbanf3m4vWYW6LjoW3/h6 CfihOqArUC+RmxloX9Schl+/hcjBrCP0xoDArncY39GRA/orIYq5heKdkjsSwVAxB/kv /qPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=nuFBhZfTmDJAZacaxfhCFb1KYqHWsBgcdKKRWfbEWN0=; b=vPLcNhRKfIycRWTLRoKdcsEVs9YJDPXZcIrt80NbgL4AiBTj8RvB7PxoqxmB7iYAtO CI841CL02Vn/Ed7rPprpe3zlg+R6HOToqPMKLYL8QzjWaJVCbQhqcQYRKjZpMhLSxevb 1c4EZzE6FgpalnBjnVSAj2m7m6kan0UbiIxICMzQ18sy6VgAd21qEQwPPE4zeyjf8l5u sCC+bK6oECllG1YvcxFrzQgomkXgBofw+vVI0ZqVT/9hop9QOX4ZywngK0aVYd0u1jiM CBS+/+fHq0xCa4buSA2SYfiMAoSPg0bQNMV5NBYzUXfS0pMP1vf8LJDiA0/eiK7IsJxG hS+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="ip/UV28r"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv4-20020a632e04000000b005537cbc032esi218062pgb.206.2023.06.20.09.36.10; Tue, 20 Jun 2023 09:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="ip/UV28r"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231805AbjFTQan (ORCPT + 99 others); Tue, 20 Jun 2023 12:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjFTQae (ORCPT ); Tue, 20 Jun 2023 12:30:34 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F5F100 for ; Tue, 20 Jun 2023 09:30:32 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f90a7325f6so36782495e9.3 for ; Tue, 20 Jun 2023 09:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278630; x=1689870630; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nuFBhZfTmDJAZacaxfhCFb1KYqHWsBgcdKKRWfbEWN0=; b=ip/UV28rDJqQq2BbB/nmsQmvnh2Q9zK8z8PFY81lxd7V1Mp0OmCLkR5dQ8H83H4uhZ VI8ckfYU2yXe6RSJCQz+MCdkZsL6N3cT4j17mft3T53HJvQ0Md1HiTP8yi3/41nw/Ubw x8oAdzNUHUe24z96gHGyFJekPUO8N/UHQt5MYgV0O20aeH9Uh/+rHBfA+w36waFbuJL+ SDUwRyoK0uWUi23fSE8RYOQOz0dtMZm3EvEztDKcQXvHTaMDvT+El3PlOQR1iIfbC2gJ f0OgPnCEtmtxTO07XHeJHpr3GDzMakX4XfsgIBszqdxHzit1a1MYNOWbtktAL69L8k4u RMmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278630; x=1689870630; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nuFBhZfTmDJAZacaxfhCFb1KYqHWsBgcdKKRWfbEWN0=; b=e6q3Flo2iq2RBlRU0P83P3G/XhvzoNnadBvSjBsEc3j77vsDsvcIAhkwQcifYogDDC hi0zC3mAjVf65CP7cNqIBKxfWecqRNgA2nJws/Muu3qTa7jEd6tULR2L+mcnPqWsd/Yi 4ZghLdy/oxSvj9wmTj2IB38LNhhmPU+cdupnVdbfZg/ocH72V4Jq6jWg03x19rGDO3+p 90C1CqGHyjfPKvsdiVpTwTjEyKzZTK0IjUfr4MwS/vxvmTODIzVZTTuAWWWAGzkv+YR/ aRPCTBZyLWBhfzNIGRmBUUC39uBXtNfo3cpG4OYJeAwVX2i1bs7bYEkyMbndjL8La939 F4yA== X-Gm-Message-State: AC+VfDw7lJBtdj+3Zr5uR2FwROHXyU1qNlGXGWIxzhx97VCY50hAp2ly mlYSZq5+lWnGEVG0vnVzmRJ8pg== X-Received: by 2002:a7b:c8c4:0:b0:3f9:1bf:8704 with SMTP id f4-20020a7bc8c4000000b003f901bf8704mr10812613wml.6.1687278630558; Tue, 20 Jun 2023 09:30:30 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:30 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:14 +0200 Subject: [PATCH net-next 1/9] mptcp: move snd_una update earlier for fallback socket MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-1-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1667; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=94K2vUxW+7CjklZmQNEYvAmRJRbL9yuf+LzZZuN1/V0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQku48aOBuwK+NuGg9HyBhX9pfXbAc1tubB5 Yc83bLntdGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c38dEADNumynfgX24GcZFzNWCG0Qhbm504OpQxp+hEc7nrxy40pgn5aH/p3l0vib6cd4m6sRuSb T24Xb37opZtyyKTsQU3/LmZGX/B5mAQVrHEVMFBn7jelpeXuM4UYykGjouWcfM6uwjZ3j8S70tg 31RxltoM0qpCJcjGtyZmWmhfCyknfkJ5O+LVErxwClw2a7L91BK/B+2p649JB5UfbxXFMePNAVZ X3S9n4B7IiGutxOgQ6px3ccNX72b/Anh8UNDcltzcNOUw+/tQ8YWIRyFF+DddOpK3l9kfQS8a71 LcFntLBQEIn0EDEz25F3TUnaGCd80A1ODkQZ9w2LUrHdPGPtWhKg1y9QZFOOHzMmZRVhwColYx5 TrUrxl6jgkrAXbMhBTGH1DVoTXlQdUSXRIBt8eGeC2Ly9K1QEV6f60qMhhL60EP/GIwecfehDBc LxcYov8h8S2GTceEytuzZrxZ9BujoyriEvQm+70LK0fUQ6SY+GLWPjbvbjYkFmJcU+yCAzt4qDv m8B/MPxPdqGUuGeEUTrVvJx99HIo8SaL1ZhysQW3vBF2TqthQc4srngJSuysYdMPMAky6QgL+nj u7CeM3NcZpmMCGNVI4WlbUXrbwgBbgk4JoJr67yoKsobiawHsa51vJ0ukaHl+PUmQZ+kMPwY0fg NqIfBLe0thFxcCA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769240250075537877?= X-GMAIL-MSGID: =?utf-8?q?1769240250075537877?= From: Paolo Abeni That will avoid an unneeded conditional in both the fast-path and in the fallback case and will simplify a bit the next patch. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/options.c | 6 ++++++ net/mptcp/protocol.c | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 8a8083207be4..4bdcd2b326bd 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1119,6 +1119,12 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mptcp_data_lock(subflow->conn); if (sk_stream_memory_free(sk)) __mptcp_check_push(subflow->conn, sk); + + /* on fallback we just need to ignore the msk-level snd_una, as + * this is really plain TCP + */ + msk->snd_una = READ_ONCE(msk->snd_nxt); + __mptcp_data_acked(subflow->conn); mptcp_data_unlock(subflow->conn); return true; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 992b89c75631..9c756d675d4d 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1004,12 +1004,6 @@ static void __mptcp_clean_una(struct sock *sk) struct mptcp_data_frag *dtmp, *dfrag; u64 snd_una; - /* on fallback we just need to ignore snd_una, as this is really - * plain TCP - */ - if (__mptcp_check_fallback(msk)) - msk->snd_una = READ_ONCE(msk->snd_nxt); - snd_una = msk->snd_una; list_for_each_entry_safe(dfrag, dtmp, &msk->rtx_queue, list) { if (after64(dfrag->data_seq + dfrag->data_len, snd_una)) From patchwork Tue Jun 20 16:30:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3793138vqr; Tue, 20 Jun 2023 09:36:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qWD3S36D969t+pvTLh9oPrCtFfoMZgw/YWhLk6QcndDhMkosgQoCnnn3yxrd/WDj5GBrd X-Received: by 2002:a17:902:c944:b0:1b0:6038:2982 with SMTP id i4-20020a170902c94400b001b060382982mr14738925pla.41.1687278974033; Tue, 20 Jun 2023 09:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687278974; cv=none; d=google.com; s=arc-20160816; b=EvlIjZINQtWwJiuNGqEIr3jXJKnf27tO13NIi4Je8g7oVMGKRmWTvT43ERhCbbTi5u aGWRtHk0vMEJ9xLm+PSKqf6tGoSPWMDPSdwlz7LeiA16Zjq0v/vr0eJdmnmHa9MrO9w+ ySADIsjh1vWqSAae6Q5obm1cWmQbxnKRGCae4L3IzWFkkabj8ak7Tge4NuhbuUUIxyWq 9aUJUv1R5SIFDR0eXfE0JKFvWjV+mfb08KZtsQ0+/nCfeF3mhXS48Q40XNPTPPMM5THc A5wHM/tuSvc0q+i9WZk5U9RdxY+e9S66zZHAjgFnpu/vC1BFqm0CTchftfLaJie85AId 2u7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=vJz7gc9qda31VHXjDefMsfEDaiQ4htT8RdWcVphxCr4=; b=HBrPdgl8bFYcAPE4vkMIcUKQKsTdnj5YLINnEw6yOIGVAkJh9c7OWP8lTv4eySwCyp 6JQJZjHntC608JhNBkHXvbcqfwyQDppiig/w5tXOdeGprrO2s6Hl0q/7Que//eP2szlJ 1WyNUKRl1ed59aM5VYZdfJZSjQDqZtYaXfVAww3TS5CW6IJQrUP4qbyKIOJnK/pmn4ri BSek3YOKZHvBK0HeAIZkcrMRWtB0TwgcCOIo3uzXNZGzRXY8D62YBQpP2+M3oy1Ly+sb 3O5UZjq8x/xbfVhcoJNtTqzhwgFqHZMvFDxAMjKCqT8S/MYcIEuPf6sVRhDKmyArfCK5 +mVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=ODYzJL4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170902dac900b001b3cd3e0533si2388690plx.607.2023.06.20.09.35.57; Tue, 20 Jun 2023 09:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=ODYzJL4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbjFTQaz (ORCPT + 99 others); Tue, 20 Jun 2023 12:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjFTQaf (ORCPT ); Tue, 20 Jun 2023 12:30:35 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B581727 for ; Tue, 20 Jun 2023 09:30:33 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31114b46d62so5039937f8f.3 for ; Tue, 20 Jun 2023 09:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278631; x=1689870631; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vJz7gc9qda31VHXjDefMsfEDaiQ4htT8RdWcVphxCr4=; b=ODYzJL4gVUO1EpHWCSWimvWMopKKyuUlSDRM5rPLsobNH4XVlut8xZPed/Q2XB+1kN DiTnIu+y/JHoy6f1ect3tID33me5wAK530s60PkMNMRD1ZT29cvragk24fxIQeijHMPm mOKSTUxoCDrxCl87wMwT86SC5p6+gAOyRQg8NzT8itV6M0ADSamiI5ymRC2nkIL14kSD ESJIv70qLPPEnYQDhhnVuFIDehuw1D8Swaq6vWsMs6SMOKJVGtJMtBIC+1w3qcdRfoQS iwDK1H8pEyxIti1rUcvjGzdMMi47utOEz2l78KcPNoOmZTvw8Vbe04i47duhCbIyQ0sI bHbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278631; x=1689870631; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vJz7gc9qda31VHXjDefMsfEDaiQ4htT8RdWcVphxCr4=; b=hn4/akEhCSOBSTWDkdl1mRiWA2EWJSINX4pY/UQ+6Am2mLmoLhcwkLcMnoj51NgX23 vZtJraEyW6JMLbl8JSJDihscv8S9pY50LDhOHwCy+okEAJoer5X3jdYxQ1cN3ZrU9l1V C2Evpn0C76s3JwL01q0zeOY2exNlqC9wX6fTQaXjbBGgbMC4fCohGnN3WfD9Q65wf/ki Q8Yxb5HP2lfjctZgC00hH3qBU7IIosrpaP9lQV6LU9FfUkKkTbyr5j5wfOJj9qU6wN3e +VPbNXtbj1GEoYGJE8QgLlsaI83GXzYMKE18lVlSd7Tf+/NwIwW93GCG5zJhaaS6pRas YlzQ== X-Gm-Message-State: AC+VfDwshmjg9b5MrGN3yQ3QtnUjKjhugi+uuqoFJcQGu4IauhVQLVAt ctL1DvyFK0cbYmJ1/+bCYXAaSw== X-Received: by 2002:adf:fb46:0:b0:30f:ce4f:5675 with SMTP id c6-20020adffb46000000b0030fce4f5675mr10459362wrs.59.1687278631410; Tue, 20 Jun 2023 09:30:31 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:31 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:15 +0200 Subject: [PATCH net-next 2/9] mptcp: track some aggregate data counters MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-2-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7362; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=upisP8a+EDNWOLxXxnQUGW2DGQfmLWpgv+/AMNVeHqE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQkH/1p+gLAtiVZp9VjseP1QF8bWYv0VmWkW cabfETQsXSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c2peEADTY6hCVD8xKcI/5YaG/DgVrXB1rs0esDuLgahOtKEtAwgxWdptY5SyKSSv4jZcFqKp5QN m5z1HDwZaDKWli+zFoPquF77pFcqOG1G3uB0je6uESsDRXS50UCIM5XrP2qmjIFagOYxt//4yMm 1oIZiGcsCLCoHaMltOeCyDal4/T4SzA6oLgH01GSr1qLZ/uaAjCsJyNRjdqo4dZ2rwNQX7uU5m3 adfXMMBW+jJJL6WWyB7EZHnFhWYxjifsk3gbdrSikTvye0H+PhuhX/1Nl/K66C79Zqvqor2l1gG j7EQBdVlH1NqVcYN9+h2uNod/N8gxU+ulfWDInr7yq3vLunQPlq53IVnknA78dPb4gDvSaXwTFv URxO7eVw4iA1LykdweJ2fP5pvKPTzy/QxzCSzQpaaIZq23GA/it1yptAWHqnficbXMhfyMGuK3m TAJeBNjJpVv6KALjiVQ4zyjjfMgZP+CXgPiI4tDwLrEB908DkfHtYFdFgSNyCsLxbINdNVodmPk pOO8vlyhSI1gI7M9P2jWXfqCu8mEmxgWY3Pz50A3ZcA6lZjnH5h6gSOaV8vRg1hSFvEHsjXy9s1 W+Q3lsMw//nI8eBfgfOAHNz0bh2/Rdm4FXmfRzyLZJtMFnRRvIVC2KeDhY/lQLf8RX3DE41EJzS QC7V3z4QLuQEbMw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769240237515652096?= X-GMAIL-MSGID: =?utf-8?q?1769240237515652096?= From: Paolo Abeni Currently there are no data transfer counters accounting for all the subflows used by a given MPTCP socket. The user-space can compute such figures aggregating the subflow info, but that is inaccurate if any subflow is closed before the MPTCP socket itself. Add the new counters in the MPTCP socket itself and expose them via the existing diag and sockopt. While touching mptcp_diag_fill_info(), acquire the relevant locks before fetching the msk data, to ensure better data consistency Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/385 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- include/uapi/linux/mptcp.h | 5 +++++ net/mptcp/options.c | 10 ++++++++-- net/mptcp/protocol.c | 11 ++++++++++- net/mptcp/protocol.h | 4 ++++ net/mptcp/sockopt.c | 25 ++++++++++++++++++++----- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 32af2d278cb4..a124be6ebbba 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -123,6 +123,11 @@ struct mptcp_info { __u8 mptcpi_local_addr_used; __u8 mptcpi_local_addr_max; __u8 mptcpi_csum_enabled; + __u32 mptcpi_retransmits; + __u64 mptcpi_bytes_retrans; + __u64 mptcpi_bytes_sent; + __u64 mptcpi_bytes_received; + __u64 mptcpi_bytes_acked; }; /* diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 4bdcd2b326bd..c254accb14de 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1026,6 +1026,12 @@ u64 __mptcp_expand_seq(u64 old_seq, u64 cur_seq) return cur_seq; } +static void __mptcp_snd_una_update(struct mptcp_sock *msk, u64 new_snd_una) +{ + msk->bytes_acked += new_snd_una - msk->snd_una; + msk->snd_una = new_snd_una; +} + static void ack_update_msk(struct mptcp_sock *msk, struct sock *ssk, struct mptcp_options_received *mp_opt) @@ -1057,7 +1063,7 @@ static void ack_update_msk(struct mptcp_sock *msk, __mptcp_check_push(sk, ssk); if (after64(new_snd_una, old_snd_una)) { - msk->snd_una = new_snd_una; + __mptcp_snd_una_update(msk, new_snd_una); __mptcp_data_acked(sk); } mptcp_data_unlock(sk); @@ -1123,7 +1129,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) /* on fallback we just need to ignore the msk-level snd_una, as * this is really plain TCP */ - msk->snd_una = READ_ONCE(msk->snd_nxt); + __mptcp_snd_una_update(msk, READ_ONCE(msk->snd_nxt)); __mptcp_data_acked(subflow->conn); mptcp_data_unlock(subflow->conn); diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 9c756d675d4d..d5b8e488bce1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -377,6 +377,7 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, if (MPTCP_SKB_CB(skb)->map_seq == msk->ack_seq) { /* in sequence */ + msk->bytes_received += copy_len; WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len); tail = skb_peek_tail(&sk->sk_receive_queue); if (tail && mptcp_try_coalesce(sk, tail, skb)) @@ -760,6 +761,7 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk) MPTCP_SKB_CB(skb)->map_seq += delta; __skb_queue_tail(&sk->sk_receive_queue, skb); } + msk->bytes_received += end_seq - msk->ack_seq; msk->ack_seq = end_seq; moved = true; } @@ -1531,8 +1533,10 @@ static void mptcp_update_post_push(struct mptcp_sock *msk, * that has been handed to the subflow for transmission * and skip update in case it was old dfrag. */ - if (likely(after64(snd_nxt_new, msk->snd_nxt))) + if (likely(after64(snd_nxt_new, msk->snd_nxt))) { + msk->bytes_sent += snd_nxt_new - msk->snd_nxt; msk->snd_nxt = snd_nxt_new; + } } void mptcp_check_and_set_pending(struct sock *sk) @@ -2590,6 +2594,7 @@ static void __mptcp_retrans(struct sock *sk) } if (copied) { dfrag->already_sent = max(dfrag->already_sent, info.sent); + msk->bytes_retrans += copied; tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle, info.size_goal); WRITE_ONCE(msk->allow_infinite_fallback, false); @@ -3102,6 +3107,10 @@ static int mptcp_disconnect(struct sock *sk, int flags) WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk))); mptcp_pm_data_reset(msk); mptcp_ca_reset(sk); + msk->bytes_acked = 0; + msk->bytes_received = 0; + msk->bytes_sent = 0; + msk->bytes_retrans = 0; WRITE_ONCE(sk->sk_shutdown, 0); sk_error_report(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 47b46602870e..27adfcc5aaa2 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -262,10 +262,13 @@ struct mptcp_sock { u64 local_key; u64 remote_key; u64 write_seq; + u64 bytes_sent; u64 snd_nxt; + u64 bytes_received; u64 ack_seq; atomic64_t rcv_wnd_sent; u64 rcv_data_fin_seq; + u64 bytes_retrans; int rmem_fwd_alloc; struct sock *last_snd; int snd_burst; @@ -274,6 +277,7 @@ struct mptcp_sock { * recovery related fields are under data_lock * protection */ + u64 bytes_acked; u64 snd_una; u64 wnd_end; unsigned long timer_ival; diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index e172a5848b0d..fa5055d5b029 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -889,7 +889,9 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) { + struct sock *sk = (struct sock *)msk; u32 flags = 0; + bool slow; memset(info, 0, sizeof(*info)); @@ -898,6 +900,9 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) info->mptcpi_add_addr_accepted = READ_ONCE(msk->pm.add_addr_accepted); info->mptcpi_local_addr_used = READ_ONCE(msk->pm.local_addr_used); + if (inet_sk_state_load(sk) == TCP_LISTEN) + return; + /* The following limits only make sense for the in-kernel PM */ if (mptcp_pm_is_kernel(msk)) { info->mptcpi_subflows_max = @@ -915,11 +920,21 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) if (READ_ONCE(msk->can_ack)) flags |= MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED; info->mptcpi_flags = flags; - info->mptcpi_token = READ_ONCE(msk->token); - info->mptcpi_write_seq = READ_ONCE(msk->write_seq); - info->mptcpi_snd_una = READ_ONCE(msk->snd_una); - info->mptcpi_rcv_nxt = READ_ONCE(msk->ack_seq); - info->mptcpi_csum_enabled = READ_ONCE(msk->csum_enabled); + mptcp_data_lock(sk); + info->mptcpi_snd_una = msk->snd_una; + info->mptcpi_rcv_nxt = msk->ack_seq; + info->mptcpi_bytes_acked = msk->bytes_acked; + mptcp_data_unlock(sk); + + slow = lock_sock_fast(sk); + info->mptcpi_csum_enabled = msk->csum_enabled; + info->mptcpi_token = msk->token; + info->mptcpi_write_seq = msk->write_seq; + info->mptcpi_retransmits = inet_csk(sk)->icsk_retransmits; + info->mptcpi_bytes_sent = msk->bytes_sent; + info->mptcpi_bytes_received = msk->bytes_received; + info->mptcpi_bytes_retrans = msk->bytes_retrans; + unlock_sock_fast(sk, slow); } EXPORT_SYMBOL_GPL(mptcp_diag_fill_info); From patchwork Tue Jun 20 16:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110616 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3801268vqr; Tue, 20 Jun 2023 09:50:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7lEshB1zD0xtvdMnFKY1ap+gKnzaT8mzLxkHadZmlLjn/oBWEq361G7kjw4AJBlw5iLiW4 X-Received: by 2002:a9d:4806:0:b0:6b5:90fa:ae0b with SMTP id c6-20020a9d4806000000b006b590faae0bmr2715708otf.20.1687279843519; Tue, 20 Jun 2023 09:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687279843; cv=none; d=google.com; s=arc-20160816; b=IvnSwxYkGcEsihleXTATR7uhtowharh9UMfUyGlVtdX2twFE5xdvryFA03QQ8burIo hLMZnX2dTYmb8bJfQlK1lb0hCxhicVRJvd4q+NU7j5qSGq2OYmlVldeTNVMoW5hHh2B5 Y9I69Ox7ORpea21uLjbC/CJzgIHBD0JfbcID+7USqfEmv1MAMDtV3A5T74cPPasQ/dnZ FL0YJ97Q7EjICg0HTLcyv3sYZUN2z0iYxvSEAoxt4z8I7sb3VnHHQ79RsmuxPdxXpJlB hakIrVgCqHJeKI6KwdCsol+B7otghpeSrqmom827Hf5bPCr2qZVlF4OyxOhG7Pv3GiSc zZsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Cw8TzJlxypWM9F2CnTaH65ECFFJEZ73AOXC4Ef09ORA=; b=vB6da/VULn/bBnOZleI3tAL4rxojU5oqONMLyYhEARrOFj//w95ARWzrpI3YT4oyTm aQwDXGMUgnqniqqAybKemZ9V+02A4sivSPmS24aKls7Lc2/pQDP6WnxiECseEjIcXPUm pBbHiX6LnjcWroVc+nbSx+t2X9vv5aJwBMoq69+YA/PyCf6j5SwrUO+gOxK82e1KbsyX MDDFtAbReWlAlcMcz7xMBf9BU/ycTrAEBwPYnM7GVkoQqDgzCyDW+6rpG9YzIxo/vxd9 8NOwb4dLhKIqqR7OxigOQIoS2oDatv+BK50N5T1Ir6f+MtVlSkBLIBRE/uobsWUCVRyc VaNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=QcAMgkg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a637443000000b0054294720d55si1992644pgn.262.2023.06.20.09.50.28; Tue, 20 Jun 2023 09:50:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=QcAMgkg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjFTQas (ORCPT + 99 others); Tue, 20 Jun 2023 12:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjFTQaf (ORCPT ); Tue, 20 Jun 2023 12:30:35 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1764F171B for ; Tue, 20 Jun 2023 09:30:34 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4f8792d2e86so1888411e87.1 for ; Tue, 20 Jun 2023 09:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278632; x=1689870632; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Cw8TzJlxypWM9F2CnTaH65ECFFJEZ73AOXC4Ef09ORA=; b=QcAMgkg8/jg7Gy8GFpuSNkXkN+MJwhSVyJbLQ8QwajO+7hXdCKYEDpx50cPyheT/Tg AMmkUKfuDDpuHWqQRYGjFEG67Apn67LgvsmU8IrpXJUZhEg5UYuC19aeePyVqjmTNKWm B/Y0NgHPpkhjbiY1m0ST2LLBB3yntYBWO6MvF6rLBQ7J8AaW8uZHuZuDtsPUsr168j9o OTx1Ic6ajJdPdHWYOeBAHTLMPbuhIZdQG/rlbHQKOedyivOTZF9x/x/TgG3SlTw9ULrL Lr3MW1WBMbLDd9OcqUrtyttN9IS4dA18XSEMKacaSQ9EmNa79W2MKEkN8h/Hv+nQ3rZH 1P9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278632; x=1689870632; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cw8TzJlxypWM9F2CnTaH65ECFFJEZ73AOXC4Ef09ORA=; b=EWxxS2cY/NT9cMJg4i5ec94HN6VmxqGwJs3XXok1ozHzuajsOt/9eqfXCt7P30VMNv M07pMsfDkEU4NGipefYPpuG7qgVsGrZ4cMM5oAGZUTsQBAOYqtb7WqCZuVGEegDFOkZy FtD4Sx+g6y7dkshZ4lYMrPi29SGFcuYY+L2cLTCHz1MzrAdl/mrw/HTv2MA8OzRZcSoM codEIa3SAti6eJ+H0GAgQUc8e6NwOE8662+vFIs+oni4JyfNGdFOO/6NA6nV3YUFrODH YuJfRnP0Te4iDTNb0ig/bpoX6WxbFOJ7HMOcD4ZPmNSu810gxi7qH3hlA2tCcl7cQUwq FNeQ== X-Gm-Message-State: AC+VfDw8K08u/iPIjDPRw7xnYEY4dl+q2zKtCv1PbliAk15TTi8CimsO S4yOZKkyVnGCS2ZDiwnyQMcnRA== X-Received: by 2002:a19:790a:0:b0:4f8:4aee:1fac with SMTP id u10-20020a19790a000000b004f84aee1facmr6705566lfc.66.1687278632308; Tue, 20 Jun 2023 09:30:32 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:32 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:16 +0200 Subject: [PATCH net-next 3/9] selftests: mptcp: explicitly tests aggregate counters MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-3-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2670; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=awLfDurrvmULc5mmvI7zYCGtlKgibsGn03vwIgEXgPU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQkNw66cmfj8X9pRKxH2KmDjBcVKt+1v/+/V 8wgWjbyPeaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c5T9EACORdoVd2YO2KSq2pVhigyD8nklAEeomq+4ClUtAKDlmsWepku3TDU9HUdfKZY3+/xS9Gd 6TsIuSyaCUZoXB7GsxfWVhEjHYN7DWRv8SQVUvZSKh3KyGs3WhmgCEnAziBwjYngtN1HGoZe1fS SANm+lOtfC/dHW30zTYJ05s7MOzI/yTikjcfLcA8qTmmz8GQtCGnXJSQXpU6TknWpadRhQhJQdO y5/a9MzHzrFDNG5bWkKDWAzuRyHnvUlpdB+kao1OOddIZy7LVrpOMIs3AhDhvxXqTtU3HWiK2E3 GXp0JhCseKSp4+qHIumE8c4X4cfddOpmK2z2TKCTA8R64C2NfjKVlkggJuhEiTLGxBqEm+erTip 7YQ8Z0inrZXSXIvQbf5EPn/UlKM0Nr88ZjwtZ2iiuMtSI9Sje2RIQUEwQ1nP7c2IkWog5M5zcYR vRnjN+RbLDI7Al11wflb55k+svnaXeDp7MtmxSS5Xz292Lb2zOnXohigONn4l6zENmVjPqOtFuO E3KgErhG9tlZpj6byt8+9tNPfikSnz6f3g85WBsS5NHVHVmKJBiPi3JrSzvRqyjGUGGLVLdx+zM Pjbi0RlAQraCkIy9l54yoEAvtvKZvxeTefEMLl8TpQ9XFVqH4SaZ5Tr0nRSk+WVw1ffAYGZBVxg j1+Esu5eL1JmZbQ== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769241149115306165?= X-GMAIL-MSGID: =?utf-8?q?1769241149115306165?= From: Paolo Abeni Update the existing sockopt test-case to do some basic checks on the newly added counters. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/385 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c index b35148edbf02..5ee710b30f10 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -51,6 +51,11 @@ struct mptcp_info { __u8 mptcpi_local_addr_used; __u8 mptcpi_local_addr_max; __u8 mptcpi_csum_enabled; + __u32 mptcpi_retransmits; + __u64 mptcpi_bytes_retrans; + __u64 mptcpi_bytes_sent; + __u64 mptcpi_bytes_received; + __u64 mptcpi_bytes_acked; }; struct mptcp_subflow_data { @@ -83,8 +88,10 @@ struct mptcp_subflow_addrs { struct so_state { struct mptcp_info mi; + struct mptcp_info last_sample; uint64_t mptcpi_rcv_delta; uint64_t tcpi_rcv_delta; + bool pkt_stats_avail; }; #ifndef MIN @@ -322,8 +329,9 @@ static void do_getsockopt_mptcp_info(struct so_state *s, int fd, size_t w) if (ret < 0) die_perror("getsockopt MPTCP_INFO"); - assert(olen == sizeof(i)); + s->pkt_stats_avail = olen >= sizeof(i); + s->last_sample = i; if (s->mi.mptcpi_write_seq == 0) s->mi = i; @@ -562,6 +570,23 @@ static void process_one_client(int fd, int pipefd) do_getsockopts(&s, fd, ret, ret2); if (s.mptcpi_rcv_delta != (uint64_t)ret + 1) xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret); + + /* be nice when running on top of older kernel */ + if (s.pkt_stats_avail) { + if (s.last_sample.mptcpi_bytes_sent != ret2) + xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64, + s.last_sample.mptcpi_bytes_sent, ret2, + s.last_sample.mptcpi_bytes_sent - ret2); + if (s.last_sample.mptcpi_bytes_received != ret) + xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64, + s.last_sample.mptcpi_bytes_received, ret, + s.last_sample.mptcpi_bytes_received - ret); + if (s.last_sample.mptcpi_bytes_acked != ret) + xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64, + s.last_sample.mptcpi_bytes_acked, ret2, + s.last_sample.mptcpi_bytes_acked - ret2); + } + close(fd); } From patchwork Tue Jun 20 16:30:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3791882vqr; Tue, 20 Jun 2023 09:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fvlz8XeIYY2hBaCO53ClLFymqvQm6l2ZBmfO4WKpdXyq/B98aqFD3rUx89zWoQShaBbTz X-Received: by 2002:a17:90b:818:b0:25e:7f55:d40b with SMTP id bk24-20020a17090b081800b0025e7f55d40bmr12890981pjb.5.1687278843749; Tue, 20 Jun 2023 09:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687278843; cv=none; d=google.com; s=arc-20160816; b=reRqUrq86lH0DRBoyu6eHj5kNyLQxDKpoenXT/t1rI8CIe/A/bquqla4IJiC4lm3oH 2cseiaoZZq0nbdiqqpOen97YPKGYTxmpSmlkJbPJLoR+ORSXHl2n0ZWK+PoqCBwvZz46 Sjv3kgTIL4qHMjVTpsEbqOJgaviIKDArv1Uk7Ndce9+nkU3Wq6I5OsCgkpZoLwBloSGp Je5ZLdy57KAJj6YXpMxUbK0L/1OCvaHk0b+AnahoVcC835LdzkzhZyvt0UZNqmXMJbvy w5UPsZp9yTCOxl3Lw8pm85dfBaeBuRrjEu0TT0m4H7CdC+J0odFfpZ8i7ZurTzYBqAZx tqRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Y5fndaTCsd6PT3EC5CenLHxKgWi3IwLDVemBAF0BQ88=; b=AKVJvtHHEB2vuXIjfptKvOHae3jcw7d3pZZtPpyzO2S5UYHYxOkj5twQ+XLt338B4d p1PJNcE3dQXjJU9oKkYFnDf3vw56GrR31I/ysaVKemb1l+FrgW4HmxzXKPRDQ8Z36mcR 6Dq8F1qg4cy+AQzkio8vs6qmgP7enM6vHa7ipYptvN/cSOKnjRw1Fu6L4s8ftXcyYt3E 9Gs8hxaStd+v/XNr4fttPntZKgc0iPg0k0KX1zCT0ip1WQ/eAYTCqTjnvyu05wHpA1EB DQaokH3W9vC+XISgszgzYFGZ7WWrsRdG1tFP7v879pOpRfHic0W9mUz0EnjFK90ZoIBV Sb7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=q2pBLSUb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b24-20020a17090acc1800b0025945de4165si2255230pju.141.2023.06.20.09.33.50; Tue, 20 Jun 2023 09:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=q2pBLSUb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232273AbjFTQbj (ORCPT + 99 others); Tue, 20 Jun 2023 12:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbjFTQbC (ORCPT ); Tue, 20 Jun 2023 12:31:02 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 923C11988 for ; Tue, 20 Jun 2023 09:30:46 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b4769a2ee5so39431881fa.3 for ; Tue, 20 Jun 2023 09:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278645; x=1689870645; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Y5fndaTCsd6PT3EC5CenLHxKgWi3IwLDVemBAF0BQ88=; b=q2pBLSUbQwOIyGXJDJyXH9/APPG9JILYehEXGBtVrdehCMIJQPYgN1soPTaGiDFYHS 2mfEDoPWghy8TFmNAz91ws5zmqwlioRYdYCDUVMOFKonC4lxNmTDd2NkWzAep9oYlzt5 YuWq8yVVutuR3SfYpgVNj31q1qF86yxjYmLsGcTw8shdtz7JU9N+7b9Zl4ef6ZmN1auK FQYUXWbcajWN8SM3HwktNLfzgQR9BhFS4TBv/H7Oc3wTfA6NyNPDTcPb6xDL4lktLVIP SLeJ5EISwcVGkuFtdmi3aDeGYS2iIj6a3w3ALDAvdFlHu9JO+CqsKVg3A1kVhJ1iM+e3 Lj+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278645; x=1689870645; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y5fndaTCsd6PT3EC5CenLHxKgWi3IwLDVemBAF0BQ88=; b=MVrCTtTlsWcXJ28tM6F8GfplEUYC2jrRCGMvmKH7xxcgVtzulWCQDw4gKAI51/SyVm W3MEs2IOjv6GX2AT921xjEpxGKuKSqke+/Lwga/HFbEMbC3eGT/cu+0JQVPkqr0+ojim r1FDcVsa6Dra/Xk/G+MAHPXvkepaFHsL05sjf+1i7N0VNorplBPjICHjj9npUvH1zwak +DwpqVgRs6gCPoFXDdfF1Oy3rAk5v9nmBtq3JIWTgsKuGSGuN1gJuS2b1TclLcC54zcR LcafkemQ5Uu+F2kU7cZcT8OLHH7rIhSWhbLjCccwUZ15FxqDaWxzlgLsOtgNLBRFayZH rLVQ== X-Gm-Message-State: AC+VfDyzaKPhbwzhDACn9UPVyfwn6n+Osc0yH64pI1YaejnFEKyd7+NU Pm8/oTt7h5ej1DrCl5Vf4PMwfInO+bSODgsCR8vHkQ== X-Received: by 2002:a1c:7414:0:b0:3f9:255:aab0 with SMTP id p20-20020a1c7414000000b003f90255aab0mr8922405wmc.33.1687278633284; Tue, 20 Jun 2023 09:30:33 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:32 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:17 +0200 Subject: [PATCH net-next 4/9] mptcp: add subflow unique id MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-4-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3775; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=arhNlpVEVZPz8Fi4+q8mXxwbbZV5QcuvJY8S/g9f9XA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQkgn2sc06kST4kKlmP4E7In1OMaQElhhTM4 Fde2HhL51mJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c/TQEACChbctUUGpqNfqW7iKVf+cU20e8LkBV1ZtMd6NiWC8DiGFhVEFnTZo4b1pSwIbkcXugaL vFBH0+2gIGX1ysKArkv2a7oUb/4/ntrFkOcjWbwnzu9Dp6eA28rFpOVvUOU9ITkgGXjhGbGd0El q0QMf2i3trX5RHaPFP+CaOp8Yu77P9XOtXCXZjwzSpejgvRGbaJaaFfla6UuFWbfRKyV2rKN2sF Y5mFjp1Wed1II9x5RgPaqZ/Y096n434wErAQ0jDVJwK4csKybpt+Y/yx0UHGVNAF/I+tz0TNzg9 Mz0WFp5RalQirX4o3ZPAxn++1b3JZYYPTb69IWM4RIYgENeJtvKxAy4RjkIe/h6KhH2vaROo7kw +sLZdWVIzc/NvHbuNyxcmU2s9c3ZPHpG2zsQ4M4+imcHYml0paN3o5bcWcalhu0S6DzoDFRSn+n PVFas9c+67YA+eqbjfZvz1p60itXmeL9ZEhrGs5O4Fxg+RVnNkXlrq0oD0y43Accyr5xBC9CvXB Bg4z3LXYNMSXXi0CJFmP/WEG1KpPTrFfH09kAIfUYpqUQ2zA5mhNg44JoMVUUt6u5n3OHxI+HUG jwCgWyRUO1JgQF/TsTu22wSyUgIf2RtHZFulWVdqFHpXWx2pRezZy+PMfTkNIlGUv8aHsN+zyi6 UXlaa8sn3vedMow== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769240100718960638?= X-GMAIL-MSGID: =?utf-8?q?1769240100718960638?= From: Paolo Abeni The user-space need to properly account the data received/sent by individual subflows. When additional subflows are created and/or closed during the MPTCP socket lifetime, the information currently exposed via MPTCP_TCPINFO are not enough: subflows are identified only by the sequential position inside the info dumps, and that will change with the above mentioned events. To solve the above problem, this patch introduces a new subflow identifier that is unique inside the given MPTCP socket scope. The initial subflow get the id 1 and the other subflows get incremental values at join time. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/388 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 6 ++++++ net/mptcp/protocol.h | 5 ++++- net/mptcp/subflow.c | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d5b8e488bce1..4ebd6e9aa949 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -96,6 +96,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) list_add(&subflow->node, &msk->conn_list); sock_hold(ssock->sk); subflow->request_mptcp = 1; + subflow->subflow_id = msk->subflow_id++; /* This is the first subflow, always with id 0 */ subflow->local_id_valid = 1; @@ -847,6 +848,7 @@ static bool __mptcp_finish_join(struct mptcp_sock *msk, struct sock *ssk) if (sk->sk_socket && !ssk->sk_socket) mptcp_sock_graft(ssk, sk->sk_socket); + mptcp_subflow_ctx(ssk)->subflow_id = msk->subflow_id++; mptcp_sockopt_sync_locked(msk, ssk); mptcp_subflow_joined(msk, ssk); return true; @@ -2732,6 +2734,7 @@ static int __mptcp_init_sock(struct sock *sk) WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk))); WRITE_ONCE(msk->allow_infinite_fallback, true); msk->recovery = false; + msk->subflow_id = 1; mptcp_pm_data_init(msk); @@ -3160,6 +3163,9 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq; + /* passive msk is created after the first/MPC subflow */ + msk->subflow_id = 2; + sock_reset_flag(nsk, SOCK_RCU_FREE); security_inet_csk_clone(nsk, req); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 27adfcc5aaa2..bb4cacd92778 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -323,7 +323,8 @@ struct mptcp_sock { u64 rtt_us; /* last maximum rtt of subflows */ } rcvq_space; - u32 setsockopt_seq; + u32 subflow_id; + u32 setsockopt_seq; char ca_name[TCP_CA_NAME_MAX]; struct mptcp_sock *dl_next; }; @@ -504,6 +505,8 @@ struct mptcp_subflow_context { u8 reset_reason:4; u8 stale_count; + u32 subflow_id; + long delegated_status; unsigned long fail_tout; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 4688daa6b38b..222dfcdadf2e 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -819,6 +819,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, if (!ctx->conn) goto fallback; + ctx->subflow_id = 1; owner = mptcp_sk(ctx->conn); mptcp_pm_new_connection(owner, child, 1); @@ -1574,6 +1575,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, subflow->remote_id = remote_id; subflow->request_join = 1; subflow->request_bkup = !!(flags & MPTCP_PM_ADDR_FLAG_BACKUP); + subflow->subflow_id = msk->subflow_id++; mptcp_info2sockaddr(remote, &addr, ssk->sk_family); sock_hold(ssk); From patchwork Tue Jun 20 16:30:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3807007vqr; Tue, 20 Jun 2023 10:01:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48QzplCq//ghXiq6WDrwr1wqpeQMkTCzt37Js+AvVRbY5qTdWEFaeUqYLOKn9NQn6/PIaw X-Received: by 2002:a05:6a20:7486:b0:10c:2cb7:29b1 with SMTP id p6-20020a056a20748600b0010c2cb729b1mr13142952pzd.51.1687280467738; Tue, 20 Jun 2023 10:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687280467; cv=none; d=google.com; s=arc-20160816; b=joUmtZ5elFsMAhM4GmhVer7EiIgebuK9CSKF3evf0baoIN/scJ0tyK7N3Gb2CB99iP hYiBIbLywn4ebMYXYiAzEgs2nPUSSgZKf9z5sfztmAgHoTejnU4QIyAU9N7gKhF4B/d4 ADwyTm9xE+s8a0/K2BGO0Y6yteHeLWzVnMSzLRzFUNQigI3+G4X/KvU7KJ3TjX77eQQh xSqhgAM0qdKs4EITc7D0Vdncfg8a12qojDsbjl/rTSBWjZTLJTuZ4ZPUsO6roaSGFbm5 KSAvFolA5bmfdyHlouSeUhPDoIunK3bHGaSwDlSDh6p6xsfMxougsXcykjsgj0K2p8Rp GZ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=bm5QjXe0oZ1sN3o3B7gp+ZfBZHzDUDc+RJQ+ZIqrios=; b=PvetPiftXQ4iYaLOwFbVMzpHrl81z4q/EwZkaBkJL1lrRr+DQrDTqOJtvjW5CnkTYj kFICt1O6l+HaWlMcBa8b7rE6uv8SnHOYsPA1EA/gOnxrAfEd2NSq7TXly8zMwjzeEexh 8m0pET/awiEu3aUSLlVzvWcm3DVblGlc3oegurjCUgGK6VViJssk4uQ7nl5ifc/Z8l6P A6dGWeCAnHbyMy/Q7EnOB+YrAyNau7yW72PglXCX7cXLCQVrOI0q7x44VIOk6TCmG516 1G3hLSF//VoW82RCloGJ1hA+v2vGa60YakPACdiSqzBs7VASR3y6TLwjrDQ5mSpNL1JE WVMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=OUSg1jgq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a170902e0c400b001b184b4bb75si2098915pla.381.2023.06.20.10.00.54; Tue, 20 Jun 2023 10:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=OUSg1jgq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231998AbjFTQbC (ORCPT + 99 others); Tue, 20 Jun 2023 12:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231550AbjFTQaj (ORCPT ); Tue, 20 Jun 2023 12:30:39 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F422B170D for ; Tue, 20 Jun 2023 09:30:35 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f8f3786f20so57411215e9.2 for ; Tue, 20 Jun 2023 09:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278634; x=1689870634; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bm5QjXe0oZ1sN3o3B7gp+ZfBZHzDUDc+RJQ+ZIqrios=; b=OUSg1jgqq3X31GcBAN7S/8B55r8VdE4TVxCN8WmLvW2Kr0zaDb2omj6bhzkqJFboxC xV9rHAzs6j6HK6vugT4QcmhWWc47/tYXJcAMpJOdOhuDlRVdO7KLwJa5VLsBCgXKlz2d XrosX6SgRGHDgrNvA4eZihNc7viY0xMdHXwEgH5SAS3LhmU9Md4t1C4wfHhdA9oamLg9 nZCnKpM4X9T/KaJL34KQRXf4wg8SUbpnYDFANKvkqMPWyPxAtb3AH7+JSPay9C3glvXo E2n27yo+v4xqAtgRnJnjeJATxtzA08EQvoc3E6V+8IKDOqZUWYTfVpSoBpiTU7R70Qe0 m2Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278634; x=1689870634; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bm5QjXe0oZ1sN3o3B7gp+ZfBZHzDUDc+RJQ+ZIqrios=; b=GeHhaUby8YToOgQVp+0a7DX7Th1FfZm+5PlK6V0U3UVGpZintatIcaK+pS/zbVQ9V+ vczEyCSzh/iEyKHCXOTliemyz6hJzgtCzCGYj+Zfq+a7wDUdSU4PeBwEDNnu3t2dYOwz OwXUv+XTVbNlbY0/JO9Z/g/ICSfN8lsDi3cWveqOKX8aKNkYn2H6e3gQUPIiHoFWDJOy I+8IMWbUnBvarEhUs41CK5aiF/LKEAbCaValHu/fR68Lkzlfs9NxZgACYfin/74lzjXx RSEuJ6Pr/v2UrhzFRNnoof55j7r5yfsTf4Xw/y6RRjgYooXx2hnL+9mU7VNyIGi7c9fO Pwlw== X-Gm-Message-State: AC+VfDz6R5p5JhQ0/WHVWCYAT81RxJcKxOBRGuXJKV3K2eVWQxv+yht7 ikYOZjzMH4ID355KvUBNNzjXvw== X-Received: by 2002:a7b:c412:0:b0:3f9:b58:df5e with SMTP id k18-20020a7bc412000000b003f90b58df5emr8899695wmi.27.1687278634490; Tue, 20 Jun 2023 09:30:34 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:34 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:18 +0200 Subject: [PATCH net-next 5/9] mptcp: introduce MPTCP_FULL_INFO getsockopt MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-5-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6801; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=o/0+BDl7MSfxpBypAltz5t1ouUesepVQ+7hOMVYbpUA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQk/oUW/NimsARi9wRT/OmCrUQpj1lwskatg 0bEtZ+fz7yJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c4TOD/9wPj5TyMyEApib57V88k46eTBqZK2HnDn6vjvvSUpGzY/qgNPFrgJn1t5/ymJf/YeOfZm c3l/5izYVWlHLBd2x+McgioJhpBlJhXL4685/IUOsXwNLxnBEOYDv+4HWLS5tIS27Okn4hL65uk nH8f+R8QvZhKE72Pa4nSB5fOrpbdovIAOCXxl+ftb4CZ9V0n5hotr3A760GuODJwmwWbAnqItXE twVw7M/b14qhr2ZzEG2SgsOHQxEJ57c7i73ARrAzmWxiZBgUx50O6+gPTMOQu1FhvhDjzXLjJUm y5E/w3pOtIt54ReFwteO83rbTRu0YvMe2Cl2StHt5RPedMNTEzUb/2sdWBWKAXqH9I5Wm1pDKJM BjmjrpeeRwTSUw9Atm8LCTYeeoMPyyiAMqeECdt49rwqWBvkE2O3oPz0N9Zgj8CWcxLPXkQUYAI b2fL+8Bx7nWUrIGNmnHKkJYbrGfBLCzRHZ5Q4A0QyB+xIsloWpXgVWpxNPFfoHKj/ZGsJfa6sze U7LccSvnKtQb0UOC09Kmv8NtPpHoFE/Qfa0s620wQIoUERCnPZqjO0dyrRGk/iDFdZAQ6LmHkb2 VAixASuJj3AuFBbSgU7BRXxmQuxRxRpm4I2ygQZztVn4Ha7wBNkLAWJIcZssUO1LRUJK6/JaK2H 3kxl2q0u1S5ZA4Q== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769241803840168880?= X-GMAIL-MSGID: =?utf-8?q?1769241803840168880?= From: Paolo Abeni Some user-space applications want to monitor the subflows utilization. Dumping the per subflow tcp_info is not enough, as the PM could close and re-create the subflows under-the-hood, fooling the accounting. Even checking the src/dst addresses used by each subflow could not be enough, because new subflows could re-use the same address/port of the just closed one. This patch introduces a new socket option, allow dumping all the relevant information all-at-once (everything, everywhere...), in a consistent manner. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/388 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- include/uapi/linux/mptcp.h | 24 +++++++++ net/mptcp/sockopt.c | 127 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 149 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index a124be6ebbba..ee9c49f949a2 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -249,9 +249,33 @@ struct mptcp_subflow_addrs { }; }; +struct mptcp_subflow_info { + __u32 id; + struct mptcp_subflow_addrs addrs; +}; + +struct mptcp_full_info { + __u32 size_tcpinfo_kernel; /* must be 0, set by kernel */ + __u32 size_tcpinfo_user; + __u32 size_sfinfo_kernel; /* must be 0, set by kernel */ + __u32 size_sfinfo_user; + __u32 num_subflows; /* must be 0, set by kernel (real subflow count) */ + __u32 size_arrays_user; /* max subflows that userspace is interested in; + * the buffers at subflow_info/tcp_info + * are respectively at least: + * size_arrays * size_sfinfo_user + * size_arrays * size_tcpinfo_user + * bytes wide + */ + __aligned_u64 subflow_info; + __aligned_u64 tcp_info; + struct mptcp_info mptcp_info; +}; + /* MPTCP socket options */ #define MPTCP_INFO 1 #define MPTCP_TCPINFO 2 #define MPTCP_SUBFLOW_ADDRS 3 +#define MPTCP_FULL_INFO 4 #endif /* _UAPI_MPTCP_H */ diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index fa5055d5b029..63f7a09335c5 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -14,7 +14,8 @@ #include #include "protocol.h" -#define MIN_INFO_OPTLEN_SIZE 16 +#define MIN_INFO_OPTLEN_SIZE 16 +#define MIN_FULL_INFO_OPTLEN_SIZE 40 static struct sock *__mptcp_tcp_fallback(struct mptcp_sock *msk) { @@ -981,7 +982,8 @@ static int mptcp_put_subflow_data(struct mptcp_subflow_data *sfd, } static int mptcp_get_subflow_data(struct mptcp_subflow_data *sfd, - char __user *optval, int __user *optlen) + char __user *optval, + int __user *optlen) { int len, copylen; @@ -1162,6 +1164,125 @@ static int mptcp_getsockopt_subflow_addrs(struct mptcp_sock *msk, char __user *o return 0; } +static int mptcp_get_full_info(struct mptcp_full_info *mfi, + char __user *optval, + int __user *optlen) +{ + int len; + + BUILD_BUG_ON(offsetof(struct mptcp_full_info, mptcp_info) != + MIN_FULL_INFO_OPTLEN_SIZE); + + if (get_user(len, optlen)) + return -EFAULT; + + if (len < MIN_FULL_INFO_OPTLEN_SIZE) + return -EINVAL; + + memset(mfi, 0, sizeof(*mfi)); + if (copy_from_user(mfi, optval, MIN_FULL_INFO_OPTLEN_SIZE)) + return -EFAULT; + + if (mfi->size_tcpinfo_kernel || + mfi->size_sfinfo_kernel || + mfi->num_subflows) + return -EINVAL; + + if (mfi->size_sfinfo_user > INT_MAX || + mfi->size_tcpinfo_user > INT_MAX) + return -EINVAL; + + return len - MIN_FULL_INFO_OPTLEN_SIZE; +} + +static int mptcp_put_full_info(struct mptcp_full_info *mfi, + char __user *optval, + u32 copylen, + int __user *optlen) +{ + copylen += MIN_FULL_INFO_OPTLEN_SIZE; + if (put_user(copylen, optlen)) + return -EFAULT; + + if (copy_to_user(optval, mfi, copylen)) + return -EFAULT; + return 0; +} + +static int mptcp_getsockopt_full_info(struct mptcp_sock *msk, char __user *optval, + int __user *optlen) +{ + unsigned int sfcount = 0, copylen = 0; + struct mptcp_subflow_context *subflow; + struct sock *sk = (struct sock *)msk; + void __user *tcpinfoptr, *sfinfoptr; + struct mptcp_full_info mfi; + int len; + + len = mptcp_get_full_info(&mfi, optval, optlen); + if (len < 0) + return len; + + /* don't bother filling the mptcp info if there is not enough + * user-space-provided storage + */ + if (len > 0) { + mptcp_diag_fill_info(msk, &mfi.mptcp_info); + copylen += min_t(unsigned int, len, sizeof(struct mptcp_info)); + } + + mfi.size_tcpinfo_kernel = sizeof(struct tcp_info); + mfi.size_tcpinfo_user = min_t(unsigned int, mfi.size_tcpinfo_user, + sizeof(struct tcp_info)); + sfinfoptr = u64_to_user_ptr(mfi.subflow_info); + mfi.size_sfinfo_kernel = sizeof(struct mptcp_subflow_info); + mfi.size_sfinfo_user = min_t(unsigned int, mfi.size_sfinfo_user, + sizeof(struct mptcp_subflow_info)); + tcpinfoptr = u64_to_user_ptr(mfi.tcp_info); + + lock_sock(sk); + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); + struct mptcp_subflow_info sfinfo; + struct tcp_info tcp_info; + + if (sfcount++ >= mfi.size_arrays_user) + continue; + + /* fetch addr/tcp_info only if the user space buffers + * are wide enough + */ + memset(&sfinfo, 0, sizeof(sfinfo)); + sfinfo.id = subflow->subflow_id; + if (mfi.size_sfinfo_user > + offsetof(struct mptcp_subflow_info, addrs)) + mptcp_get_sub_addrs(ssk, &sfinfo.addrs); + if (copy_to_user(sfinfoptr, &sfinfo, mfi.size_sfinfo_user)) + goto fail_release; + + if (mfi.size_tcpinfo_user) { + tcp_get_info(ssk, &tcp_info); + if (copy_to_user(tcpinfoptr, &tcp_info, + mfi.size_tcpinfo_user)) + goto fail_release; + } + + tcpinfoptr += mfi.size_tcpinfo_user; + sfinfoptr += mfi.size_sfinfo_user; + } + release_sock(sk); + + mfi.num_subflows = sfcount; + if (mptcp_put_full_info(&mfi, optval, copylen, optlen)) + return -EFAULT; + + return 0; + +fail_release: + release_sock(sk); + return -EFAULT; +} + static int mptcp_put_int_option(struct mptcp_sock *msk, char __user *optval, int __user *optlen, int val) { @@ -1235,6 +1356,8 @@ static int mptcp_getsockopt_sol_mptcp(struct mptcp_sock *msk, int optname, switch (optname) { case MPTCP_INFO: return mptcp_getsockopt_info(msk, optval, optlen); + case MPTCP_FULL_INFO: + return mptcp_getsockopt_full_info(msk, optval, optlen); case MPTCP_TCPINFO: return mptcp_getsockopt_tcpinfo(msk, optval, optlen); case MPTCP_SUBFLOW_ADDRS: From patchwork Tue Jun 20 16:30:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3791884vqr; Tue, 20 Jun 2023 09:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PMU4rDGSFDMoA97E76C+297uCEYaRkb2QA0Xqd8c1uy5EGbH+zVCQjUw5LmRpJw+EckFQ X-Received: by 2002:a17:902:ab18:b0:1ac:6d4c:c24b with SMTP id ik24-20020a170902ab1800b001ac6d4cc24bmr7362942plb.3.1687278843821; Tue, 20 Jun 2023 09:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687278843; cv=none; d=google.com; s=arc-20160816; b=Bg5fuiLR6erHfNYrGFx5sNLCjDqGfqJ//uLdqsB4VtVt7TKCisE9ZPrcoSLDuv+Lel fxgZe/RBv9zj7zJRAN5n+lqTDexG8nJR65URzwaLIoy/r8o/y9tEq2dTB/Fl0H7Fkyja efAjB+w52pOTYUtYFS/chNWhxs27d/RGOwFRrq55szUnyRhNMJHkEC+Kb6QZzaJ5FUNg 5Q99zk4IW5VxKeJ8eM9OhwYjjeaWGmONArRdYD5Q/1KFTEETVTpRILu+q/1pzOHzfQop bEwZF2BMVl5TJ852Nxw5Ww4CbiORA4+lNrDQqj54JqX4Kg06NK5HRpLHHrFR4NJqXr7M Ax3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=0fmVpb8BzbfYzQdlLQkxrXEElwIfZZy9IqLUavxxfBU=; b=n/1bC3/GpMGLJf+n0r3QF3ukyoFoe4AQVfOJcKZkiustP6/fB/qKuuWeJ8twrHOyHz 1+7FuR9BIfBbQ3BRAqS3qYh29ekgx/lTOVDwIAEb1UWgsu3or3qCXH7QO4OejnGF6sPo lpv/ROmahhk8xtCHC3G2aDFgh29Zu29tY0QRzxdBPx1znjm1aVVHYSAuBceg876ZdCXA pgtxNNnNNLrBO61L1RE75f5gz3empmyxIQ+t7w76SkYrCHs287DpqX8KBnzT4x/m0PPs Zk+ICVNpiQN+m7PCQLg05lVMB+Eh2LGBIzL+VYC+i9NkSWMlFEYKV3sdzZB0P5Tul7LB 5BDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=H0yZh7yy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij26-20020a170902ab5a00b001ab18eb1764si2219398plb.131.2023.06.20.09.33.50; Tue, 20 Jun 2023 09:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=H0yZh7yy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbjFTQbJ (ORCPT + 99 others); Tue, 20 Jun 2023 12:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbjFTQak (ORCPT ); Tue, 20 Jun 2023 12:30:40 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8F941727 for ; Tue, 20 Jun 2023 09:30:36 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f8f3786f1dso53719395e9.2 for ; Tue, 20 Jun 2023 09:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278635; x=1689870635; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0fmVpb8BzbfYzQdlLQkxrXEElwIfZZy9IqLUavxxfBU=; b=H0yZh7yy/4ABJ1SFN9nMPbQPcuqnOJJO/wTCjbrJ8ETqgT9NKcFt8Vzp7PTf1nt8b6 hsfwqnUrYqVtksZG6o3IxgyCvQolPdY4fw+O4GpXO8qjrCStpp1jiUs16YnbFT1ID9gA mT6j6IHuQyOh5atwvIZSR11OSAt6GYehfJ9uhxXFCKF47peT5jLV20BCl8WaC0yiymd8 WFHCRRYY7I07KGI+Yu76H81P2F9uE9Og9YPH4GRrBjm0EknIkbnj1fo6F+1bK22YTjf2 +yzRSg56VuYl2Rjgv2NmZHu/Nm+pq/KXJgLICpTp7dzMMqMh4Rb90hwscyq4DadtTp3G O/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278635; x=1689870635; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0fmVpb8BzbfYzQdlLQkxrXEElwIfZZy9IqLUavxxfBU=; b=fu++bnmRsCbAVJ6p3vP7DnOOec6/cW8BBikfGXwGPWPz19/7SH9Pr9t7Hq9HY+aDp4 Cl5KuDCfTQDLouW1sFOv9L93vpRtZicQUfsB8mf+o5yc31UbR4YDls/TNmqvbrX1ediG dO7C7sRg7KbcgJdVAQi7V63NjZrduog/TzEJsn920M6bmfcdzYGkNcy22fFZxEew4bOb 7crmQIbmgmc8I6Y5Lh7quaRft20G5FHXW4YelpJVH22ZFIbe5cZ9dTgWhesQ3E039ze6 tvpLhkvr6rTqXrCLh5b8vGQis5UCdf36DbRNRCQilTwhWKYfi6YnqfFwygo8S519RyMT WxxQ== X-Gm-Message-State: AC+VfDxKPzPwUJKfvJSD0MnakNypDzfN1G03F08Lxi6cne8MIgfR01H+ RqjlaqqlOIT199U0ZlDK0FY6KQ== X-Received: by 2002:a7b:c7cb:0:b0:3f9:b1e7:8a41 with SMTP id z11-20020a7bc7cb000000b003f9b1e78a41mr4968596wmk.35.1687278635403; Tue, 20 Jun 2023 09:30:35 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:35 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:19 +0200 Subject: [PATCH net-next 6/9] selftests: mptcp: add MPTCP_FULL_INFO testcase MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-6-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5444; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=fPcgPXKgB0XSCiVtuCn69Ip5uyFx/AYrTDDoOEtpepE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQk5qfh7vizDIl9NDeib76hhUzXq7yL/ll7m d1eSpN7hiqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c/XID/9OdVrvDIWALDSYmsVGY6D201QJrQO0ZKHq2PMJuYqbbRukKTjqyeMXH4JpLvz2NrH8p/O QqJaS/UKxiVBPKMr2VOr/XOLWp18OthSxfzNLVXeMLeqOntm+AziV4VeOlFDTEYvaAfgNQDc/XW Ia/WV6fR3ziT7QAbBGmKYZL6eZLuKnTINSiSb2caDS6EYTP/TlmVswS6VPEKysiyaaZzqzxJU07 9NNsxMkhNEWLBa2jrHI7bKDZdomxEgcGYv6ScdCedkoKh14WzUI42QcIw8h0FfoseeO/iIS0o2z FsLhVXNqGdDCprnzlCgye4ZYFPT/TCozRLDQiMyb5eiyv0YDARkCgrrRYKlq1DzaDLXcDCK43Xe ilNSmfKDRN+jH01cqWcE8kQ8/vXxxC3AH1Ra5Le8bMsWC/NrCrE5y8quWrXlt1FqJo3C1qKDKSK RwYrdN35j4U44Ml5u5RfYua29tYrG7CJfpsFMZsfmDJBbQQs0z+BGxSyOzCUFMXTqayPnCknw3V FgfGdJaeCnF9G1jQD3q8kcg15LWNWUpiuAlyAhCxS4OJ5soNC9VBqxIwUamclCuKKtCIFFwSx9h 71HttWNlVpCTxwUhdGy2igU0W1RUT1HM2essp7hr8N1LrzX88opmgNlbgw1JBDcMQNebCs8B4Jd k0qEon/jdgvsmMw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769240100533295185?= X-GMAIL-MSGID: =?utf-8?q?1769240100533295185?= From: Paolo Abeni Add a testcase explicitly triggering the newly introduce MPTCP_FULL_INFO getsockopt. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/388 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 93 ++++++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c index 5ee710b30f10..926b0be87c99 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -86,9 +86,38 @@ struct mptcp_subflow_addrs { #define MPTCP_SUBFLOW_ADDRS 3 #endif +#ifndef MPTCP_FULL_INFO +struct mptcp_subflow_info { + __u32 id; + struct mptcp_subflow_addrs addrs; +}; + +struct mptcp_full_info { + __u32 size_tcpinfo_kernel; /* must be 0, set by kernel */ + __u32 size_tcpinfo_user; + __u32 size_sfinfo_kernel; /* must be 0, set by kernel */ + __u32 size_sfinfo_user; + __u32 num_subflows; /* must be 0, set by kernel (real subflow count) */ + __u32 size_arrays_user; /* max subflows that userspace is interested in; + * the buffers at subflow_info/tcp_info + * are respectively at least: + * size_arrays * size_sfinfo_user + * size_arrays * size_tcpinfo_user + * bytes wide + */ + __aligned_u64 subflow_info; + __aligned_u64 tcp_info; + struct mptcp_info mptcp_info; +}; + +#define MPTCP_FULL_INFO 4 +#endif + struct so_state { struct mptcp_info mi; struct mptcp_info last_sample; + struct tcp_info tcp_info; + struct mptcp_subflow_addrs addrs; uint64_t mptcpi_rcv_delta; uint64_t tcpi_rcv_delta; bool pkt_stats_avail; @@ -370,6 +399,8 @@ static void do_getsockopt_tcp_info(struct so_state *s, int fd, size_t r, size_t olen -= sizeof(struct mptcp_subflow_data); assert(olen == ti.d.size_user); + s->tcp_info = ti.ti[0]; + if (ti.ti[0].tcpi_bytes_sent == w && ti.ti[0].tcpi_bytes_received == r) goto done; @@ -391,7 +422,7 @@ static void do_getsockopt_tcp_info(struct so_state *s, int fd, size_t r, size_t do_getsockopt_bogus_sf_data(fd, MPTCP_TCPINFO); } -static void do_getsockopt_subflow_addrs(int fd) +static void do_getsockopt_subflow_addrs(struct so_state *s, int fd) { struct sockaddr_storage remote, local; socklen_t olen, rlen, llen; @@ -439,6 +470,7 @@ static void do_getsockopt_subflow_addrs(int fd) assert(memcmp(&local, &addrs.addr[0].ss_local, sizeof(local)) == 0); assert(memcmp(&remote, &addrs.addr[0].ss_remote, sizeof(remote)) == 0); + s->addrs = addrs.addr[0]; memset(&addrs, 0, sizeof(addrs)); @@ -459,13 +491,70 @@ static void do_getsockopt_subflow_addrs(int fd) do_getsockopt_bogus_sf_data(fd, MPTCP_SUBFLOW_ADDRS); } +static void do_getsockopt_mptcp_full_info(struct so_state *s, int fd) +{ + size_t data_size = sizeof(struct mptcp_full_info); + struct mptcp_subflow_info sfinfo[2]; + struct tcp_info tcp_info[2]; + struct mptcp_full_info mfi; + socklen_t olen; + int ret; + + memset(&mfi, 0, data_size); + memset(tcp_info, 0, sizeof(tcp_info)); + memset(sfinfo, 0, sizeof(sfinfo)); + + mfi.size_tcpinfo_user = sizeof(struct tcp_info); + mfi.size_sfinfo_user = sizeof(struct mptcp_subflow_info); + mfi.size_arrays_user = 2; + mfi.subflow_info = (unsigned long)&sfinfo[0]; + mfi.tcp_info = (unsigned long)&tcp_info[0]; + olen = data_size; + + ret = getsockopt(fd, SOL_MPTCP, MPTCP_FULL_INFO, &mfi, &olen); + if (ret < 0) { + if (errno == EOPNOTSUPP) { + perror("MPTCP_FULL_INFO test skipped"); + return; + } + xerror("getsockopt MPTCP_FULL_INFO"); + } + + assert(olen <= data_size); + assert(mfi.size_tcpinfo_kernel > 0); + assert(mfi.size_tcpinfo_user == + MIN(mfi.size_tcpinfo_kernel, sizeof(struct tcp_info))); + assert(mfi.size_sfinfo_kernel > 0); + assert(mfi.size_sfinfo_user == + MIN(mfi.size_sfinfo_kernel, sizeof(struct mptcp_subflow_info))); + assert(mfi.num_subflows == 1); + + /* Tolerate future extension to mptcp_info struct and running newer + * test on top of older kernel. + * Anyway any kernel supporting MPTCP_FULL_INFO must at least include + * the following in mptcp_info. + */ + assert(olen > (socklen_t)__builtin_offsetof(struct mptcp_full_info, tcp_info)); + assert(mfi.mptcp_info.mptcpi_subflows == 0); + assert(mfi.mptcp_info.mptcpi_bytes_sent == s->last_sample.mptcpi_bytes_sent); + assert(mfi.mptcp_info.mptcpi_bytes_received == s->last_sample.mptcpi_bytes_received); + + assert(sfinfo[0].id == 1); + assert(tcp_info[0].tcpi_bytes_sent == s->tcp_info.tcpi_bytes_sent); + assert(tcp_info[0].tcpi_bytes_received == s->tcp_info.tcpi_bytes_received); + assert(!memcmp(&sfinfo->addrs, &s->addrs, sizeof(struct mptcp_subflow_addrs))); +} + static void do_getsockopts(struct so_state *s, int fd, size_t r, size_t w) { do_getsockopt_mptcp_info(s, fd, w); do_getsockopt_tcp_info(s, fd, r, w); - do_getsockopt_subflow_addrs(fd); + do_getsockopt_subflow_addrs(s, fd); + + if (r) + do_getsockopt_mptcp_full_info(s, fd); } static void connect_one_server(int fd, int pipefd) From patchwork Tue Jun 20 16:30:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3792479vqr; Tue, 20 Jun 2023 09:34:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WsH+w6xG60znHnKhJefYxl369kxCMsbbUfRC1d7+XICEYmx7+PxkGN4YJCtwXZjvxMd2G X-Received: by 2002:a05:6830:1550:b0:6af:9c61:c0e3 with SMTP id l16-20020a056830155000b006af9c61c0e3mr9916234otp.29.1687278898675; Tue, 20 Jun 2023 09:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687278898; cv=none; d=google.com; s=arc-20160816; b=0fNVMnXgKSiC6zT+kXWaMvgK4M/QwbN8fbSq/v4BVyHB/UUIqU3ppj/z8zZA15o+Ze USBJUwnadXDSjAEqm9HEHIjuNURQPdjZzzh0+x5qd6dP5yUpnh/YHplvjNP5CnrR1O8x TGZvnSWAEI6ECq2XqRbHHb3eD40Pwd+GUnNfXT6t+czGkYr1m39yv52B2WEEbwui3qd/ fnZ32cFdkoeJh2wk4lUV0yPGVnGS2EJdEX9Ko3zDtKKKERr90GHqlDnla54dQEbVqPx4 TDWS9/E/G2BRifDpCW5eT0kGf1uxoU5dFvlFPGwUpSWSzn4ohDnn+T4wn0OvAf1U9big HkDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=M+3rYDno64lq4pcOQfs2XEYgkB99jAmuRJnUEJYNOIc=; b=h6vxtvEm/EhW9khejJksizcxPHDF4JCKiERHhc85QxnccXRFeGY5QoEU0NG6uMNK4x GAPXUWJeNwO/0s6ZN20zUfUxSjnQIsR8Q0Rg28oOlK4WsROv0qnlbM5EwsPT4KzakBjP Ou8QWF+cS3Z52B0bCuhS324FH8sHas16iBZhtDLEzE/RrBKHXoAvJwWlcyhsZcPQdFdi sqZ/zU5R+xse5ZJwBXaCqYUaKBaE2LKyNYoVAIplbG9DXVeegeGGyyKk98UYQ2AOs368 n5roEHNwLwkZhO/sj22bK2l4XyK+F/xDdlkQmbllTpVxF97kcVLt5IiiRlW8X2HG/5JE VJfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="zB+la/wg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a63b514000000b0054ff0e193fesi2173362pge.225.2023.06.20.09.34.44; Tue, 20 Jun 2023 09:34:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="zB+la/wg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231810AbjFTQbO (ORCPT + 99 others); Tue, 20 Jun 2023 12:31:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbjFTQal (ORCPT ); Tue, 20 Jun 2023 12:30:41 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A36DC for ; Tue, 20 Jun 2023 09:30:38 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f883420152so1769502e87.1 for ; Tue, 20 Jun 2023 09:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278636; x=1689870636; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=M+3rYDno64lq4pcOQfs2XEYgkB99jAmuRJnUEJYNOIc=; b=zB+la/wggc1VC58H6IB/lIYOcJsNn6WE5cXkeRqAcHQjo0mcJAdWLsO01M29imNHQs aFVQxeown/tMeaceP+i+gwmlYnerZvIAkxtMwAnvgKgviBqWiinXGGGmNZJFWwmTYCde l4vIo5530D1BQtAvAB/1ck2FurAumcJHAZLQZBe/Hs6w4GfKSfWPcT9qrkB2vmm1Pk8v PST2/f/57g4YtU6h2A6t0ELt3TbnxfFr/l6Ph7EQDfCdjSEZg3fBpYBvQPvRwnliU02y 668LZ3qMny5GCpor7KvXSIF6Y0rg2zbEkJOIVeQf0j/nlMEbXV5/MzvyUQeQomEy3yMn Vvjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278636; x=1689870636; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M+3rYDno64lq4pcOQfs2XEYgkB99jAmuRJnUEJYNOIc=; b=jZTY6dciX76RBUAz93qNWDL1IRB2zM9S8gRLjd3Ose92kNmdH0kUOz1/CS0LVh/bQo JFmGMh6gc1kVvreGqotLvIiQlOTe11xMDAW2bWnX8Uvx62+mEMcnihrBzgvAqzYHRQaU x3g+3YJs62M31ueW3T8LL38HMyX9O0R8rzrj6vNLDrqURsMNM7BpObpBIfbl9D8u5X6A R/UI9ViVQP4IAcZS/vEBIfWHJTOSGhED4zYG2vrmNl76gJ4BrfYGtbulne9lJj1UNI5D GV/j+r4MBbmJhOD6DG1wNIhnGGZ/kQBH5uICRczhNwemkgN3X+8rtdb1X/EW5Dl4bD+M +Ttw== X-Gm-Message-State: AC+VfDy8twIux1bmwt4/e9K/TwOlTADd3ynRlhkz9DqyDGwLuUniW5N/ fAt+r9G66q6IoFoZGr/ei3zbOA== X-Received: by 2002:a19:ab12:0:b0:4f8:6aec:1a7b with SMTP id u18-20020a19ab12000000b004f86aec1a7bmr3900454lfe.67.1687278636276; Tue, 20 Jun 2023 09:30:36 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:36 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:20 +0200 Subject: [PATCH net-next 7/9] selftests: mptcp: join: skip check if MIB counter not supported (part 2) MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-7-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3948; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=abzxrEVNoJ7Ql/J02Q0CV6m2IPXwAB1iOgYr8iLGxmU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQk0zIu54dctAVesZxRVGsIecrhRI5w9cjgz zfT+ppbciGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg cxo6EACEBIPC0qbn1q/GyzrHITIhcUE8AhlAcrTKBQUfcdQqeDoZCWshA+mVK4fxmTYelZHYN/F Mjd+B8zpObxG6YfUCAFqE3nQ8mLJpIpt6aKa1/vY154D1VqVjVCkLLOWj7FEQ7WgOqO982JPcNq 4eyaVFg8MWQFJI6Iwf5G0ent82gmYg/cWrypgjvJK1xt5QONq/OLZnNNmraEBuIOlJAHGrrNaDG xpMicm5UAxKNf2DEWdQd6JbJ96FoKOiflJgrs7+Kechi5gwvz6kS5o5K3KlaAgPJAQ++DgWotwe TmpYA2RRds2STezDSghGy/O6WLauaIjhMV/Sd9dRzXijXhWIqZ1kqpbN5XueGKjmKPyd1TiklWH dCAUcJtmKYB5OQf4HE2Vh/GrSJqPvYGBlosSgCVQH7Km53keJUIT73qISzhMxbaz9GReiAboZ/2 g3rz0+y03ExpRQS7BQFuHVKGT5zqbo46Te1+MOTzoW6NASyU5Q/16TOuBr/QTPrJnKjEXJBtpvs ptv8BVY/1OJpK5RKk/K6RH0YZq+bptu53g/KG55QLPkmyb3co16BGBH9+Hmf6ck+iCFL0xfPhFx wezRXLI3XrLA2f0UBcqiQ8kZpjrubTvxczMqgDYGPNeEJCLsE1hzd9qgHbYI/jDPgBCpLC8zxdn ywXqCGdrR5kbUVw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769240158374558036?= X-GMAIL-MSGID: =?utf-8?q?1769240158374558036?= Selftests are supposed to run on any kernels, including the old ones not supporting all MPTCP features. One of them is the MPTCP MIB counters introduced in commit fc518953bc9c ("mptcp: add and use MIB counter infrastructure") and more later. The MPTCP Join selftest heavily relies on these counters. If a counter is not supported by the kernel, it is not displayed when using 'nstat -z'. We can then detect that and skip the verification. A new helper (get_counter()) has been added recently in the -net tree to do the required checks and return an error if the counter is not available. This commit is similar to the one with the same title applied in the -net tree but it modifies code only present in net-next for the moment, see the Fixes commit below. While at it, we can also remove the use of ${extra_msg} variable which is never assigned in chk_rm_tx_nr() function and use 'echo' without '-n' parameter. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 Fixes: 0639fa230a21 ("selftests: mptcp: add explicit check for new mibs") Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 33 +++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 1b68fe1c0885..a7973d6a40a0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -1683,12 +1683,12 @@ chk_add_tx_nr() timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) printf "%-${nr_blank}s %s" " " "add TX" - count=$(ip netns exec $ns1 nstat -as MPTcpExtAddAddrTx | grep MPTcpExtAddAddrTx | awk '{print $2}') - [ -z "$count" ] && count=0 - + count=$(get_counter ${ns1} "MPTcpExtAddAddrTx") + if [ -z "$count" ]; then + echo -n "[skip]" # if the test configured a short timeout tolerate greater then expected # add addrs options, due to retransmissions - if [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then + elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then echo "[fail] got $count ADD_ADDR[s] TX, expected $add_tx_nr" fail_test else @@ -1696,9 +1696,10 @@ chk_add_tx_nr() fi echo -n " - echo TX " - count=$(ip netns exec $ns2 nstat -as MPTcpExtEchoAddTx | grep MPTcpExtEchoAddTx | awk '{print $2}') - [ -z "$count" ] && count=0 - if [ "$count" != "$echo_tx_nr" ]; then + count=$(get_counter ${ns2} "MPTcpExtEchoAddTx") + if [ -z "$count" ]; then + echo "[skip]" + elif [ "$count" != "$echo_tx_nr" ]; then echo "[fail] got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr" fail_test else @@ -1734,9 +1735,10 @@ chk_rm_nr() fi printf "%-${nr_blank}s %s" " " "rm " - count=$(ip netns exec $addr_ns nstat -as MPTcpExtRmAddr | grep MPTcpExtRmAddr | awk '{print $2}') - [ -z "$count" ] && count=0 - if [ "$count" != "$rm_addr_nr" ]; then + count=$(get_counter ${addr_ns} "MPTcpExtRmAddr") + if [ -z "$count" ]; then + echo -n "[skip]" + elif [ "$count" != "$rm_addr_nr" ]; then echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" fail_test else @@ -1778,16 +1780,15 @@ chk_rm_tx_nr() local rm_addr_tx_nr=$1 printf "%-${nr_blank}s %s" " " "rm TX " - count=$(ip netns exec $ns2 nstat -as MPTcpExtRmAddrTx | grep MPTcpExtRmAddrTx | awk '{print $2}') - [ -z "$count" ] && count=0 - if [ "$count" != "$rm_addr_tx_nr" ]; then + count=$(get_counter ${ns2} "MPTcpExtRmAddrTx") + if [ -z "$count" ]; then + echo "[skip]" + elif [ "$count" != "$rm_addr_tx_nr" ]; then echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr" fail_test else - echo -n "[ ok ]" + echo "[ ok ]" fi - - echo "$extra_msg" } chk_prio_nr() From patchwork Tue Jun 20 16:30:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3811777vqr; Tue, 20 Jun 2023 10:06:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wBsHlaF/h23fuW122RyAS8rBfQ9d6hMQhisPsDEudD0Efo5AqULmoVvAmxyVHg7QqX1cm X-Received: by 2002:a17:90a:ec14:b0:25b:d0c9:9f00 with SMTP id l20-20020a17090aec1400b0025bd0c99f00mr7512603pjy.9.1687280808005; Tue, 20 Jun 2023 10:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687280807; cv=none; d=google.com; s=arc-20160816; b=KC+8UhbqJb+Y+WgsYlBrbnk+HBb9eWGxQ1D6TmRisX1Y7GAkZYoWBCKsx3l4noWkkK jDOujNdAhOkxUYz6M3ueU3zBluwiEumt7f2ik4nCqdTqPfVIyAiY1kjVZczfx5kaFuiX Cvq1VRdcQ7SKrgK8J5LNegKRIkEiZvcnYRRUXbSYIDNfF21NLLLDTaZJctBxCqMFMIs4 eMWz7e7KS+tTWfqctSjFHF9Mq+/ErV4G8dPs1vmkg1Od72T/BaPYV454D1OMdGqNl5lJ OkAb6gbEwT9+MJKN32fsG43I021U31mECr80BNu+2Kh9sWzw68enUYfFWnciLQXqtKXk 1Myg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=a7elg4draWHNpGjD0HLDzJ+3OyRSgUqMtc+y+geeEHc=; b=Ifm5/Jk024x9KfZy7zm1xYFOR5YX2OJz/HZiJMi5ela44j89vnRj2rYxDI7eHA5Ui8 051s9IaA5RzaOK9TnrP/J2q+Y1j2NLTkNn6iYc7EUgTpZbgXFTNBVf1BPpKPx8ox8ux+ N/3z0mlgopqqH0VVhQYYGX8m17hSxfWoIUqSlepNikHJv3fIOLXwOE+YYgWZ+4L4l1Ca ZySC6aqkCSx76Yk3aW9bBdEeTwY+ZcvkAa9CCcuHiHpHR+Zss+/PRUrc9a/2+YjEXHRJ 1H3oesKEYOQAi3mtGiIAAaZ2snHPyxzgziR9CZ+kKVfQ4M5F9kgW/VQ6uR+Btvd6y1y/ rmnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=fhdDkTcz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k130-20020a633d88000000b0051b9ce24708si2187594pga.103.2023.06.20.10.06.20; Tue, 20 Jun 2023 10:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=fhdDkTcz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbjFTQbV (ORCPT + 99 others); Tue, 20 Jun 2023 12:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbjFTQal (ORCPT ); Tue, 20 Jun 2023 12:30:41 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC1041733 for ; Tue, 20 Jun 2023 09:30:38 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f909853509so28658795e9.3 for ; Tue, 20 Jun 2023 09:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278637; x=1689870637; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=a7elg4draWHNpGjD0HLDzJ+3OyRSgUqMtc+y+geeEHc=; b=fhdDkTczBb6rVV12XCSs39fdpf55epJ4y5zRoQJT4xQoM9iIJRmDufHZHlIIcb7Qyo h+6PVjFheamz0VSQ78gJKyXdF3yENiH5+dS9AO2Vgqt9dQ3MEEtXyi/1ySdCS53TcZxA zQtSpbckW/mT68NuBh3ibnXPoleFYgEEBufh4Tp6QS9xVrpYVZr0fBQpMpLRROVRaqfd aFC1/0yE6n7xYkWVgUuFQyLTIK+TuFMCNm5ln5wqaNgLz27HNiBMS2Vk9trpk+BPs/+q wlkEgh/7ThT+IxasDcGdlWeksqxnSVXO4rJRsSNy0Ouz5P9gG96knLndmxy+IJSmfP0k Jl7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278637; x=1689870637; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a7elg4draWHNpGjD0HLDzJ+3OyRSgUqMtc+y+geeEHc=; b=Oc1LC0QMz6r26Nv8GB6MlFnQzMRXP8WABL7fjfQwtyotqTNJYqZEvfWNLxyTJk3b7x KnPBtxCLLB4t2M13G+nB3fT1Z4mxHNE3fBIgfQGpgElJWyrAInAPhclEbLyBQrBvS7rT tGkaksmn38bQaeMR/FqJAGi48dD2im3kfcc0DjVtys62iOG6P0/Qbg3obb9LcZsrLJ/K EwWsE3oiZlQb4ev9lF0B2ebWGAXElx9YA84UFJ/9zfckszrL819tedXgdeBJADhzXIiY 5AHxtNSJCXZ2z+gSHId694zLjfWJT02lSAYNzKXxqnDBGgTtLrWqoklz5KJKFsQTyNzA qgIw== X-Gm-Message-State: AC+VfDz2jw8wieyqqY4LTl+4ZLaAQCcMhlWPTttivEEt689V9JnhcVTG 5ciKCII7frZkxx8DRkEmLRLkWg== X-Received: by 2002:a7b:c449:0:b0:3f4:a09f:1877 with SMTP id l9-20020a7bc449000000b003f4a09f1877mr8650689wmi.23.1687278637169; Tue, 20 Jun 2023 09:30:37 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:36 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:21 +0200 Subject: [PATCH net-next 8/9] mptcp: consolidate transition to TCP_CLOSE in mptcp_do_fastclose() MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-8-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1968; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=J0hbphqDnBQXxAYln3jyFeuXYGpPLcu5bRjMLswg8ew=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQkQp7ZphscCESHFoCADk9udZaIhfe1hxTej uZAKnNJS0KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c6YaEADNIuJ+BTrKv0+V9hcb8zkqWKeXlBnXPs8LCezMBeJqm0szcDC6fUlr5nUouQpf+qsL63a wwdQvNvpgHDbMH6oVGOOaEmAtnqX/guDsqid6bKqbsXqhvh4GwRAHQfHncVyGVZSG9+incwolfK eDVmThQo4GhatAajhbFaCufHV4FgBeF8eT7CQ4jjIY7U3zBDJUmQRCOBwfDvzCd7JJkVN2VEuLo oqblrQ/hrbBYKHZ5NHwXsJHheT7ZOC1DItwjpc/MbC+RPd9BpopS8WFHKxwtjNkQPjJBjkeYiI3 6/R+evhOwDMnCmV/X/rvOqhTpssdtIoo1n4m3gFCJWG6TePolrNrclszyAG6yvJSEzgTR8oF1oQ aqvYsgYa29lB+GjnYyawfTThAXpWnjN3ERRk3Doi0KT3sRxGMmWL7OfJokKR5iQFf0w+MXdGBXK MjGb7FsNHXtbLBivuPndenEuRk0EGi2xm4vPecXNyswzx2gqMm9nwF+3Q4z367STZJj/u6Bzd3k Jg1z0AqzVaSnjuc1BgYKsl1fpl9Gzb7VAcmHdQWwAe4R10bBLI1GjK9c2fyK++Auhycn3ED1DEI bwfwRNr1ajskPGDpP6rG28b5iyEglNRAoJEs3UYOcc3gHbIQM2lcNNmv9ymjyHb8OmrDDSvRwTT Lj5X395gifMiS5g== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769242160783908541?= X-GMAIL-MSGID: =?utf-8?q?1769242160783908541?= From: Paolo Abeni The MPTCP code always set the msk state to TCP_CLOSE before calling performing the fast-close. Move such state transition in mptcp_do_fastclose() to avoid some code duplication. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 4ebd6e9aa949..f65eec3e0d22 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2655,6 +2655,7 @@ static void mptcp_do_fastclose(struct sock *sk) struct mptcp_subflow_context *subflow, *tmp; struct mptcp_sock *msk = mptcp_sk(sk); + inet_sk_state_store(sk, TCP_CLOSE); mptcp_for_each_subflow_safe(msk, subflow, tmp) __mptcp_close_ssk(sk, mptcp_subflow_tcp_sock(subflow), subflow, MPTCP_CF_FASTCLOSE); @@ -2692,10 +2693,9 @@ static void mptcp_worker(struct work_struct *work) * even if it is orphaned and in FIN_WAIT2 state */ if (sock_flag(sk, SOCK_DEAD)) { - if (mptcp_should_close(sk)) { - inet_sk_state_store(sk, TCP_CLOSE); + if (mptcp_should_close(sk)) mptcp_do_fastclose(sk); - } + if (sk->sk_state == TCP_CLOSE) { __mptcp_destroy_sock(sk); goto unlock; @@ -2938,7 +2938,6 @@ static void __mptcp_destroy_sock(struct sock *sk) void __mptcp_unaccepted_force_close(struct sock *sk) { sock_set_flag(sk, SOCK_DEAD); - inet_sk_state_store(sk, TCP_CLOSE); mptcp_do_fastclose(sk); __mptcp_destroy_sock(sk); } @@ -2980,7 +2979,6 @@ bool __mptcp_close(struct sock *sk, long timeout) /* If the msk has read data, or the caller explicitly ask it, * do the MPTCP equivalent of TCP reset, aka MPTCP fastclose */ - inet_sk_state_store(sk, TCP_CLOSE); mptcp_do_fastclose(sk); timeout = 0; } else if (mptcp_close_state(sk)) { From patchwork Tue Jun 20 16:30:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 110617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3804882vqr; Tue, 20 Jun 2023 09:57:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66FwARu9vk4JkbbHKdfg0LAFq93aivhvVOBcGu9NlG57Qot0UDYrya/kOln4fOOhKZ/UjK X-Received: by 2002:a05:6359:a01:b0:129:c1c1:c897 with SMTP id el1-20020a0563590a0100b00129c1c1c897mr8209601rwb.24.1687280247735; Tue, 20 Jun 2023 09:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687280247; cv=none; d=google.com; s=arc-20160816; b=TxyocCPgl5asX369qhc5lI6XWkhvUCoF3/Qs4kk2zfFv50VI5Lczy3d/DPWpKVyQNv ENCZ5wl2onytEmoJOMkLRtPmWSRDsVN6oCqi1gpjjQ1+AyqsLeowN2v1VrCmXnt90LTZ q6K90hpxzN/VntBxq6lMiaTNbNembtt+dfvb9bUx3MUKgpJzVvdgjZLWUo46hRxHiFef 6xqfOzMzJ6np13USer8tSsZ1a5nxdN6wrb0/LyPzENDknmeMVBZZDujaK/X7rv+SxDD4 +WKlL4xS+l2/qsUyZD1ReveBDYIUG0705rxfjESRvA7Db7rRXEv1Q7t+Z9Ud7/V5dxqQ lDdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=gZ3kJNWmTLtBf/BfLXDmeQlmTShgJXVFKrdZIjv8KLU=; b=nPx6H/v83cSPjAfgiyHOTYLV1Fwg9e19WZSYGfHoiAh/JWHkz8n2c54NfxeRhUO8MO FmnukUeDAbkTSH/1Y6g6tl7SJInf/AnjhZsWt3hDpUBKm/FpmvF87bxIDiePCI2kZ/xN 1VegezPW1pzkx0GBSB+fwV6yPqQjC0PK3KzOVXBs79/6qVcOLWEmfNZ0XJZpOVme1AKG Svbf8BZHCSvxnskMkK4+tYwJPObuYSAQlFEe2sfelr+F15dehD+TENh3HzKWaHtL3Ghd KcQAY9aakg53gymTPTGSiHTKabLoKCxU0P7CWR+QiGlYYSgbNmqSSeasYlTctsTCDrMx N8oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=UHwL1K4p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a63741b000000b0054f78775084si2030457pgc.125.2023.06.20.09.57.13; Tue, 20 Jun 2023 09:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=UHwL1K4p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232030AbjFTQb0 (ORCPT + 99 others); Tue, 20 Jun 2023 12:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjFTQam (ORCPT ); Tue, 20 Jun 2023 12:30:42 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1EC173B for ; Tue, 20 Jun 2023 09:30:39 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f9b0f139feso28209805e9.3 for ; Tue, 20 Jun 2023 09:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1687278638; x=1689870638; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gZ3kJNWmTLtBf/BfLXDmeQlmTShgJXVFKrdZIjv8KLU=; b=UHwL1K4pbMTRAcfRGUYcKm0zXsepk52siFP533rGVXYBJiQhAAd4JWM0F3rAbSCzdm kgk/0KQZBcMUc9LI+nygZ/pjRD0BTibdmUZYu11f9ao0z0USFduLL/BKrGiLdUR8RLb7 K5pwPQtiizLRxZPTg3PMt5B9TGCIlJ8XppzOw/70QTJZ0TzvfOtHfMEwUmNTuCGP0eUO OEMPcHx1Ism07UaFItz+PtnwJVoHLiWCCsEDCZv06SLcwChA90dddRfVHNjJyeLB4c63 hTKY8ywCiXKiA3DRpR2oYqE2Zc+apJ/aXDkyaJhoxKMpAYH/bGdWTD+coOUfuOUxBJt3 tz8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687278638; x=1689870638; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gZ3kJNWmTLtBf/BfLXDmeQlmTShgJXVFKrdZIjv8KLU=; b=HBhl1LAAQYPmXTTNWMwaoa8jqt9YbZ0NjnwXRG6xvCucxhULHmYrVrlHC/lcsaikHm GosuJ0Su65wegMKDF8b4eVitrJQFH7NAGy0aTrNcd5E5KhZZstshY9mVXLCWZqnqoaNV BEJPcK2GDzt3gxWYB9U4vga7Er6kS+ISk+7OP5OAhCXaMJMEbqaAT3ieebbSl72m6QHH EEtAuu4LR4pnFy/4sTVyf7UCkjTJd2FDhOHIpAK8Sp3Ux87KQ2MJBCpxPgk2XWBccRi0 zLl6z8UlbPsV5Wv93MHpIgKZlsIbqd+rB1Ga78IqGUALVMTT8BKkLm+6uhoXlNvRdC5Y 9xcg== X-Gm-Message-State: AC+VfDwvW6uJm5OcZZBD19PXIYOJH+9eVmUtaf5qC9VFnZtV0lAX3OO1 2VZpoYYrHTOrBQr+bYrg1Gk3dUTSA6zJUGQROxG71g== X-Received: by 2002:a7b:cbd7:0:b0:3f9:ab2:dd91 with SMTP id n23-20020a7bcbd7000000b003f90ab2dd91mr7782743wmi.27.1687278638108; Tue, 20 Jun 2023 09:30:38 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003f8fbe3bf7asm12064342wmq.32.2023.06.20.09.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:30:37 -0700 (PDT) From: Matthieu Baerts Date: Tue, 20 Jun 2023 18:30:22 +0200 Subject: [PATCH net-next 9/9] mptcp: pass addr to mptcp_pm_alloc_anno_list MIME-Version: 1.0 Message-Id: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-9-62b9444bfd48@tessares.net> References: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> In-Reply-To: <20230620-upstream-net-next-20230620-mptcp-expose-more-info-and-misc-v1-0-62b9444bfd48@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Geliang Tang X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3179; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=ZCzZ8EKi5x6HATdIf96lUX0XdrhaBy/V/aHygwI2nHo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkkdQkII3YarV/LkRetzK0oASSiajfV0fUYKPKS 6nO0dbzQkeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZJHUJAAKCRD2t4JPQmmg c+E7D/4oRFzBb+3Z8XhicZ8EJVpmjafjIkCblAMmOuq2/UD9ojIr6nxyXcDHd87FGJEWOdisZbO UZLi/fAXMiUfDp9LQZ2Y8IMUSravhrJC1nPWl+JGphPNtKS4s0g+09ZNOtkfmAJKK8Xt76H1D3i Au4/kNykdrbTaOFero2AblnVltHYCP7TDX2tWaSfpsZfmSDEiRAnKT97LAwZJwwlvRfUe6oi0zr +uLrOOdPKsP/SSxUKH3nN5nisHjpVXfcz6lL3oGDgwx19HddJ3y/bL/bGC/qevuN6G2FC33Psd6 tNNwyEFsPpnjprrMMh78u8lJtBiHnBRnN72FyIEdhUcU9QW+hqAQzIH0KuXVfk3Om/U6i9YJ3O+ aQF2x4EPNjpHmJIXcQ7P8yBhBycD1krFwijuyv0nEMzOBDVluagjzzKJdJzr4Ce/lSDofo18YTN WLFF3OZy2pTipel9OhHg/L2UdbPtSfz2rwPnZJvRv8r5NY/WfTfgOEOWW3L4RB2bhTHIiywG+nl qIIa5qRLlGGcLJu9yLhSAzc4bmupyg4auhnpFwfod2LkSM4CeWmJE5qKc4/qYY3eGLOaD6cVP9y fbC+xOlR0LM6sUtos2bgIy0OfE7AnjBt01xdms0qonYKg60+XUU2TjyqABkU8woxxZvUcoBNPg+ t0UDgsRU+2zC5tA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769241572645083029?= X-GMAIL-MSGID: =?utf-8?q?1769241572645083029?= From: Geliang Tang Pass addr parameter to mptcp_pm_alloc_anno_list() instead of entry. We can reduce the scope, e.g. in mptcp_pm_alloc_anno_list(), we only access "entry->addr", we can then restrict to the pointer to "addr" then. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 8 ++++---- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a12a87b780f6..c01a7197581d 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -341,7 +341,7 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk, } bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, - const struct mptcp_pm_addr_entry *entry) + const struct mptcp_addr_info *addr) { struct mptcp_pm_add_entry *add_entry = NULL; struct sock *sk = (struct sock *)msk; @@ -349,7 +349,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, lockdep_assert_held(&msk->pm.lock); - add_entry = mptcp_lookup_anno_list_by_saddr(msk, &entry->addr); + add_entry = mptcp_lookup_anno_list_by_saddr(msk, addr); if (add_entry) { if (mptcp_pm_is_kernel(msk)) @@ -366,7 +366,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, list_add(&add_entry->list, &msk->pm.anno_list); - add_entry->addr = entry->addr; + add_entry->addr = *addr; add_entry->sock = msk; add_entry->retrans_times = 0; @@ -576,7 +576,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) return; if (local) { - if (mptcp_pm_alloc_anno_list(msk, local)) { + if (mptcp_pm_alloc_anno_list(msk, &local->addr)) { __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); msk->pm.add_addr_signaled++; mptcp_pm_announce_addr(msk, &local->addr, false); diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 47a883a16c11..b5a8aa4c1ebd 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -193,7 +193,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info) lock_sock((struct sock *)msk); spin_lock_bh(&msk->pm.lock); - if (mptcp_pm_alloc_anno_list(msk, &addr_val)) { + if (mptcp_pm_alloc_anno_list(msk, &addr_val.addr)) { msk->pm.add_addr_signaled++; mptcp_pm_announce_addr(msk, &addr_val.addr, false); mptcp_pm_nl_addr_send_ack(msk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index bb4cacd92778..3a1a64cdeba6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -817,7 +817,7 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, struct mptcp_addr_info *rem, u8 bkup); bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, - const struct mptcp_pm_addr_entry *entry); + const struct mptcp_addr_info *addr); void mptcp_pm_free_anno_list(struct mptcp_sock *msk); bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk); struct mptcp_pm_add_entry *