From patchwork Tue Nov 5 17:05:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 1189851 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=none (p=none dis=none) header.from=strlen.de 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 476wyR32qbz9sP3 for ; Wed, 6 Nov 2019 04:05:02 +1100 (AEDT) Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2DC3B100DC42B; Tue, 5 Nov 2019 09:07:42 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a0a:51c0:0:12e:520::1; helo=chamillionaire.breakpoint.cc; envelope-from=fw@breakpoint.cc; receiver= Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4D2B2100DC429 for ; Tue, 5 Nov 2019 09:07:40 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1iS2GH-0000Qi-8t; Tue, 05 Nov 2019 18:04:57 +0100 From: Florian Westphal To: Cc: Florian Westphal Date: Tue, 5 Nov 2019 18:05:28 +0100 Message-Id: <20191105170531.30407-2-fw@strlen.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105170531.30407-1-fw@strlen.de> References: <20191105170531.30407-1-fw@strlen.de> MIME-Version: 1.0 Message-ID-Hash: ACFTIIQSSYKT4L5RYNB2SLO7C26LEO2L X-Message-ID-Hash: ACFTIIQSSYKT4L5RYNB2SLO7C26LEO2L X-MailFrom: fw@breakpoint.cc 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 mptcp 1/4] protocol.h: mptcp_subflow_get_map_offset arg can be const List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: squashto: mptcp: Implement MPTCP receive path Signed-off-by: Florian Westphal --- net/mptcp/protocol.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8fe5f9383d38..46f7becd9a45 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -248,7 +248,7 @@ mptcp_subflow_tcp_socket(const struct mptcp_subflow_context *subflow) } static inline u64 -mptcp_subflow_get_map_offset(struct mptcp_subflow_context *subflow) +mptcp_subflow_get_map_offset(const struct mptcp_subflow_context *subflow) { return tcp_sk(mptcp_subflow_tcp_socket(subflow)->sk)->copied_seq - subflow->ssn_offset - @@ -256,7 +256,7 @@ mptcp_subflow_get_map_offset(struct mptcp_subflow_context *subflow) } static inline u64 -mptcp_subflow_get_mapped_dsn(struct mptcp_subflow_context *subflow) +mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow) { return subflow->map_seq + mptcp_subflow_get_map_offset(subflow); } From patchwork Tue Nov 5 17:05:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 1189852 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=none (p=none dis=none) header.from=strlen.de 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 476wyV6Mtgz9sNT for ; Wed, 6 Nov 2019 04:05:06 +1100 (AEDT) Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 36FA9100DC428; Tue, 5 Nov 2019 09:07:46 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a0a:51c0:0:12e:520::1; helo=chamillionaire.breakpoint.cc; envelope-from=fw@breakpoint.cc; receiver= Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 976C2100DC425 for ; Tue, 5 Nov 2019 09:07:44 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1iS2GL-0000Qr-J5; Tue, 05 Nov 2019 18:05:01 +0100 From: Florian Westphal To: Cc: Florian Westphal Date: Tue, 5 Nov 2019 18:05:29 +0100 Message-Id: <20191105170531.30407-3-fw@strlen.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105170531.30407-1-fw@strlen.de> References: <20191105170531.30407-1-fw@strlen.de> MIME-Version: 1.0 Message-ID-Hash: QMU774DNALX4X7APBT7BJMFMKHIJOE2N X-Message-ID-Hash: QMU774DNALX4X7APBT7BJMFMKHIJOE2N X-MailFrom: fw@breakpoint.cc 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 mptcp 2/4] options: ignore mptcp-level ack that is ahead of write_seq List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: We should not allow a peer to ack data that we haven't even sent yet, so test incoming una vs. write_seq. squashto: mptcp: update per unacked sequence on pkt reception Signed-off-by: Florian Westphal --- net/mptcp/options.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 1b08e1193991..80dbe7662cea 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -566,12 +566,18 @@ static void update_una(struct mptcp_sock *msk, struct mptcp_options_received *mp_opt) { u64 new_snd_una, snd_una, old_snd_una = atomic64_read(&msk->snd_una); + u64 write_seq = READ_ONCE(msk->write_seq); /* avoid ack expansion on update conflict, to reduce the risk of * wrongly expanding to a future ack sequence number, which is way * more dangerous than missing an ack */ new_snd_una = expand_ack(old_snd_una, mp_opt->data_ack, mp_opt->ack64); + + /* ACK for data not even sent yet? Ignore. */ + if (after64(new_snd_una, write_seq)) + new_snd_una = old_snd_una; + while (after64(new_snd_una, old_snd_una)) { snd_una = old_snd_una; old_snd_una = atomic64_cmpxchg(&msk->snd_una, snd_una, From patchwork Tue Nov 5 17:05:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 1189853 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=none (p=none dis=none) header.from=strlen.de 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 476wyb4S94z9sNT for ; Wed, 6 Nov 2019 04:05:11 +1100 (AEDT) Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 43C51100DC428; Tue, 5 Nov 2019 09:07:51 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a0a:51c0:0:12e:520::1; helo=chamillionaire.breakpoint.cc; envelope-from=fw@breakpoint.cc; receiver= Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B457E100DC425 for ; Tue, 5 Nov 2019 09:07:49 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1iS2GP-0000R2-SC; Tue, 05 Nov 2019 18:05:05 +0100 From: Florian Westphal To: Cc: Florian Westphal Date: Tue, 5 Nov 2019 18:05:30 +0100 Message-Id: <20191105170531.30407-4-fw@strlen.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105170531.30407-1-fw@strlen.de> References: <20191105170531.30407-1-fw@strlen.de> MIME-Version: 1.0 Message-ID-Hash: SEONIQOGXHREXVVTZCEYYHYBRNN2QLNS X-Message-ID-Hash: SEONIQOGXHREXVVTZCEYYHYBRNN2QLNS X-MailFrom: fw@breakpoint.cc 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 mptcp 3/4] protocol: use sk_wait_event helper List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Avoids a bit of copy&paste code. squashto: mptcp: recvmsg() can drain data from multiple subflows Signed-off-by: Florian Westphal --- net/mptcp/protocol.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 3af5f121af9e..8cc9cc5675c2 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -443,22 +443,12 @@ static void mptcp_wait_data(struct sock *sk, long *timeo) { DEFINE_WAIT_FUNC(wait, woken_wake_function); struct mptcp_sock *msk = mptcp_sk(sk); - int data_ready; add_wait_queue(sk_sleep(sk), &wait); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); - release_sock(sk); - - smp_mb__before_atomic(); - data_ready = test_and_clear_bit(MPTCP_DATA_READY, &msk->flags); - smp_mb__after_atomic(); - - if (!data_ready) - *timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, *timeo); - - sched_annotate_sleep(); - lock_sock(sk); + sk_wait_event(sk, timeo, + test_and_clear_bit(MPTCP_DATA_READY, &msk->flags), &wait); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); remove_wait_queue(sk_sleep(sk), &wait); From patchwork Tue Nov 5 17:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 1189854 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=none (p=none dis=none) header.from=strlen.de 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 476wyg3LTHz9sP3 for ; Wed, 6 Nov 2019 04:05:15 +1100 (AEDT) Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4C89C100DC429; Tue, 5 Nov 2019 09:07:55 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a0a:51c0:0:12e:520::1; helo=chamillionaire.breakpoint.cc; envelope-from=fw@breakpoint.cc; receiver= Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4640D100DC42C for ; Tue, 5 Nov 2019 09:07:53 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1iS2GU-0000R9-95; Tue, 05 Nov 2019 18:05:10 +0100 From: Florian Westphal To: Cc: Florian Westphal Date: Tue, 5 Nov 2019 18:05:31 +0100 Message-Id: <20191105170531.30407-5-fw@strlen.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105170531.30407-1-fw@strlen.de> References: <20191105170531.30407-1-fw@strlen.de> MIME-Version: 1.0 Message-ID-Hash: 7VUQBN2E4IJRZKJG3BJ5ONF7VI4RKGCQ X-Message-ID-Hash: 7VUQBN2E4IJRZKJG3BJ5ONF7VI4RKGCQ X-MailFrom: fw@breakpoint.cc 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 mptcp 4/4] poll: release lock before waiting List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: else, this can block kworker thread forever -- it needs to lock the mptcp socket, so we should not hold this lock when waiting for events. squashto: mptcp: add mptcp_poll Signed-off-by: Florian Westphal --- net/mptcp/protocol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 8cc9cc5675c2..53b1b015d9d4 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1229,7 +1229,9 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, return ret; } + release_sock(sk); sock_poll_wait(file, sock, wait); + lock_sock(sk); mptcp_for_each_subflow(msk, subflow) { struct socket *tcp_sock;