From patchwork Fri Dec 13 14:33:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1209164 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.b="HKRrUlSv"; 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 47ZCpp1LtBz9sPh for ; Sat, 14 Dec 2019 01:34:09 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7847A1011368F; Fri, 13 Dec 2019 06:37:30 -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 E8F781011368B for ; Fri, 13 Dec 2019 06:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576247645; 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=pyUjHduUQF1v3an99O4BiJxn8rDnAyRZr3jQYlBvqws=; b=HKRrUlSvaeBkeFK7nINPMYeelaoERbI7kyGsd4+dkA19fELxDlN0M4wzvkaSznxvpfcfm3 cS/+ythnJ1EG/KOxmjBCVR7uzeH3XXb8QwvPS8X9XpUD6tleUGgSkf/h8/7qRSaJrFDreR kLApP3vT57LGikbOYAleXAeiEi3RNLI= 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-105-wvgNXgTqMpCZoCpu9l9SCA-1; Fri, 13 Dec 2019 09:34:03 -0500 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 59A7518FF666; Fri, 13 Dec 2019 14:34:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-236.ams2.redhat.com [10.36.117.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A5C45D9E2; Fri, 13 Dec 2019 14:34:01 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org, Florian Westphal Date: Fri, 13 Dec 2019 15:33:49 +0100 Message-Id: <8599ff8e65531ddfa8d0cd110e89b2e82bd9368c.1576247361.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: wvgNXgTqMpCZoCpu9l9SCA-1 X-Mimecast-Spam-Score: 0 Message-ID-Hash: 4CFWCABO3EDPEFOI7JS6MZ4XJ2UY4KGN X-Message-ID-Hash: 4CFWCABO3EDPEFOI7JS6MZ4XJ2UY4KGN 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] [RFC PATCH 1/4] mptcp: add helper to forcefully fallback the msk socket to TCP List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: will be used in later patch Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index c15232461a61..b6d753ed8397 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -24,6 +24,38 @@ #define MPTCP_SAME_STATE TCP_MAX_STATES +static void __mptcp_close(struct sock *sk, long timeout); + +/* MP_CAPABLE handshake failed, convert msk to plain tcp, replacing + * socket->sk and stream ops and destroying msk + * return the msk socket, as we can't access msk anymore after this function + * completes + */ +static struct socket *__mptcp_fallback_to_tcp(struct mptcp_sock *msk, + struct sock *ssk) +{ + struct mptcp_subflow_context *subflow; + struct socket *sock; + struct sock *sk; + + sk = (struct sock *)msk; + sock = sk->sk_socket; + subflow = mptcp_subflow_ctx(ssk); + + /* detach the msk socket */ + list_del_init(&subflow->node); + sock_orphan(sk); + + /* socket is now TCP */ + sock_graft(ssk, sock); + sock->ops = sk->sk_family == AF_INET6 ? &inet6_stream_ops : + &inet_stream_ops; + + /* destroy the left-over msk sock */ + __mptcp_close(sk, 0); + return sock; +} + /* if msk has a single subflow socket, and the mp_capable handshake is not * completed yet or has failed - that is, the socket is Not MP Capable, * returns it. @@ -561,7 +593,7 @@ static void mptcp_subflow_shutdown(struct sock *ssk, int how) release_sock(ssk); } -static void mptcp_close(struct sock *sk, long timeout) +static void __mptcp_close(struct sock *sk, long timeout) { struct mptcp_subflow_context *subflow, *tmp; struct mptcp_sock *msk = mptcp_sk(sk); @@ -569,8 +601,6 @@ static void mptcp_close(struct sock *sk, long timeout) mptcp_token_destroy(msk->token); inet_sk_state_store(sk, TCP_CLOSE); - lock_sock(sk); - list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { struct sock *ssk = mptcp_subflow_tcp_sock(subflow); @@ -583,6 +613,12 @@ static void mptcp_close(struct sock *sk, long timeout) sk_common_release(sk); } +static void mptcp_close(struct sock *sk, long timeout) +{ + lock_sock(sk); + __mptcp_close(sk, timeout); +} + static void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk) { const struct ipv6_pinfo *ssk6 = inet6_sk(ssk); From patchwork Fri Dec 13 14:33:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1209166 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.b="KIrqv4rv"; 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 47ZCpp6tDTz9sPn for ; Sat, 14 Dec 2019 01:34:10 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 809D010113693; Fri, 13 Dec 2019 06:37:30 -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 4D93B1011368B for ; Fri, 13 Dec 2019 06:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576247645; 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=qamSqdhb2e+x8345MfosypJaMgupcfnsd4fLs4VHegQ=; b=KIrqv4rvLbw6rv4g0+f/e79Cpo3d3hOB+nBbFi1xtlPppJtpFAdMIa6PPMCGFmXbj3oQe0 l8e8Lk7ViLaBH9IET3fn1jbtAL3cEyWqNmrHbLyNJIlNXyBGmjgmxHRAlhoiTsYDWbtpX7 QmDym07768zmCrMP/D/OF/6DcZQx/Mo= 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-61-wXNcVAgDMFO5V2Xa4wd6Cw-1; Fri, 13 Dec 2019 09:34:04 -0500 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 69B66107ACC5; Fri, 13 Dec 2019 14:34:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-236.ams2.redhat.com [10.36.117.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB6885DA70; Fri, 13 Dec 2019 14:34:02 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org, Florian Westphal Date: Fri, 13 Dec 2019 15:33:50 +0100 Message-Id: <61271bff5252d53a660a6e91bafc7c2c9899a319.1576247361.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: wXNcVAgDMFO5V2Xa4wd6Cw-1 X-Mimecast-Spam-Score: 0 Message-ID-Hash: DHZHXPY4AHOK4ENTXCQ3XHXKSUGYCF4I X-Message-ID-Hash: DHZHXPY4AHOK4ENTXCQ3XHXKSUGYCF4I 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] [RFC PATCH 2/4] mptcp: cache the first subflow sock List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: so that we can easily check for TCP fallback Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 6 +++++- net/mptcp/protocol.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b6d753ed8397..1d21b64b2149 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -87,7 +87,7 @@ static struct socket *__mptcp_tcp_fallback(const struct mptcp_sock *msk) static bool __mptcp_can_create_subflow(const struct mptcp_sock *msk) { - return ((struct sock *)msk)->sk_state == TCP_CLOSE; + return !msk->first; } static struct socket *__mptcp_socket_create(struct mptcp_sock *msk, int state) @@ -108,6 +108,7 @@ static struct socket *__mptcp_socket_create(struct mptcp_sock *msk, int state) if (err) return ERR_PTR(err); + msk->first = ssock->sk; msk->subflow = ssock; subflow = mptcp_subflow_ctx(ssock->sk); list_add(&subflow->node, &msk->conn_list); @@ -559,6 +560,8 @@ static int __mptcp_init_sock(struct sock *sk) INIT_LIST_HEAD(&msk->conn_list); __set_bit(MPTCP_SEND_SPACE, &msk->flags); + msk->first = NULL; + return 0; } @@ -688,6 +691,7 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err, msk->local_key = subflow->local_key; msk->token = subflow->token; msk->subflow = NULL; + msk->first = newsk; mptcp_token_update_accept(newsk, new_mptcp_sock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 0e5ba5ac1443..b4cf88258b6b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -73,6 +73,7 @@ struct mptcp_sock { struct list_head conn_list; struct skb_ext *cached_ext; /* for the next sendmsg */ struct socket *subflow; /* outgoing connect/listener/!mp_capable */ + struct sock *first; }; #define mptcp_for_each_subflow(__msk, __subflow) \ From patchwork Fri Dec 13 14:33:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1209168 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.b="Om9ym2dY"; 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 47ZCpv1tkfz9sRC for ; Sat, 14 Dec 2019 01:34:14 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A913610113690; Fri, 13 Dec 2019 06:37:35 -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-2.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 E709B10113699 for ; Fri, 13 Dec 2019 06:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576247647; 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=cchlIHvdNMNVGxGz0je8jaxEWt3YjtHViS/0jswqZRc=; b=Om9ym2dYThjhtcjJwBkYcd7kC4MsyOcUA2eXKTWqPCyHLGls4JSHus3ysGUM7M9H0v2TQ6 Y5kXagc/JZwPiB/yUEFHbxJQvgD0PuJV9mjNKfybfHCsC3oRbz4czwXBLh8kpZeR2XAhmx gjhF5I09BOpHKVUyQuc+hmZPHB69OCg= 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-157-eSN8S3SFOjG9QjLGO7cHHg-1; Fri, 13 Dec 2019 09:34:05 -0500 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 754F8800D4C; Fri, 13 Dec 2019 14:34:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-236.ams2.redhat.com [10.36.117.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8A355D9CA; Fri, 13 Dec 2019 14:34:03 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org, Florian Westphal Date: Fri, 13 Dec 2019 15:33:51 +0100 Message-Id: <1ff9c849d5246c75ce15e707e1b3377958a08600.1576247361.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: eSN8S3SFOjG9QjLGO7cHHg-1 X-Mimecast-Spam-Score: 0 Message-ID-Hash: ZAIKJQ5KD4OU4ZFTZS5IQ3VZMXVIC2XI X-Message-ID-Hash: ZAIKJQ5KD4OU4ZFTZS5IQ3VZMXVIC2XI 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] [RFC PATCH 3/4] mptcp: late fallback support List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: passive connection can fallback tcp, too. Additionally it can happens after that the subflow become established: syn+ MP_CAPABLE -> <- syn, ack + MP_CAPABLE ack, seq = 3 -> // OoO packet is accepted because in-sequence // passive socket is created, is in ESTABLISHED // status and tentatively as MP_CAPABLE ack, seq = 2 -> // no MP_CAPABLE opt, subflow should fallback to TCP Currently that will lead to disaster, in several nasty ways. Deal with that "transitioning" the socket to tcp, replacing socket->sk with the tcp subflow and rearranging all the link, than calling the relevant operation on the now-tcp socket Co-developed-by: Florian Westphal Signed-off-by: Florian Westphal Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 1d21b64b2149..999b1f89b3d6 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -69,20 +69,32 @@ static struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk) return msk->subflow; } -/* if msk has a single subflow, and the mp_capable handshake is failed, +static bool __mptcp_needs_tcp_fallback(const struct mptcp_sock *msk) +{ + return msk->first && !tcp_sk(msk->first)->is_mptcp; +} + +/* if the mp_capable handshake is failed, return a tcp socket * return it. * Otherwise returns NULL */ -static struct socket *__mptcp_tcp_fallback(const struct mptcp_sock *msk) +static struct socket *__mptcp_tcp_fallback(struct mptcp_sock *msk) { - struct socket *ssock = __mptcp_nmpc_socket(msk); - sock_owned_by_me((const struct sock *)msk); - if (!ssock || tcp_sk(ssock->sk)->is_mptcp) + if (!likely(__mptcp_needs_tcp_fallback(msk))) return NULL; - return ssock; + if (msk->subflow) { + /* the first subflow is an active connection, discart the + * paired socket + */ + msk->subflow->sk = NULL; + sock_release(msk->subflow); + msk->subflow = NULL; + } + + return __mptcp_fallback_to_tcp(msk, msk->first); } static bool __mptcp_can_create_subflow(const struct mptcp_sock *msk) @@ -301,7 +313,6 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (ssock) { pr_debug("fallback passthrough"); ret = sock_sendmsg(ssock, msg); - release_sock(sk); return ret; } @@ -404,7 +415,6 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, pr_debug("fallback-read subflow=%p", mptcp_subflow_ctx(ssock->sk)); copied = sock_recvmsg(ssock, msg, flags); - release_sock(sk); return copied; } From patchwork Fri Dec 13 14:33:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1209169 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.b="MRjLSFpv"; 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 47ZCpv1tcfz9sR8 for ; Sat, 14 Dec 2019 01:34:14 +1100 (AEDT) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AFF2210113699; Fri, 13 Dec 2019 06:37:35 -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 04E2D1011368B for ; Fri, 13 Dec 2019 06:37:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576247650; 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=xd6HtNJJbhzU9VuHx7BvNFeV5RKhcKDw3NybtdIjAeA=; b=MRjLSFpv5268g8XH/XRCDDOE/KumJfHT44QEiv7fgnsf6RtV8QTHASqX1XLoA7SKzx7aht W+vKx6lT2B0IcOOc0Y3P8VnJ27rGf6nT9mjdp9qBf1C/hFV70fOI0Iai8E89Hfkm5z9wsj fosz3YL1E/8R7HuyRxOcQFdTfUoQxm0= 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-238-aMBD0he8NrCCigsSRyckrQ-1; Fri, 13 Dec 2019 09:34:06 -0500 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 80942DB2A; Fri, 13 Dec 2019 14:34:05 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-236.ams2.redhat.com [10.36.117.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4C7E5D9CA; Fri, 13 Dec 2019 14:34:04 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org, Florian Westphal Date: Fri, 13 Dec 2019 15:33:52 +0100 Message-Id: <2a28826e6748b33e04b28a733c537dd4d2a55dea.1576247361.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: aMBD0he8NrCCigsSRyckrQ-1 X-Mimecast-Spam-Score: 0 Message-ID-Hash: 3UZP2PHGMBTNFL5RYHVXHARCYNFH2T4Q X-Message-ID-Hash: 3UZP2PHGMBTNFL5RYHVXHARCYNFH2T4Q 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] [RFC PATCH 4/4] mptcp: deal with fallback in additional places. List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Everytime the msk socket ops block, a passive connection can complete with failure the MP_CAPABLE handshake, requiring transitioning to TCP. Signed-off-by: Paolo Abeni = 0 ? ret + copied : (copied ? copied : ret); } timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); @@ -332,6 +335,11 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) &size_goal); if (ret < 0) break; + if (ret == 0 && unlikely(__mptcp_needs_tcp_fallback(msk))) { + release_sock(ssk); + ssock = __mptcp_tcp_fallback(msk); + goto fallback; + } copied += ret; } @@ -412,6 +420,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, lock_sock(sk); ssock = __mptcp_tcp_fallback(msk); if (ssock) { +fallback: pr_debug("fallback-read subflow=%p", mptcp_subflow_ctx(ssock->sk)); copied = sock_recvmsg(ssock, msg, flags); @@ -518,6 +527,8 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, pr_debug("block timeout %ld", timeo); wait_data = true; mptcp_wait_data(sk, &timeo); + if (unlikely(__mptcp_tcp_fallback(msk))) + goto fallback; } if (more_data_avail) { @@ -1057,8 +1068,8 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, static __poll_t mptcp_poll(struct file *file, struct socket *sock, struct poll_table_struct *wait) { - const struct mptcp_sock *msk; struct sock *sk = sock->sk; + struct mptcp_sock *msk; struct socket *ssock; __poll_t mask = 0; @@ -1074,6 +1085,9 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, release_sock(sk); sock_poll_wait(file, sock, wait); lock_sock(sk); + ssock = __mptcp_tcp_fallback(msk); + if (unlikely(ssock)) + return ssock->ops->poll(file, ssock, NULL); if (test_bit(MPTCP_DATA_READY, &msk->flags)) mask = EPOLLIN | EPOLLRDNORM;