From patchwork Thu Mar 5 14:46:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249649 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cZ+pVwcu; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKK6XTWz9sSJ for ; Fri, 6 Mar 2020 01:53:57 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CEEB110FC3781; Thu, 5 Mar 2020 06:48:12 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.211.31.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8304C10FC377C for ; Thu, 5 Mar 2020 06:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/iuSZ+vsAetuKkL4M32SdEyJY8x+rq5LMu4F+rZd7l0=; b=cZ+pVwcuaqVFRwfhwlfiNaFKprXWfWfjZi9TNhXWmmL31nHjEX0qkyx8vHYcbmuAKJNCIG u/YkKhJVM63lEZdviTNRnrvufMfDyvO3z9lMf42GdIzma3L6lB2cCdSKK1VZC2CJ2w+a4X bYtgnfYiQiUAFSoX7dSY1Iyvx4pb24s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-L6fcczjNMMmyj_JFbKdQoQ-1; Thu, 05 Mar 2020 09:47:16 -0500 X-MC-Unique: L6fcczjNMMmyj_JFbKdQoQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2404DA0CD7 for ; Thu, 5 Mar 2020 14:47:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 873035D9C9 for ; Thu, 5 Mar 2020 14:47:14 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:38 +0100 Message-Id: <91063550108210c28a3b3aeb5f0e4cb5bc3b73df.1583418572.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BREVOB4BDKOHSA452UYQP66LELLLICHP X-Message-ID-Hash: BREVOB4BDKOHSA452UYQP66LELLLICHP X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 1/12] mptcp: rename fourth ack field List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The name is misleading, it actually track the 'fully established' status. Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 18 +++++++++--------- net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 45acd877bef3..a45f6f97ef45 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -259,11 +259,11 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, struct mptcp_ext *mpext; unsigned int data_len; - pr_debug("subflow=%p fourth_ack=%d seq=%x:%x remaining=%d", subflow, - subflow->fourth_ack, subflow->snd_isn, + pr_debug("subflow=%p fully established=%d seq=%x:%x remaining=%d", + subflow, subflow->fully_established, subflow->snd_isn, skb ? TCP_SKB_CB(skb)->seq : 0, remaining); - if (subflow->mp_capable && !subflow->fourth_ack && skb && + if (subflow->mp_capable && !subflow->fully_established && skb && subflow->snd_isn == TCP_SKB_CB(skb)->seq) { /* When skb is not available, we better over-estimate the * emitted options len. A full DSS option is longer than @@ -424,19 +424,19 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size, return false; } -static bool check_fourth_ack(struct mptcp_subflow_context *subflow, - struct sk_buff *skb, - struct mptcp_options_received *mp_opt) +static bool check_fully_established(struct mptcp_subflow_context *subflow, + struct sk_buff *skb, + struct mptcp_options_received *mp_opt) { /* here we can process OoO, in-window pkts, only in-sequence 4th ack * are relevant */ - if (likely(subflow->fourth_ack || + if (likely(subflow->fully_established || TCP_SKB_CB(skb)->seq != subflow->ssn_offset + 1)) return true; if (mp_opt->use_ack) - subflow->fourth_ack = 1; + subflow->fully_established = 1; if (subflow->can_ack) return true; @@ -462,7 +462,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb, struct mptcp_ext *mpext; mp_opt = &opt_rx->mptcp; - if (!check_fourth_ack(subflow, skb, mp_opt)) + if (!check_fully_established(subflow, skb, mp_opt)) return; if (!mp_opt->dss) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 6c0b2c8ab674..fcba0e8f45f2 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -119,7 +119,7 @@ struct mptcp_subflow_context { u32 map_data_len; u32 request_mptcp : 1, /* send MP_CAPABLE */ mp_capable : 1, /* remote is MPTCP capable */ - fourth_ack : 1, /* send initial DSS */ + fully_established : 1, /* path validated */ conn_finished : 1, map_valid : 1, mpc_map : 1, diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 0de2a44bdaa0..b5f7a5a90ed1 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -794,7 +794,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->tcp_state_change = old_ctx->tcp_state_change; new_ctx->tcp_write_space = old_ctx->tcp_write_space; new_ctx->mp_capable = 1; - new_ctx->fourth_ack = subflow_req->remote_key_valid; + new_ctx->fully_established = subflow_req->remote_key_valid; new_ctx->can_ack = subflow_req->remote_key_valid; new_ctx->remote_key = subflow_req->remote_key; new_ctx->local_key = subflow_req->local_key; From patchwork Thu Mar 5 14:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249652 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=198.145.21.10; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gPfWGZgv; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKM595vz9sQt for ; Fri, 6 Mar 2020 01:53:59 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D5D8A10FC3786; Thu, 5 Mar 2020 06:48:12 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D49AD10FC377A for ; Thu, 5 Mar 2020 06:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3/ov/VmCJIjgbjis2i1NBv1jPRI48Z6+0wcGZX18AOo=; b=gPfWGZgvhN6v5xsF69UT84ejeG3u4ia/3vHTziaRtiEwg24ECcDzSG6fNMlFZqBLm+FI9P ILTmM5ZwUXmaVzam3G5R70OzO9wGNEkHW/bqV7zHBp9pYy1OLHAszVygBxFgpftTXrp3Yu /kFQ+wCBI4cHYygWi0azHCV0CGMNN3Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-bP4BOV0kPsW_olQH3cuIRg-1; Thu, 05 Mar 2020 09:47:16 -0500 X-MC-Unique: bP4BOV0kPsW_olQH3cuIRg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14646107B27A for ; Thu, 5 Mar 2020 14:47:16 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75BCB5D9C9 for ; Thu, 5 Mar 2020 14:47:15 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:39 +0100 Message-Id: <6bd4e7892b80f11b4c9e41b232c683a2d6f9ed7d.1583418572.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: SYZ66QQRYLQT5J5Y6DC7RJHWSX6D3TLS X-Message-ID-Hash: SYZ66QQRYLQT5J5Y6DC7RJHWSX6D3TLS X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 2/12] Squash-to: "mptcp: Add ADD_ADDR handling" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Need a new hook to limit the number of per msk subflows Also add new fields to properly account the total subflows number Signed-off-by: Paolo Abeni --- net/mptcp/pm.c | 9 ++++++++- net/mptcp/protocol.h | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index e869cea22f66..f17db5517544 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -39,6 +39,12 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side) WRITE_ONCE(pm->server_side, server_side); } +bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) +{ + pr_debug("msk=%p", msk); + return false; +} + void mptcp_pm_fully_established(struct mptcp_sock *msk) { pr_debug("msk=%p", msk); @@ -88,10 +94,11 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) msk->pm.add_addr_signaled = 0; msk->pm.add_addr_accepted = 0; msk->pm.local_addr_used = 0; + msk->pm.subflows = 0; WRITE_ONCE(msk->pm.work_pending, false); WRITE_ONCE(msk->pm.addr_signal, false); - WRITE_ONCE(msk->pm.fully_established, false); WRITE_ONCE(msk->pm.accept_addr, false); + WRITE_ONCE(msk->pm.accept_subflow, false); msk->pm.status = MPTCP_PM_IDLE; spin_lock_init(&msk->pm.lock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 80af72fab808..b3a02735c796 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -105,15 +105,17 @@ struct mptcp_pm_data { bool addr_signal; bool server_side; - bool fully_established; bool work_pending; bool accept_addr; + bool accept_subflow; u8 add_addr_signaled; u8 add_addr_accepted; u8 local_addr_used; + u8 subflows; u8 add_addr_signal_max; u8 add_addr_accept_max; u8 local_addr_max; + u8 subflows_max; enum mptcp_pm_status status; struct work_struct work; @@ -286,6 +288,7 @@ void mptcp_pm_init(void); void mptcp_pm_data_init(struct mptcp_sock *msk); void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side); void mptcp_pm_fully_established(struct mptcp_sock *msk); +bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk); void mptcp_pm_connection_closed(struct mptcp_sock *msk); void mptcp_pm_subflow_established(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow); From patchwork Thu Mar 5 14:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249638 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PJ4cGZo1; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDBN5lktz9sPg for ; Fri, 6 Mar 2020 01:47:55 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DDC2810FC378D; Thu, 5 Mar 2020 06:48:12 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D064310FC377A for ; Thu, 5 Mar 2020 06:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=luQ6STD4+zQcRqpGATNN3dTE2RiZV5ppYTnMt5xHQuM=; b=PJ4cGZo1dcJ0C3KPIOdLkl9ZNF6WDAvv3joXYITXTdoEo7iPrNsuHmX7NpbTBmmlPCMkG+ m9/rrDoXaSTF5Ll7I+V4MrHiKbTEsH2rU27Q/52nSEUakmuKaLXQpShn4N5yD/n51DJ4gl dqxF1+j0HOoEljRUFDkRt/Xx5kQO0yk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-jgAAF8WSPGGTaZYCvIg-0w-1; Thu, 05 Mar 2020 09:47:17 -0500 X-MC-Unique: jgAAF8WSPGGTaZYCvIg-0w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0D52801FA0 for ; Thu, 5 Mar 2020 14:47:16 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 661F65D9C9 for ; Thu, 5 Mar 2020 14:47:16 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:40 +0100 Message-Id: <106e575c6f51334a303dfd17ea4613e4fe4eb32b.1583418572.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: S6GO7KYMOPUMJ6IJGMRWID6NMJDS2EOK X-Message-ID-Hash: S6GO7KYMOPUMJ6IJGMRWID6NMJDS2EOK X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 3/12] Squash-to: "mptcp: Add handling of incoming MP_JOIN requests" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Send 4th ack on 3rd acj reception for MP_JOIN pkts and enforce no data packet before 4th ack. Let the PM limit the number of per msk subflows. Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 56 ++++++++++++++++++++++++++++++++------------ net/mptcp/protocol.c | 7 +++--- net/mptcp/protocol.h | 1 + 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 5e62cb9aafda..c548ad107d44 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -553,37 +553,66 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size, return false; } -static bool check_fully_established(struct mptcp_subflow_context *subflow, +static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, + struct mptcp_subflow_context *subflow, struct sk_buff *skb, struct mptcp_options_received *mp_opt) { /* here we can process OoO, in-window pkts, only in-sequence 4th ack - * are relevant + * will make the subflow fully established */ - if (likely(subflow->fully_established || - TCP_SKB_CB(skb)->seq != subflow->ssn_offset + 1)) - return true; + if (likely(subflow->fully_established)) { + /* on passive sockets, check for 3rd ack retransmission + * note that msk is always set by subflow_syn_recv_sock() + * for mp_join subflows + */ + if (TCP_SKB_CB(skb)->seq == subflow->ssn_offset + 1 && + TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq && + subflow->mp_join && mp_opt->mp_join && + READ_ONCE(msk->pm.server_side)) + tcp_send_ack(sk); + goto fully_established; + } + + /* we should process OoO packets before the first subflow is fully + * established, but not expected for MP_JOIN subflows + */ + if (TCP_SKB_CB(skb)->seq != subflow->ssn_offset + 1) + return subflow->mp_capable; if (mp_opt->use_ack) { + /* subflows are fully established as soon as we get any + * additional ack. + */ subflow->fully_established = 1; - if (subflow->mp_join) - mptcp_pm_subflow_established(mptcp_sk(subflow->conn), - subflow); + goto fully_established; } - if (subflow->can_ack) - return true; + WARN_ON_ONCE(subflow->can_ack); /* If the first established packet does not contain MP_CAPABLE + data * then fallback to TCP */ if (!mp_opt->mp_capable) { subflow->mp_capable = 0; - tcp_sk(mptcp_subflow_tcp_sock(subflow))->is_mptcp = 0; + tcp_sk(sk)->is_mptcp = 0; return false; } + + subflow->fully_established = 1; subflow->remote_key = mp_opt->sndr_key; subflow->can_ack = 1; + +fully_established: + /* msk can be null for MPC subflow on passive socket */ + if (subflow->pm_notified || !msk) + return true; + + subflow->pm_notified = 1; + if (subflow->mp_join) + mptcp_pm_subflow_established(msk, subflow); + else + mptcp_pm_fully_established(msk); return true; } @@ -596,7 +625,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb, struct mptcp_ext *mpext; mp_opt = &opt_rx->mptcp; - if (!check_fully_established(subflow, skb, mp_opt)) + if (!check_fully_established(msk, sk, subflow, skb, mp_opt)) return; if (msk && mp_opt->add_addr) { @@ -654,9 +683,6 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb, } mpext->data_fin = mp_opt->data_fin; - - if (msk) - mptcp_pm_fully_established(msk); } void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e10879368ab0..6129324d96e7 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1088,9 +1088,10 @@ bool mptcp_finish_join(struct sock *sk) return false; parent_sock = READ_ONCE(parent->sk_socket); - if (parent_sock) { - if (!sk->sk_socket) - mptcp_sock_graft(sk, parent_sock); + if (parent_sock && !sk->sk_socket) { + /* passive connection, attach to msk socket */ + mptcp_sock_graft(sk, parent_sock); + return mptcp_pm_allow_new_subflow(msk); } return true; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f2698dfe41f8..16fcc2f8e034 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -198,6 +198,7 @@ struct mptcp_subflow_context { mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */ fully_established : 1, /* path validated */ + pm_notified : 1, /* PM hook called for established status */ conn_finished : 1, map_valid : 1, mpc_map : 1, From patchwork Thu Mar 5 14:46:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249651 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=198.145.21.10; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HEk47+UK; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKL3tl4z9sSQ for ; Fri, 6 Mar 2020 01:53:58 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E960310FC3788; Thu, 5 Mar 2020 06:48:14 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DA34110FC3789 for ; Thu, 5 Mar 2020 06:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=woaIQucg3aUq/2ZIJRFkR6L5x95SrRAFQTddnpwp4U4=; b=HEk47+UKJAJ9RauqJL1IdM5nWDaByxiwpLT7ptyxOP7iRu1sWC6IT+qFxu3h6M1xp97TZi rLSpAq2Cy8dYnIL3f1fZCu0dXz7gayOQvgFJjLxQh7IL1HLNbnUWa14UbUzDj+PHUjoSKx /PTwmxKZilFOxjTCEy/5vuiOek1LvuY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-gV66pcmNPu2pYCawqNzYLg-1; Thu, 05 Mar 2020 09:47:18 -0500 X-MC-Unique: gV66pcmNPu2pYCawqNzYLg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC4341005510 for ; Thu, 5 Mar 2020 14:47:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FAA85D9C9 for ; Thu, 5 Mar 2020 14:47:17 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BHVNL5ZONDH5FSIKB2337O6WR2AYLTWY X-Message-ID-Hash: BHVNL5ZONDH5FSIKB2337O6WR2AYLTWY X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 4/12] Squash-to: "mptcp: Add handling of outgoing MP_JOIN requests" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Schedule 3rd ack retransmission via delack timer, and clear it on fully established event v1 -> v2: - clarified some comments (Mat) - reordered expression to detect 3rd ack for clarity (Mat) - dropped duplicate comment (Mat) Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 67 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 0e3e273131c4..5b61fd78c01c 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -341,6 +341,38 @@ void mptcp_rcv_synsent(struct sock *sk) } } +/* MP_JOIN client subflow must wait for 4th ack before sending any data: + * TCP can't schedule delack timer before the subflow is fully established. + * MPTCP uses the delack timer to do 3rd ack retransmissions + */ +static void schedule_3rdack_retransmission(struct sock *sk) +{ + struct inet_connection_sock *icsk = inet_csk(sk); + struct tcp_sock *tp = tcp_sk(sk); + unsigned long timeout; + + /* reschedule with a timeout above RTT, as we must look only for drop */ + if (tp->srtt_us) + timeout = tp->srtt_us << 1; + else + timeout = TCP_TIMEOUT_INIT; + + WARN_ON_ONCE(icsk->icsk_ack.pending & ICSK_ACK_TIMER); + icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER; + icsk->icsk_ack.timeout = timeout; + sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout); +} + +static void clear_3rdack_retransmission(struct sock *sk) +{ + struct inet_connection_sock *icsk = inet_csk(sk); + + sk_stop_timer(sk, &icsk->icsk_delack_timer); + icsk->icsk_ack.timeout = 0; + icsk->icsk_ack.ato = 0; + icsk->icsk_ack.pending &= ~(ICSK_ACK_SCHED | ICSK_ACK_TIMER); +} + static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, unsigned int *size, unsigned int remaining, @@ -350,17 +382,21 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, struct mptcp_ext *mpext; unsigned int data_len; - pr_debug("subflow=%p fully established=%d seq=%x:%x remaining=%d", - subflow, subflow->fully_established, subflow->snd_isn, - skb ? TCP_SKB_CB(skb)->seq : 0, remaining); + /* When skb is not available, we better over-estimate the emitted + * options len. A full DSS option (28 bytes) is longer than + * TCPOLEN_MPTCP_MPC_ACK_DATA(22) or TCPOLEN_MPTCP_MPJ_ACK(24), so + * tell the caller to defer the estimate to + * mptcp_established_options_dss(), which will reserve enough space. + */ + if (!skb) + return false; - if (subflow->mp_capable && !subflow->fully_established && skb && - subflow->snd_isn == TCP_SKB_CB(skb)->seq) { - /* When skb is not available, we better over-estimate the - * emitted options len. A full DSS option is longer than - * TCPOLEN_MPTCP_MPC_ACK_DATA, so let's the caller try to fit - * that. - */ + /* MPC/MPJ needed only on 3rd ack packet */ + if (subflow->fully_established || + subflow->snd_isn != TCP_SKB_CB(skb)->seq) + return false; + + if (subflow->mp_capable) { mpext = mptcp_get_ext(skb); data_len = mpext ? mpext->data_len : 0; @@ -388,12 +424,13 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, data_len); return true; - } else if (subflow->mp_join && !subflow->fourth_ack) { + } else if (subflow->mp_join) { opts->suboptions = OPTION_MPTCP_MPJ_ACK; memcpy(opts->hmac, subflow->hmac, MPTCPOPT_HMAC_LEN); *size = TCPOLEN_MPTCP_MPJ_ACK; - subflow->fourth_ack = 1; pr_debug("subflow=%p", subflow); + + schedule_3rdack_retransmission(sk); return true; } return false; @@ -633,10 +670,12 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, return true; subflow->pm_notified = 1; - if (subflow->mp_join) + if (subflow->mp_join) { + clear_3rdack_retransmission(sk); mptcp_pm_subflow_established(msk, subflow); - else + } else { mptcp_pm_fully_established(msk); + } return true; } From patchwork Thu Mar 5 14:46:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249655 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CXVgjz7C; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKM6YMQz9sSM for ; Fri, 6 Mar 2020 01:53:59 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1E23410FC3797; Thu, 5 Mar 2020 06:48:19 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.211.31.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C556E10FC377F for ; Thu, 5 Mar 2020 06:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/m8eieY4B/enjmCNnfiELhjdIipF2PUlZI/NAEqR5K8=; b=CXVgjz7C+T/vvxHGMjoexE+Qv+RS2DqxX/Y5iHqsav1B0tRMI7XrP+WNmUaGZxfy2f6MAH qKPBlCRDvB+zjMSR7RJxLwNfD2Phk/aDl3I9p7v369sqMhIexFyn1pSf7NTzzJw5fMta9w V/U9K+iM9x9utwHcSs3af25gMfpI0vM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-aqkgrTK4PNKBMd6NkDkk2Q-1; Thu, 05 Mar 2020 09:47:19 -0500 X-MC-Unique: aqkgrTK4PNKBMd6NkDkk2Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3F2CE6782 for ; Thu, 5 Mar 2020 14:47:18 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B3565D9C9 for ; Thu, 5 Mar 2020 14:47:18 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:42 +0100 Message-Id: <0db2fb40deda2e09e28a1fed61a01eb9a179d1af.1583418572.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: O7GPDA2KWDVJ6DNZF574CPY4XDLXAPNV X-Message-ID-Hash: O7GPDA2KWDVJ6DNZF574CPY4XDLXAPNV X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 5/12] Squash-to: "mptcp: Implement path manager interface commands" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Adapt the mptcp_pm_fully_established() hook to the new call site. Additionally avoid useless work if we don't need to announce any address /create any subflows Signed-off-by: Paolo Abeni --- net/mptcp/pm.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 174fde4071e0..a3fe2371d41b 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -45,9 +45,23 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side) bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) { - pr_debug("msk=%p", msk); + struct mptcp_pm_data *pm = &msk->pm; + int ret; - return false; + pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows, + pm->subflows_max, READ_ONCE(pm->accept_subflow)); + + /* try to avoid acquiring the lock below */ + if (!READ_ONCE(pm->accept_subflow)) + return false; + + spin_lock_bh(&pm->lock); + ret = pm->subflows < pm->subflows_max; + if (ret && ++pm->subflows == pm->subflows_max) + WRITE_ONCE(pm->accept_subflow, false); + spin_unlock_bh(&pm->lock); + + return ret; } static bool mptcp_pm_schedule_work(struct mptcp_sock *msk, @@ -71,13 +85,13 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk) pr_debug("msk=%p", msk); /* try to avoid acquiring the lock below */ - if (READ_ONCE(pm->fully_established)) + if (!READ_ONCE(pm->work_pending)) return; spin_lock_bh(&pm->lock); - if (!READ_ONCE(pm->fully_established) && - mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED)) - WRITE_ONCE(pm->fully_established, true); + + if (READ_ONCE(pm->work_pending)) + mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED); spin_unlock_bh(&pm->lock); } From patchwork Thu Mar 5 14:46:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249647 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MqBQqwy8; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKK6Xffz9sSM for ; Fri, 6 Mar 2020 01:53:57 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 03C3010FC3789; Thu, 5 Mar 2020 06:48:17 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8B18E10FC377E for ; Thu, 5 Mar 2020 06:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b9wpKpkp7wHR/hkWZBubCTP2UdnHAi7YPEojIorUkrA=; b=MqBQqwy8wQo6RPKKs7oIRqS8Y2s7Z9fSEdNY7A8Kfrrr0QxztLAAJ9jen31OqfOiL/Xub8 yhY1J7+/Ywno8laZfKahF3gMALwUTYTr4jwDVjyOSnDNAFSmJ0py9ZAXW2L4TFCSKvyPQf gOAR+1fbyGIz0vjVJRXRtt+7oEY395g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-LXcGSXmaOsC17bPuSjTnHA-1; Thu, 05 Mar 2020 09:47:20 -0500 X-MC-Unique: LXcGSXmaOsC17bPuSjTnHA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AEF07801FA9 for ; Thu, 5 Mar 2020 14:47:19 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25BBA5D9C9 for ; Thu, 5 Mar 2020 14:47:18 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:43 +0100 Message-Id: <9bc5d0bf5dbd649ea83dffcae3a0e6980f3696cf.1583418573.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BF5CU7YNNFIROWHBGAGGELOGQVALX42C X-Message-ID-Hash: BF5CU7YNNFIROWHBGAGGELOGQVALX42C X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 6/12] Squash-to: "mptcp: allow dumping subflow context to userspace" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: fix after field name change. Additionally rename the exposed uAPI flags to be more consistent Signed-off-by: Paolo Abeni --- include/uapi/linux/mptcp.h | 18 +++++++++--------- net/mptcp/diag.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index d087048fb4a2..c564140d20f0 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -4,15 +4,15 @@ #include -#define MPTCP_SUBFLOW_FLAG_MCAP_REM BIT(0) -#define MPTCP_SUBFLOW_FLAG_MCAP_LOC BIT(1) -#define MPTCP_SUBFLOW_FLAG_JOIN_REM BIT(2) -#define MPTCP_SUBFLOW_FLAG_JOIN_LOC BIT(3) -#define MPTCP_SUBFLOW_FLAG_BKUP_REM BIT(4) -#define MPTCP_SUBFLOW_FLAG_BKUP_LOC BIT(5) -#define MPTCP_SUBFLOW_FLAG_4THACK BIT(6) -#define MPTCP_SUBFLOW_FLAG_CONNECTED BIT(7) -#define MPTCP_SUBFLOW_FLAG_MAPVALID BIT(8) +#define MPTCP_SUBFLOW_FLAG_MCAP_REM BIT(0) +#define MPTCP_SUBFLOW_FLAG_MCAP_LOC BIT(1) +#define MPTCP_SUBFLOW_FLAG_JOIN_REM BIT(2) +#define MPTCP_SUBFLOW_FLAG_JOIN_LOC BIT(3) +#define MPTCP_SUBFLOW_FLAG_BKUP_REM BIT(4) +#define MPTCP_SUBFLOW_FLAG_BKUP_LOC BIT(5) +#define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED BIT(6) +#define MPTCP_SUBFLOW_FLAG_CONNECTED BIT(7) +#define MPTCP_SUBFLOW_FLAG_MAPVALID BIT(8) enum { MPTCP_SUBFLOW_ATTR_UNSPEC, diff --git a/net/mptcp/diag.c b/net/mptcp/diag.c index 4b6d9f7e418f..a536586742f2 100644 --- a/net/mptcp/diag.c +++ b/net/mptcp/diag.c @@ -43,8 +43,8 @@ static int subflow_get_info(const struct sock *sk, struct sk_buff *skb) flags |= MPTCP_SUBFLOW_FLAG_BKUP_REM; if (sf->request_bkup) flags |= MPTCP_SUBFLOW_FLAG_BKUP_LOC; - if (sf->fourth_ack) - flags |= MPTCP_SUBFLOW_FLAG_4THACK; + if (sf->fully_established) + flags |= MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED; if (sf->conn_finished) flags |= MPTCP_SUBFLOW_FLAG_CONNECTED; if (sf->map_valid) From patchwork Thu Mar 5 14:46:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249650 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=198.145.21.10; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UYLm4Exb; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKL31Wzz9sSN for ; Fri, 6 Mar 2020 01:53:58 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0B8FC10FC3791; Thu, 5 Mar 2020 06:48:17 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1F64910FC378F for ; Thu, 5 Mar 2020 06:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MyHZEvSYd7dJSOTpnsnXtlBzI8mf9Fut094/zRafA/s=; b=UYLm4ExbTeD24bleGyQMbKhxb54jIlIC+Ey0yJdRK8s/LkeiQWp9OMW5rtBD9YmRPEx39r 58IDq8ugp5ZKwRP2nK0bPR7SXNJMpHP1dNT9ezuKr9qAnFJNFEsM8g19PY3bvuOyusZtbP nv0KO4s3r0zEfSxVJ/Xf5A+e6hFAw6E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-NXZm8Mi_M_e4X1WcX79EiA-1; Thu, 05 Mar 2020 09:47:21 -0500 X-MC-Unique: NXZm8Mi_M_e4X1WcX79EiA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99CC1107ACCC for ; Thu, 5 Mar 2020 14:47:20 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EED25DA2C for ; Thu, 5 Mar 2020 14:47:19 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:44 +0100 Message-Id: <022bd71ed0dd1e66e8a61796ea273547511cb494.1583418573.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 2EUW6WAAEVIF3QBUQV4JFE7QWMAPN72G X-Message-ID-Hash: 2EUW6WAAEVIF3QBUQV4JFE7QWMAPN72G X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 7/12] Squash-to: "mptcp: add MIB counter infrastructure" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Add more MP JOIN related counters, will help self-tests Signed-off-by: Paolo Abeni --- net/mptcp/mib.c | 3 +++ net/mptcp/mib.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index 4ab627e877d1..365bd574940c 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -16,6 +16,9 @@ static const struct snmp_mib mptcp_snmp_list[] = { SNMP_MIB_ITEM("MPTCPRetrans", MPTCP_MIB_RETRANSSEGS), SNMP_MIB_ITEM("MPJoinNoTokenFound", MPTCP_MIB_JOINNOTOKEN), SNMP_MIB_ITEM("MPJoinSynRx", MPTCP_MIB_JOINSYNRX), + SNMP_MIB_ITEM("MPJoinSynAckRx", MPTCP_MIB_JOINSYNACKRX), + SNMP_MIB_ITEM("MPJoinSynAckHMacFailure", MPTCP_MIB_JOINSYNACKMAC), + SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX), SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC), SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH), SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX), diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index d50b53e8209b..d7de340fc997 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -9,6 +9,9 @@ enum linux_mptcp_mib_field { MPTCP_MIB_RETRANSSEGS, /* Segments retransmitted at the MPTCP-level */ MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */ MPTCP_MIB_JOINSYNRX, /* Received a SYN + MP_JOIN */ + MPTCP_MIB_JOINSYNACKRX, /* Received a SYN/ACK + MP_JOIN */ + MPTCP_MIB_JOINSYNACKMAC, /* HMAC was wrong on SYN/ACK + MP_JOIN */ + MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN */ MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */ MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */ MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */ From patchwork Thu Mar 5 14:46:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249657 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=198.145.21.10; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EUwERfup; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKN13ndz9sNg for ; Fri, 6 Mar 2020 01:53:59 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 157C910FC3793; Thu, 5 Mar 2020 06:48:19 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 676D810FC377F for ; Thu, 5 Mar 2020 06:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fze7DReGrF5978kzAk4yPHMsCOnVPUSvuiov75LvKu4=; b=EUwERfupOtEGz/yPxpCFpC7O+m7kx7OojryyJjTg4xpkEUq3yDegN1NuAhCtliFmchZL+e HpA0qmhoIzVPozEKy+KcoTTGiqiIOpLVX6AaDWeWv6dlKheVk+XJSi2LT9DZ6Ruslicvet 0oyhkeJhYECkbn6EYx7sN3Y0QFx3N28= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-e3fMqJCPMTSPvEZmowr1lQ-1; Thu, 05 Mar 2020 09:47:22 -0500 X-MC-Unique: e3fMqJCPMTSPvEZmowr1lQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89A36E679D for ; Thu, 5 Mar 2020 14:47:21 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB065D9C9 for ; Thu, 5 Mar 2020 14:47:20 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:45 +0100 Message-Id: <40c76b96ceffa7226cd5b870b23a75bba4196984.1583418573.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: UL67V6ITDWBZWSCFDWKCQXYQYVTJZCPE X-Message-ID-Hash: UL67V6ITDWBZWSCFDWKCQXYQYVTJZCPE X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 8/12] Squash-to: "mptcp: increment MIB counters in a few places" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: incremente the newly introduced counters Signed-off-by: Paolo Abeni --- net/mptcp/subflow.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 639f3d6ac9dc..201a695a792b 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -252,6 +252,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) goto do_reset; subflow->conn_finished = 1; + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNACKRX); } else { do_reset: tcp_send_active_reset(sk, GFP_ATOMIC); @@ -374,8 +375,10 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, opt_rx.mptcp.mp_join = 0; mptcp_get_options(skb, &opt_rx); if (!opt_rx.mptcp.mp_join || - !subflow_hmac_valid(req, &opt_rx)) + !subflow_hmac_valid(req, &opt_rx)) { + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKMAC); return NULL; + } } create_child: @@ -407,6 +410,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, ctx->conn = (struct sock *)owner; if (!mptcp_finish_join(child)) goto close_child; + + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX); } } From patchwork Thu Mar 5 14:46:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249656 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KQpj/B28; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKN17Zhz9sSJ for ; Fri, 6 Mar 2020 01:53:59 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2687210FC379B; Thu, 5 Mar 2020 06:48:19 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.211.31.81; helo=us-smtp-delivery-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 14C2D10FC3793 for ; Thu, 5 Mar 2020 06:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gk3NJX0CJ8JTltk7bTn/8M9umBviKZYjuaJ9f0iLJXA=; b=KQpj/B28ZNfla3KDKiQ9Pe02q8bc57HOEeKJncl0tvuyvbnI5mrcyv+sXe17WnivVEwNI4 vlXuhJpQ7xtf7K5lQVKZ77hKiSwQiGJiYZgHFFV6nm/gH89giDFQV6saoODcnbn6Kqijwe Al/g2dC5VusflrlcsS/tY3IC+mUtjMo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-n2IA2coUOIyH83ASBgrShw-1; Thu, 05 Mar 2020 09:47:23 -0500 X-MC-Unique: n2IA2coUOIyH83ASBgrShw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74951107ACC4 for ; Thu, 5 Mar 2020 14:47:22 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDB735D9C9 for ; Thu, 5 Mar 2020 14:47:21 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: JMYZ6WRAXS5DRVWD56UBV25BSTGFI2U3 X-Message-ID-Hash: JMYZ6WRAXS5DRVWD56UBV25BSTGFI2U3 X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 9/12] Squash-to: "subflow: place further subflows on new 'join_list'" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: do not insert the new subflow on join list, if we are going to drop it Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2db55fb1be6b..b3eb886b9488 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1519,6 +1519,7 @@ bool mptcp_finish_join(struct sock *sk) struct mptcp_sock *msk = mptcp_sk(subflow->conn); struct sock *parent = (void *)msk; struct socket *parent_sock; + bool ret; pr_debug("msk=%p, subflow=%p", msk, subflow); @@ -1530,12 +1531,15 @@ bool mptcp_finish_join(struct sock *sk) if (parent_sock && !sk->sk_socket) { mptcp_sock_graft(sk, parent_sock); - /* active connections are already on conn_list */ - spin_lock_bh(&msk->join_list_lock); - if (!WARN_ON_ONCE(!list_empty(&subflow->node))) - list_add_tail(&subflow->node, &msk->join_list); - spin_unlock_bh(&msk->join_list_lock); - return mptcp_pm_allow_new_subflow(msk); + ret = mptcp_pm_allow_new_subflow(msk); + if (ret) { + /* active connections are already on conn_list */ + spin_lock_bh(&msk->join_list_lock); + if (!WARN_ON_ONCE(!list_empty(&subflow->node))) + list_add_tail(&subflow->node, &msk->join_list); + spin_unlock_bh(&msk->join_list_lock); + } + return ret; } return true; } From patchwork Thu Mar 5 14:46:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249648 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WZP6FWnG; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKK5vTcz9sQt for ; Fri, 6 Mar 2020 01:53:57 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 40E2610FC3794; Thu, 5 Mar 2020 06:48:24 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.211.31.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 949E710FC377F for ; Thu, 5 Mar 2020 06:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rSr3rCgUrOXnpT3IY0bTKF5Ydbv0MQy7BxY7gJTKb9U=; b=WZP6FWnG005FBE2ZJEE6lrh1y5EB2aFwpyRa42Nx6KUL8/ZEW4TK3Zwr6z4eXzLFKzxNww 8e8L8E4KizwFouvTL2S/wRfuEBXouufTdoURWyY6szyn96Qd5OmX7E+C9kF1lBXN9Uon3I f0xDCV5AJcCdeZzfATIPtK2os6vm7qo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-98yK3vz6OZOuF-TWHOiNhQ-1; Thu, 05 Mar 2020 09:47:24 -0500 X-MC-Unique: 98yK3vz6OZOuF-TWHOiNhQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62ED4800D4E for ; Thu, 5 Mar 2020 14:47:23 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7CE95D9C9 for ; Thu, 5 Mar 2020 14:47:22 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:47 +0100 Message-Id: <49babca922e5470d11d4277eddde792fa9e3d2d0.1583418573.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: IDZ642PELKUE2365XVHMWALU77DYPWSJ X-Message-ID-Hash: IDZ642PELKUE2365XVHMWALU77DYPWSJ X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 10/12] Squash-to: "mptcp: add netlink based PM" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Implement support for max subflow limits, updating the APIs. Be sure to avoid any pending work if the subflows limit will block that. Fix an issue in local address lookup: we must traverse also the join_list. Signed-off-by: Paolo Abeni --- include/uapi/linux/mptcp.h | 5 +- net/mptcp/pm_netlink.c | 93 +++++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 29 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 92414f3d1463..d061c5a6ae05 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -45,6 +45,7 @@ enum mptcp_pm_attrs { MPTCP_PM_ATTR_ADDR, /* nested address */ MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */ + MPTCP_PM_ATTR_SUBFLOWS, /* u32 */ __MPTCP_PM_ATTR_MAX }; @@ -78,8 +79,8 @@ enum { MPTCP_PM_CMD_DEL_ADDR, MPTCP_PM_CMD_GET_ADDR, MPTCP_PM_CMD_FLUSH_ADDRS, - MPTCP_PM_CMD_SET_RCV_ADD_ADDRS, - MPTCP_PM_CMD_GET_RCV_ADD_ADDRS, + MPTCP_PM_CMD_SET_LIMITS, + MPTCP_PM_CMD_GET_LIMITS, __MPTCP_PM_CMD_AFTER_LAST }; diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 0887fae982fc..adfea3b85606 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -35,6 +35,7 @@ struct pm_nl_pernet { unsigned int add_addr_signal_max; unsigned int add_addr_accept_max; unsigned int local_addr_max; + unsigned int subflows_max; unsigned int next_id; }; @@ -89,14 +90,14 @@ static void remote_address(const struct sock_common *skc, #endif } -static bool lookup_subflow_by_saddr(const struct mptcp_sock *msk, +static bool lookup_subflow_by_saddr(const struct list_head *list, struct mptcp_addr_info *saddr) { struct mptcp_subflow_context *subflow; struct mptcp_addr_info cur; struct sock_common *skc; - list_for_each_entry(subflow, &msk->conn_list, node) { + list_for_each_entry(subflow, list, node) { skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow); local_address(skc, &cur); @@ -109,20 +110,27 @@ static bool lookup_subflow_by_saddr(const struct mptcp_sock *msk, static struct mptcp_pm_addr_entry * select_local_address(const struct pm_nl_pernet *pernet, - const struct mptcp_sock *msk) + struct mptcp_sock *msk) { struct mptcp_pm_addr_entry *entry, *ret = NULL; rcu_read_lock(); + spin_lock_bh(&msk->join_list_lock); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) continue; + + /* avoid any address already in use by subflows and + * pending join + */ if (entry->addr.family == ((struct sock *)msk)->sk_family && - !lookup_subflow_by_saddr(msk, &entry->addr)) { + !lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) && + !lookup_subflow_by_saddr(&msk->join_list, &entry->addr)) { ret = entry; break; } } + spin_unlock_bh(&msk->join_list_lock); rcu_read_unlock(); return ret; } @@ -154,7 +162,8 @@ select_signal_address(struct pm_nl_pernet *pernet, unsigned int pos) static void check_work_pending(struct mptcp_sock *msk) { if (msk->pm.add_addr_signaled == msk->pm.add_addr_signal_max && - msk->pm.local_addr_used == msk->pm.local_addr_max) + (msk->pm.local_addr_used == msk->pm.local_addr_max || + (msk->pm.subflows == msk->pm.subflows_max))) WRITE_ONCE(msk->pm.work_pending, false); } @@ -192,12 +201,14 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) } /* check if should create a new subflow */ - if (msk->pm.local_addr_used < msk->pm.local_addr_max) { + if (msk->pm.local_addr_used < msk->pm.local_addr_max && + msk->pm.subflows < msk->pm.subflows_max) { remote_address((struct sock_common *)sk, &remote); local = select_local_address(pernet, msk); if (local) { msk->pm.local_addr_used++; + msk->pm.subflows++; check_work_pending(msk); spin_unlock_bh(&msk->pm.lock); __mptcp_subflow_connect(sk, local->ifindex, @@ -239,7 +250,10 @@ void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) pr_debug("accepted %d:%d remote family %d", msk->pm.add_addr_accepted, msk->pm.add_addr_accept_max, msk->pm.remote.family); - if (++msk->pm.add_addr_accepted >= msk->pm.add_addr_accept_max) + msk->pm.add_addr_accepted++; + msk->pm.subflows++; + if (msk->pm.add_addr_accepted >= msk->pm.add_addr_accept_max || + msk->pm.subflows >= msk->pm.subflows_max) WRITE_ONCE(msk->pm.accept_addr, false); /* connect to the specified remote address, using whatever @@ -352,16 +366,21 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) void mptcp_pm_nl_data_init(struct mptcp_sock *msk) { + struct mptcp_pm_data *pm = &msk->pm; struct pm_nl_pernet *pernet; + bool subflows; pernet = net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id); - msk->pm.add_addr_signal_max = READ_ONCE(pernet->add_addr_signal_max); - msk->pm.add_addr_accept_max = READ_ONCE(pernet->add_addr_accept_max); - msk->pm.local_addr_max = READ_ONCE(pernet->local_addr_max); - WRITE_ONCE(msk->pm.work_pending, - !!msk->pm.local_addr_max || !!msk->pm.add_addr_signal_max); - WRITE_ONCE(msk->pm.accept_addr, !!msk->pm.add_addr_accept_max); + pm->add_addr_signal_max = READ_ONCE(pernet->add_addr_signal_max); + pm->add_addr_accept_max = READ_ONCE(pernet->add_addr_accept_max); + pm->local_addr_max = READ_ONCE(pernet->local_addr_max); + pm->subflows_max = READ_ONCE(pernet->subflows_max); + subflows = !!pm->subflows_max; + WRITE_ONCE(pm->work_pending, (!!pm->local_addr_max && subflows) || + !!pm->add_addr_signal_max); + WRITE_ONCE(pm->accept_addr, !!pm->add_addr_accept_max && subflows); + WRITE_ONCE(pm->accept_subflow, subflows); } #define MPTCP_PM_CMD_GRP_OFFSET 0 @@ -386,6 +405,7 @@ static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX + 1] = { [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_addr_policy), [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, }; static int mptcp_pm_family_to_addr(int family) @@ -690,31 +710,46 @@ static int mptcp_nl_cmd_dump_addrs(struct sk_buff *msg, return msg->len; } -static int -mptcp_nl_cmd_set_rcv_add_addrs(struct sk_buff *skb, struct genl_info *info) +static int parse_limit(struct genl_info *info, int id, unsigned int *limit) { - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_RCV_ADD_ADDRS]; - struct pm_nl_pernet *pernet = genl_info_pm_nl(info); - int limit; + struct nlattr *attr = info->attrs[id]; if (!attr) { GENL_SET_ERR_MSG(info, "missing announce accept limit"); return -EINVAL; } - limit = nla_get_u32(attr); - if (limit > MPTCP_PM_ADDR_MAX) { + *limit = nla_get_u32(attr); + if (*limit > MPTCP_PM_ADDR_MAX) { GENL_SET_ERR_MSG(info, "announce accept limit greater than maximum"); return -EINVAL; } + return 0; +} - WRITE_ONCE(pernet->add_addr_accept_max, limit); +static int +mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info) +{ + struct pm_nl_pernet *pernet = genl_info_pm_nl(info); + unsigned int rcv_addrs, subflows; + int ret; + + ret = parse_limit(info, MPTCP_PM_ATTR_RCV_ADD_ADDRS, &rcv_addrs); + if (ret) + return ret; + + ret = parse_limit(info, MPTCP_PM_ATTR_SUBFLOWS, &subflows); + if (ret) + return ret; + + WRITE_ONCE(pernet->add_addr_accept_max, rcv_addrs); + WRITE_ONCE(pernet->subflows_max, subflows); return 0; } static int -mptcp_nl_cmd_get_rcv_add_addrs(struct sk_buff *skb, struct genl_info *info) +mptcp_nl_cmd_get_limits(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct sk_buff *msg; @@ -725,7 +760,7 @@ mptcp_nl_cmd_get_rcv_add_addrs(struct sk_buff *skb, struct genl_info *info) return -ENOMEM; reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, - MPTCP_PM_CMD_GET_RCV_ADD_ADDRS); + MPTCP_PM_CMD_GET_LIMITS); if (!reply) goto fail; @@ -733,6 +768,10 @@ mptcp_nl_cmd_get_rcv_add_addrs(struct sk_buff *skb, struct genl_info *info) READ_ONCE(pernet->add_addr_accept_max))) goto fail; + if (nla_put_u32(msg, MPTCP_PM_ATTR_SUBFLOWS, + READ_ONCE(pernet->subflows_max))) + goto fail; + genlmsg_end(msg, reply); return genlmsg_reply(msg, info); @@ -765,13 +804,13 @@ static struct genl_ops mptcp_pm_ops[] = { .flags = GENL_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_SET_RCV_ADD_ADDRS, - .doit = mptcp_nl_cmd_set_rcv_add_addrs, + .cmd = MPTCP_PM_CMD_SET_LIMITS, + .doit = mptcp_nl_cmd_set_limits, .flags = GENL_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_GET_RCV_ADD_ADDRS, - .doit = mptcp_nl_cmd_get_rcv_add_addrs, + .cmd = MPTCP_PM_CMD_GET_LIMITS, + .doit = mptcp_nl_cmd_get_limits, .flags = GENL_ADMIN_PERM, }, }; From patchwork Thu Mar 5 14:46:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249654 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=198.145.21.10; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MBAlXo/y; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKM6nZxz9sSR for ; Fri, 6 Mar 2020 01:53:59 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 30A9D10FC378F; Thu, 5 Mar 2020 06:48:20 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.120; helo=us-smtp-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 35CA910FC379E for ; Thu, 5 Mar 2020 06:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UNvtNQ5q17MacvLrlj9Yt0oRyN+wRcAkWmAmX/2bB4E=; b=MBAlXo/yzHQ0KQltIbZeg7nU4rOxYNOqGgpYviWM3qr1K2fgfNvDIAt84RvHC4k13auhzt dtLU4+j8g9WXUETsAuBe71w5IEm8glD766Ek0jqAJAXtzI6DNnW6nDdcokqJ0Z5umiTQ9H 7pMb5Eom4/VcBVMwiDCXmEvnSTa7bMM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-biNQBMD8PjmmStg3DB4Dag-1; Thu, 05 Mar 2020 09:47:25 -0500 X-MC-Unique: biNQBMD8PjmmStg3DB4Dag-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C1D9E6782 for ; Thu, 5 Mar 2020 14:47:24 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6D615D9C9 for ; Thu, 5 Mar 2020 14:47:23 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: R4JVPLWTDVP2ODHUFTLBI2DMDMBPU3KE X-Message-ID-Hash: R4JVPLWTDVP2ODHUFTLBI2DMDMBPU3KE X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 11/12] Squash-to: "selftests: add PM netlink functional tests" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: update to new NL APIs add checks for subflows limits Signed-off-by: Paolo Abeni --- .../testing/selftests/net/mptcp/pm_netlink.sh | 17 +++++-- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 46 ++++++++++++------- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index a6552eb8acbe..cfc743c47cb2 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -69,7 +69,8 @@ check() } check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" -check "ip netns exec $ns1 ./pm_nl_ctl accept" "accept 0" "defaults accept add addr" +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +subflows 0" "defaults limits" ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo @@ -114,10 +115,16 @@ id 8 flags signal 10.0.1.8 " "id limit" ip netns exec $ns1 ./pm_nl_ctl flush check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" -ip netns exec $ns1 ./pm_nl_ctl accept 9 -check "ip netns exec $ns1 ./pm_nl_ctl accept" "accept 0" "above accept add_addr hard limit" +ip netns exec $ns1 ./pm_nl_ctl limits 9 1 +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +subflows 0" "rcv addrs above hard limit" -ip netns exec $ns1 ./pm_nl_ctl accept 8 -check "ip netns exec $ns1 ./pm_nl_ctl accept" "accept 8" "set accept add_addr" +ip netns exec $ns1 ./pm_nl_ctl limits 1 9 +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +subflows 0" "subflows above hard limit" + +ip netns exec $ns1 ./pm_nl_ctl limits 8 8 +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 8 +subflows 8" "set limits" exit $ret diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c index 66ce85a0ff98..cc3b9c5a3cff 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -30,7 +30,7 @@ static void syntax(char *argv[]) fprintf(stderr, "\tget \n"); fprintf(stderr, "\tflush\n"); fprintf(stderr, "\tdump\n"); - fprintf(stderr, "\taccept []\n"); + fprintf(stderr, "\tlimits [ ]\n"); exit(0); } @@ -501,7 +501,7 @@ int flush_addrs(int fd, int pm_family, int argc, char *argv[]) return 0; } -static void print_accept(struct nlmsghdr *nh, int pm_family, int total_len) +static void print_limits(struct nlmsghdr *nh, int pm_family, int total_len) { struct rtattr *attrs; uint32_t max; @@ -520,11 +520,15 @@ static void print_accept(struct nlmsghdr *nh, int pm_family, int total_len) attrs = (struct rtattr *) ((char *) NLMSG_DATA(nh) + GENL_HDRLEN); while (RTA_OK(attrs, len)) { - if (attrs->rta_type != MPTCP_PM_ATTR_RCV_ADD_ADDRS) + int type = attrs->rta_type; + + if (type != MPTCP_PM_ATTR_RCV_ADD_ADDRS && + type != MPTCP_PM_ATTR_SUBFLOWS) goto next; memcpy(&max, RTA_DATA(attrs), 4); - printf("accept %u\n", max); + printf("%s %u\n", type == MPTCP_PM_ATTR_SUBFLOWS ? + "subflows": "accept", max); next: attrs = RTA_NEXT(attrs, len); @@ -532,22 +536,23 @@ static void print_accept(struct nlmsghdr *nh, int pm_family, int total_len) } } -int get_set_accept(int fd, int pm_family, int argc, char *argv[]) +int get_set_limits(int fd, int pm_family, int argc, char *argv[]) { char data[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct genlmsghdr)) + 1024]; + uint32_t rcv_addr = 0, subflows = 0; int cmd, len = sizeof(data); struct nlmsghdr *nh; - uint32_t max = 0; int off = 0; /* limit */ - if (argc == 3) { - max = atoi(argv[2]); - cmd = MPTCP_PM_CMD_SET_RCV_ADD_ADDRS; + if (argc == 4) { + rcv_addr = atoi(argv[2]); + subflows = atoi(argv[3]); + cmd = MPTCP_PM_CMD_SET_LIMITS; } else { - cmd = MPTCP_PM_CMD_GET_RCV_ADD_ADDRS; + cmd = MPTCP_PM_CMD_GET_LIMITS; } memset(data, 0, sizeof(data)); @@ -555,20 +560,27 @@ int get_set_accept(int fd, int pm_family, int argc, char *argv[]) off = init_genl_req(data, pm_family, cmd, MPTCP_PM_VER); /* limit */ - if (cmd == MPTCP_PM_CMD_SET_RCV_ADD_ADDRS) { + if (cmd == MPTCP_PM_CMD_SET_LIMITS) { struct rtattr *rta = (void *)(data + off); rta->rta_type = MPTCP_PM_ATTR_RCV_ADD_ADDRS; rta->rta_len = RTA_LENGTH(4); - memcpy(RTA_DATA(rta), &max, 4); + memcpy(RTA_DATA(rta), &rcv_addr, 4); off += NLMSG_ALIGN(rta->rta_len); - cmd = MPTCP_PM_CMD_SET_RCV_ADD_ADDRS; + + rta = (void *)(data + off); + rta->rta_type = MPTCP_PM_ATTR_SUBFLOWS; + rta->rta_len = RTA_LENGTH(4); + memcpy(RTA_DATA(rta), &subflows, 4); + off += NLMSG_ALIGN(rta->rta_len); + + /* do not expect a reply */ len = 0; } len = do_nl_req(fd, nh, off, len); - if (cmd == MPTCP_PM_CMD_GET_RCV_ADD_ADDRS) - print_accept(nh, pm_family, len); + if (cmd == MPTCP_PM_CMD_GET_LIMITS) + print_limits(nh, pm_family, len); return 0; } @@ -595,8 +607,8 @@ int main(int argc, char *argv[]) return get_addr(fd, pm_family, argc, argv); else if (!strcmp(argv[1], "dump")) return dump_addrs(fd, pm_family, argc, argv); - else if (!strcmp(argv[1], "accept")) - return get_set_accept(fd, pm_family, argc, argv); + else if (!strcmp(argv[1], "limits")) + return get_set_limits(fd, pm_family, argc, argv); fprintf(stderr, "unknown sub-command: %s", argv[1]); syntax(argv); From patchwork Thu Mar 5 14:46:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1249653 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GiC3bcMQ; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YDKM51zJz9sPK for ; Fri, 6 Mar 2020 01:53:59 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4A39F10FC379F; Thu, 5 Mar 2020 06:48:24 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E681610FC377F for ; Thu, 5 Mar 2020 06:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583419647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2xNunEGL8wtk2snzm9DQiEG0fm3ZJVBM+G8szrOKgbA=; b=GiC3bcMQ/6LtiE++cIHUofhpmF9zocT1FpqZ+dNc71IQsv+SAJxvS7le4A0pxQeo/D3sym wjPQP0bMcRV4jC6waxrP2ZjitV4/YXkbEO7sv0v6qmHYByHcqYRYw3eGkjQfNH9//JfqJs frosDCiTLK1kcB71h2bwgPL3hBZOzLQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-8BukYRV8OmqhPhJh1qMgyg-1; Thu, 05 Mar 2020 09:47:26 -0500 X-MC-Unique: 8BukYRV8OmqhPhJh1qMgyg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36D0C800D4E for ; Thu, 5 Mar 2020 14:47:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id A098D5D9C9 for ; Thu, 5 Mar 2020 14:47:24 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Date: Thu, 5 Mar 2020 15:46:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 3IA53KYIIEGS2YPGJZVARSJ7JPOWGLI5 X-Message-ID-Hash: 3IA53KYIIEGS2YPGJZVARSJ7JPOWGLI5 X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH v2 12/12] Squash-to: "selftests: add test-cases for MPTCP MP_JOIN" List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Add tests for subflows limit enforcing. re-enable multiple subflows tests. cleanup data gathering via appropriate nstat command line options Signed-off-by: Paolo Abeni --- .../testing/selftests/net/mptcp/mptcp_join.sh | 100 ++++++++++++++---- 1 file changed, 79 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 799914cd973a..a724f9e1fa50 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -17,7 +17,6 @@ init() capout=$(mktemp) rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) - nstat="/tmp/.nstat.$rndh" ns1="ns1-$rndh" ns2="ns2-$rndh" @@ -53,7 +52,6 @@ init() cleanup_partial() { rm -f "$capout" - rm -f "$nstat" for netns in "$ns1" "$ns2"; do ip netns del $netns @@ -222,20 +220,50 @@ run_tests() chk_join_nr() { local msg="$1" - local ns=$2 - local nr=$3 + local syn_nr=$2 + local syn_ack_nr=$3 + local ack_nr=$4 local count + local dump_stats - count=`NSTAT_HISTORY=$nstat ip netns exec $ns nstat |grep MPTcpExtMPJoinSynRx | awk '{print $2}'` + printf "%-36s %s" "$msg" "syn" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` [ -z "$count" ] && count=0 - printf "%-50s %s" "$msg" - if [ "$count" != "$nr" ]; then - echo "[fail] got $count JOIN[s] expected $nr" + if [ "$count" != "$syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn expected $syn_nr" ret=1 + dump_stats=1 else - echo "[ ok ]" + echo -n "[ ok ]" fi + echo -n " - synack" + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$syn_ack_nr" ]; then + echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - ack" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack expected $ack_nr" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp + echo Client ns stats + ip netns exec $ns2 nstat -as | grep MPTcp + fi } sin=$(mktemp) @@ -248,49 +276,79 @@ make_file "$sin" "server" trap cleanup EXIT run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "no JOIN" $ns1 "0" +chk_join_nr "no JOIN" "0" "0" "0" + +# subflow limted by client +reset +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "single subflow, limited by client" 0 0 0 + +# subflow limted by server +reset +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "single subflow, limited by server" 1 1 0 # subflow reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "single subflow" $ns1 1 +chk_join_nr "single subflow" 1 1 1 # multiple subflows reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 0 2 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "multiple subflows" $ns1 2 +chk_join_nr "multiple subflows" 2 2 2 + + +# multiple subflows limited by serverf +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "multiple subflows, limited by server" 2 2 1 # add_address, unused reset ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "unused signal address" $ns1 0 +chk_join_nr "unused signal address" 0 0 0 # accept and use add_addr reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal -ip netns exec $ns2 ./pm_nl_ctl accept 1 run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "signal address" $ns1 1 +chk_join_nr "signal address" 1 1 1 # accept and use add_addr with an additional subflow reset ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal -ip netns exec $ns2 ./pm_nl_ctl accept 1 +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 1 2 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "subflow and signal" $ns1 2 +chk_join_nr "subflow and signal" 2 2 2 # accept and use add_addr with an additional subflows reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 3 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal -ip netns exec $ns2 ./pm_nl_ctl accept 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 3 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow -ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.2 flags signal +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "multiple subflows and signal" $ns1 3 +chk_join_nr "multiple subflows and signal" 3 3 3 -exit $ret \ No newline at end of file +exit $ret