From patchwork Wed May 26 16:08:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 12282225 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 855422FB4 for ; Wed, 26 May 2021 16:08:39 +0000 (UTC) Received: by mail-ej1-f47.google.com with SMTP id z12so3359110ejw.0 for ; Wed, 26 May 2021 09:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k273NB9wIyfKYG+Tl83ECdrDlxzxxBmfRV9onhRlQp0=; b=V9rkKZTOjHjf3NWaTo90znu4sw+OKVSserO7ezizGKFRNwEH8vx/waG9/u2JtAkfnC 9BNbmHUadlwXwFqiliD1T1nMU2jOoF5NIxRrcSp3HRwEnc4HgOrRkUhhDoA16oV39O5T 0crghWmKdQsWWma4o/wLosLY0wiWVM/iuxSmglDm3TccfNzUV1n1EzedHIlgttmWog3Y q+yORi2M/cBm26aw0LCkZm1ahfB0yymuF6vdsLShw8gD2ET+yOrtbFy85xVD06AUb6VG TnVDu5KP/uD5beqUqQ4Eti/n747eLbRBp/oVGM2Od4YukU3BG5q8SCvOa+8Hq0csHKej +P3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k273NB9wIyfKYG+Tl83ECdrDlxzxxBmfRV9onhRlQp0=; b=I25cbRJBR0+h2Wm17nKnn7+TJD36k2VWdYOcRFVUgrRBEykRSe26ACxYT/ASIa64JG uEJpv7cQAW2dk19TnOzPwvhBNGfatV7FxcDV2APuxIG3zMA+ajOgKYYbFJLeOn5adWIc xpsJ4K2W3pUEqnZK17kxIKbJGkYz4DDHpXfzL8wz/Jf/Qjg5px+l0Ld/8BzDcpxiaFY/ TU0myQRC/jAgAySzubhBbAMKfyvhglGUOTL7+mNouqIVFoGL37IoSftc0UbJz3Em4Xgv 24Y5yNv1Mv+lsF+6WmZeTF0rkItoQpOSGvLXbANVk+NzX5ZDfCqTmTzPw+L3Zb81Y5gS ghQA== X-Gm-Message-State: AOAM530vv8nWc7oh7UmSkyOpG/rVTnJxZzwGH8b6uugdhww5Fy9vskJk G5seMXb89iYEyfGXjG0DkVXoxlFp3faiuTKF X-Google-Smtp-Source: ABdhPJyogBRbNKWEKrHE9qoMCIdO1oZZG/4GLnEocBR6faoCjCQQ7Hxq7nPFTQPro7x73Ee9Y/sBIA== X-Received: by 2002:a17:906:76c6:: with SMTP id q6mr22048328ejn.387.1622045317986; Wed, 26 May 2021 09:08:37 -0700 (PDT) Received: from tsr-vdi-mbaerts.nix.tessares.net (static.23.216.130.94.clients.your-server.de. [94.130.216.23]) by smtp.gmail.com with ESMTPSA id j7sm931655ejk.51.2021.05.26.09.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 09:08:37 -0700 (PDT) From: Matthieu Baerts To: mptcp@lists.linux.dev Cc: Florian Westphal Subject: [RESEND] [MPTCP] [PATCH MPTCP 1/5] tcp: make two mptcp helpers available to tcp stack Date: Wed, 26 May 2021 18:08:09 +0200 Message-ID: <20201105170126.5627-2-fw@strlen.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526160813.4160315-1-matthieu.baerts@tessares.net> References: <20210526160813.4160315-1-matthieu.baerts@tessares.net> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20210526160809.rTj9ASQ134zS4-WNEx5nzBlazpJOKqv2wxIt7V8L19w@z> From: Florian Westphal needed by followup patches to add mptcp reset (and fastclose) options to tcp reset packets. Signed-off-by: Florian Westphal --- include/net/mptcp.h | 10 ++++++++++ include/net/tcp.h | 5 +++++ net/mptcp/protocol.h | 11 ----------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index b6cf07143a8a..3d57607982fa 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -78,6 +78,11 @@ static inline bool rsk_drop_req(const struct request_sock *req) return tcp_rsk(req)->is_mptcp && tcp_rsk(req)->drop_req; } +static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) +{ + return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP); +} + void mptcp_space(const struct sock *ssk, int *space, int *full_space); bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, unsigned int *size, struct mptcp_out_options *opts); @@ -169,6 +174,11 @@ static inline bool rsk_drop_req(const struct request_sock *req) return false; } +static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) +{ + return NULL; +} + static inline void mptcp_parse_option(const struct sk_buff *skb, const unsigned char *ptr, int opsize, struct tcp_options_received *opt_rx) diff --git a/include/net/tcp.h b/include/net/tcp.h index f3d42cb626fc..8115164e0df6 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2377,4 +2377,9 @@ static inline u64 tcp_transmit_time(const struct sock *sk) return 0; } +static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) +{ + return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) | + ((nib & 0xF) << 8) | field); +} #endif /* _TCP_H */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d29c6a4749eb..66bd4d096753 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -139,12 +139,6 @@ struct mptcp_options_received { u16 port; }; -static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) -{ - return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) | - ((nib & 0xF) << 8) | field); -} - struct mptcp_addr_info { sa_family_t family; __be16 port; @@ -568,11 +562,6 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk); void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); -static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) -{ - return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP); -} - void mptcp_diag_subflow_init(struct tcp_ulp_ops *ops); static inline bool __mptcp_check_fallback(const struct mptcp_sock *msk) From patchwork Wed May 26 16:08:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 12282219 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C8D92F80 for ; Wed, 26 May 2021 16:08:37 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id o5so2197266edc.5 for ; Wed, 26 May 2021 09:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2R7IB3T8nXkD3Z9xfKk+7vNzqPqPAMPWq/WLiAQ3S9E=; b=bOem0Za/rcxp2rUARsm4ezRrbv8sLvGyDnRL1NFcaJc7J0XEM45wpH4pvuMTkwwfGQ f4uAoqr/S467G49vD57SHMDAqGiK7FXBQrKi+UPD/Iz3gRLhotGCCf376M/r7xEgDoLz rf2vkZcvi4UNbYVqJXXrbjBz6GwsbhTDJoIeR3k0ugogopsyatXk6zOdNgxFJLUHKl7Y SyOK5DZn9Fe2JHTr/l/W0SlNXeTVFO0J9LhUITRY+LAtRasFFEpcLabUwyKsNBO+Rj4k 2WRFbJuBhJMllVoRypP2RczQXcsuPN8g04GvR9wBehsBL4bnGi5d0/DOhff1T4klPkx+ ngOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2R7IB3T8nXkD3Z9xfKk+7vNzqPqPAMPWq/WLiAQ3S9E=; b=M7UPhd/9u0TmoyDzfHXwJt4z6+hMzCuMRAmDTK6omIWBQtM6z3Yi+et9slOdEJiuLt jq7Hh9KPeM9kYN8bvXGsQcaFh/xNaYRwpNuXxoUUac+eaAXu+Wses/K3Ji2YVKs/x9JP ThIGS3UhH4A5FnRr3GTXwR+ctuHwim0TJmk2NHQmK/Kwq3+Wxsni9Pb3gehf7zWdALxO tWAiIeZe1k0IIHzzaQSVHz5bAFgOkmLXFLwL+6HuRTOPJRo/8MDK44x+dipScK9zqc4O Xif+cuPm3ERAfS+oKGYSs7SatFjdF/vhDzU91Re2LMw4fYFdFiQ+XptK+YNciAr9q42u LVfg== X-Gm-Message-State: AOAM5330avGPTv9q29RgYyuDvG4U14K4uPGS4pekHf2bD3qtfesKPhGK bkgNhko4AIEMWq8RkY8+wfoH1bEV1VqvLfkm X-Google-Smtp-Source: ABdhPJzbommUWU/1oNok1zZ9+0dyCHkzU7v7kFjId0z1/Yy9sz0OYhjnY2KRKX7NUQaRaG32E/vjkA== X-Received: by 2002:a05:6402:35c4:: with SMTP id z4mr37856452edc.362.1622045315802; Wed, 26 May 2021 09:08:35 -0700 (PDT) Received: from tsr-vdi-mbaerts.nix.tessares.net (static.23.216.130.94.clients.your-server.de. [94.130.216.23]) by smtp.gmail.com with ESMTPSA id j7sm931655ejk.51.2021.05.26.09.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 09:08:35 -0700 (PDT) From: Matthieu Baerts To: mptcp@lists.linux.dev Cc: Florian Westphal Subject: [RESEND] [MPTCP] [RFC PATCH 2/4] tcp: move selected mptcp helpers to tcp.h/mptcp.h Date: Wed, 26 May 2021 18:08:06 +0200 Message-ID: <20200924143505.27641-3-fw@strlen.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526160813.4160315-1-matthieu.baerts@tessares.net> References: <20210526160813.4160315-1-matthieu.baerts@tessares.net> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20210526160806.rIDA-4-syBCl_52leGyXIBVIYbqUskUiH4uMOJda5WU@z> From: Florian Westphal Will be needed to fill in the MPTCP reset option from tcp_ipv4/ipv6.c. It would make more sense to place mptcp_option() in mptcp.h, but TCPOPT_MPTCP is defined in tcp.h, and mptcp.h is included from tcp.h, not the other way around. Placing the helper in mptcp.h thus results in a build failure because TCPOPT_MPTCP is not defined. Signed-off-by: Florian Westphal --- include/net/mptcp.h | 10 ++++++++++ include/net/tcp.h | 5 +++++ net/mptcp/protocol.h | 11 ----------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 6e706d838e4e..5f5062580e0e 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -68,6 +68,11 @@ static inline bool sk_is_mptcp(const struct sock *sk) return tcp_sk(sk)->is_mptcp; } +static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) +{ + return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP); +} + static inline bool rsk_is_mptcp(const struct request_sock *req) { return tcp_rsk(req)->is_mptcp; @@ -153,6 +158,11 @@ static inline void mptcp_init(void) { } +static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) +{ + return NULL; +} + static inline bool sk_is_mptcp(const struct sock *sk) { return false; diff --git a/include/net/tcp.h b/include/net/tcp.h index 852f0d71dd40..ea8c134802e8 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2406,4 +2406,9 @@ static inline u64 tcp_transmit_time(const struct sock *sk) return 0; } +static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) +{ + return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) | + ((nib & 0xF) << 8) | field); +} #endif /* _TCP_H */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 7cfe52aeb2b8..e8c873c66182 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -130,12 +130,6 @@ struct mptcp_options_received { u16 port; }; -static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) -{ - return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) | - ((nib & 0xF) << 8) | field); -} - struct mptcp_addr_info { sa_family_t family; __be16 port; @@ -486,11 +480,6 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk); void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); -static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) -{ - return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP); -} - static inline bool before64(__u64 seq1, __u64 seq2) { return (__s64)(seq1 - seq2) < 0; From patchwork Wed May 26 16:08:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 12282233 X-Patchwork-Delegate: mat@martineau.name Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B76A2FB7 for ; Wed, 26 May 2021 16:08:42 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id z12so3359310ejw.0 for ; Wed, 26 May 2021 09:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QzEaCbME0vL9z8gysu4UW6QXI9jijCA3f0/m/3S1jQs=; b=lFVOQRy+bYgHck7LFcmy3inTf8GKB+n260XeChzfOsIPBSSKR0zL+4/al1temjRhjL SggE+3Gtltg3ELHxj2zbconSS59WSdlW5ONt+WTvjKuN3RMQcSPBGqbqP0cKphim6Wcy Uu8+AzV9uPsHqr/UH2frIjV/UmgfYKxM/uTqpzqtDBHKGJwfs8p8P6BLhfGFBLPa7DzX 4Y5mlJWwZLTgQcWPlBBIwETFHcmTkmO5McW35QZUX65yji+iWc2ang0SIoK0JCXYxQ6I m6mTOjsOO9t3av0c1ocqWYpyl1FYCfTnCfvtGs6ukFg3w+EGG9GRyZUrvyXwbYpfZgPs uX2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QzEaCbME0vL9z8gysu4UW6QXI9jijCA3f0/m/3S1jQs=; b=sQJj2lV5cE2N2ylugXiFpl+k4q1aQ1HFljz5Y90PQj1M97ZsGfJaKcMi2TtJVv3Akk +9XNkRlDrVYdw1EgFH+KlKyitGxKIySgu72upuoJ/41rx5/baC7aDQNn73EaPq5E6TGG PO9DfDaw0pZyrDIAH0RpcnkzYdPDEOv6lhlnOHrsgmbhW/miQQKsJOdcmzWO2vBLVlFO M61KoRppRk/I+xrgLFJGsnA/el+zCj9g6KutR7dCiF/FbgmE7XizSdw6aCQdUlqYFqds s/ZP0abUvCiHO9EWr5lLEtUh6U39ukUNgYYj02Lup8dzEj1UqksgelHbIVzSodw+m1mg VyCw== X-Gm-Message-State: AOAM532DHMlkg1/gBXkRsIZ/eYyMeAftwCjU1MoSZIqFCk+fQknbk5Cl UFm8e0RTwXdtF1hUNj6I7R5TZrdVBtVLE30H X-Google-Smtp-Source: ABdhPJwUp8tT6bN6w//rje319mlj2Ia097KODFZNmsNztKmsd/qWC8FXZNmS7LcBIzNJlUcB1rVRAg== X-Received: by 2002:a17:906:aac8:: with SMTP id kt8mr33476733ejb.402.1622045320613; Wed, 26 May 2021 09:08:40 -0700 (PDT) Received: from tsr-vdi-mbaerts.nix.tessares.net (static.23.216.130.94.clients.your-server.de. [94.130.216.23]) by smtp.gmail.com with ESMTPSA id j7sm931655ejk.51.2021.05.26.09.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 09:08:40 -0700 (PDT) From: Matthieu Baerts To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [RESEND] [MPTCP][PATCH mptcp-next 3/3] mptcp: send out MP_FAIL when data checksum fail Date: Wed, 26 May 2021 18:08:13 +0200 Message-ID: X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526160813.4160315-1-matthieu.baerts@tessares.net> References: <20210526160813.4160315-1-matthieu.baerts@tessares.net> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20210526160813.L4l1DzKShRoGq0ToaN7HN8-Qkz3M01gh0eYSeqKMCtQ@z> From: Geliang Tang When a bad checksum is detected, send out the MP_FAIL suboption. Signed-off-by: Geliang Tang --- net/mptcp/subflow.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 659b8842ae3b..efd84ff61015 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -906,6 +906,8 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff * csum = csum_partial(&header, sizeof(header), subflow->map_data_csum); if (unlikely(csum_fold(csum))) { MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSCSUMERR); + subflow->send_mp_fail = 1; + subflow->fail_seq = subflow->map_seq; return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; } From patchwork Wed May 26 16:08:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 12282221 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F393A2FB2 for ; Wed, 26 May 2021 16:08:37 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id y7so2217191eda.2 for ; Wed, 26 May 2021 09:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hSPS0ohv8sOjUp3/NyaEgOWpJMbP/S/t+Db7N77pFA8=; b=TCBKqMtctoEIvd49PmezUFaOiCY9ZzDq2DKZbosEfWVZAOlHuWfrrmF664jfWMWGH1 hL7yX18wd7insjimsys1HhQcevsDO90ZqUVmvULA9hT5n4AhoitKu753PPbx0iM5UNPC ebfZ2HRsNnl5liJHgtfvubE2o8DNSy4fuR5sDF8BoeAydpeuKrU/9g2m6ITN3lMfzEoD MQqIBAkwfbU3JuCdrDEdck3ewJhf+wq4ZyuzihZD+8IfcT8Mcb3gTMr6yV9MbYtUlLjq VG8kIUZQEHC+RrU92gCbLxmd/nEZ5xxmns9QIXMNGL4aCzwLlA92YpLMthw48UYjyADw ubwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hSPS0ohv8sOjUp3/NyaEgOWpJMbP/S/t+Db7N77pFA8=; b=JyW/Sc/8SGbSgG7YC7imz7l0LJW/jwmbmQeQdInGpMkVQdCYgnfCinJl/MtqbXbXft 1Trp9CMODsuCopSq35dgM0szF66or9LUHQoDP3KlM2n6fJ1H/lWKFl7V8+VEU1MZwKQw w8SYyphIc7n2s0Ul0ESfaQpJmKwaNs9f0MGdeAKn72QYPXNPOwTd6EmssHrinKEuyVty Ni71b2lqO1MMVAgkpp5kDPon9xNunMyTmhbA/LeA11jwXVaYvRCL+x7Rv+FhmV+MVpwr 4wbAKX4PfzcQFqUPKmWOoQK0VGOMGAcr97iOtCgWKJ2IjYiufXiRgCJDsdZwqzu5Yqo5 QmWw== X-Gm-Message-State: AOAM5308n8petX/SWK5oxd7wDWmQVnvhwgE4Ekx3VWkUsTu6LtfuAYiU dhf6tSiHLTTZBHB4krAcFvWoEAuYwJ8BZCiV X-Google-Smtp-Source: ABdhPJy8hML72twf3wm+qKWeqGabL2q6USJ9zUayWQlKzmb1wH7OkMZM5Xl5zyJ/nbBqsmBScUr0EQ== X-Received: by 2002:a50:ff13:: with SMTP id a19mr38440609edu.300.1622045316345; Wed, 26 May 2021 09:08:36 -0700 (PDT) Received: from tsr-vdi-mbaerts.nix.tessares.net (static.23.216.130.94.clients.your-server.de. [94.130.216.23]) by smtp.gmail.com with ESMTPSA id j7sm931655ejk.51.2021.05.26.09.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 09:08:35 -0700 (PDT) From: Matthieu Baerts To: mptcp@lists.linux.dev Cc: Florian Westphal Subject: [RESEND] [MPTCP] [RFC PATCH 4/4] tcp: parse tcp options contained in reset packets Date: Wed, 26 May 2021 18:08:07 +0200 Message-ID: <20200924143505.27641-5-fw@strlen.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526160813.4160315-1-matthieu.baerts@tessares.net> References: <20210526160813.4160315-1-matthieu.baerts@tessares.net> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20210526160807.kCpMSHmEQCUHAoDHJDTXW8lypLNz1_VEAhH2XfMfPio@z> From: Florian Westphal This will be used to handle MPTCP_TCPRST suboption. It allows an MPTCP receiver to learn more information when a subflow is re-set. The MPTCP_TCPRST option gives an error code (protocol error, path too slow, middlebox interference detected, and so on). This allows an MPTCP receiver to make a decision to reopen the subflow at a later time, or even completely disable the path. Signed-off-by: Florian Westphal --- include/net/tcp.h | 2 +- net/ipv4/tcp_input.c | 13 ++++++++----- net/ipv4/tcp_minisocks.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index a981b5d60112..92eee154e2a3 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -609,7 +609,7 @@ void tcp_skb_collapse_tstamp(struct sk_buff *skb, /* tcp_input.c */ void tcp_rearm_rto(struct sock *sk); void tcp_synack_rtt_meas(struct sock *sk, struct request_sock *req); -void tcp_reset(struct sock *sk); +void tcp_reset(struct sock *sk, struct sk_buff *skb); void tcp_skb_mark_lost_uncond_verify(struct tcp_sock *tp, struct sk_buff *skb); void tcp_fin(struct sock *sk); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 8afa4af30fdc..0a10ba1df1a0 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4206,10 +4206,13 @@ static inline bool tcp_sequence(const struct tcp_sock *tp, u32 seq, u32 end_seq) } /* When we get a reset we do this. */ -void tcp_reset(struct sock *sk) +void tcp_reset(struct sock *sk, struct sk_buff *skb) { trace_tcp_receive_reset(sk); + if (sk_is_mptcp(sk)) + mptcp_incoming_options(sk, skb); + /* We want the right error as BSD sees it (and indeed as we do). */ switch (sk->sk_state) { case TCP_SYN_SENT: @@ -5590,7 +5593,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, &tp->last_oow_ack_time)) tcp_send_dupack(sk, skb); } else if (tcp_reset_check(sk, skb)) { - tcp_reset(sk); + tcp_reset(sk, skb); } goto discard; } @@ -5626,7 +5629,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, } if (rst_seq_match) - tcp_reset(sk); + tcp_reset(sk, skb); else { /* Disable TFO if RST is out-of-order * and no data has been received @@ -6059,7 +6062,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, */ if (th->rst) { - tcp_reset(sk); + tcp_reset(sk, skb); goto discard; } @@ -6501,7 +6504,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA); - tcp_reset(sk); + tcp_reset(sk, skb); return 1; } } diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 56c306e3cd2f..12f2495f98df 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -802,7 +802,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, req->rsk_ops->send_reset(sk, skb); } else if (fastopen) { /* received a valid RST pkt */ reqsk_fastopen_remove(sk, req, true); - tcp_reset(sk); + tcp_reset(sk, skb); } if (!fastopen) { inet_csk_reqsk_queue_drop(sk, req); From patchwork Wed May 26 16:08:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 12282227 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40D032FB2 for ; Wed, 26 May 2021 16:08:40 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id w12so2224091edx.1 for ; Wed, 26 May 2021 09:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NWtoFOgkqhrjKC1PZ/5woHNifTuxnBnpaiOnfkbriws=; b=E4+Pt+yTCO0dcXaDqVqJ1PVcGaQVYELyuZaxGrh8g4rgkpznizdAtk1BC1GKUmXre3 uLOHwXdFdmo0+dwoAOEnzDVLhKdDQ6l3Vww94FgaLQMPU7zrhc8ocBoZEBkS7xQgXe8U FOJuxiWBO4SqG46EJICpxFhnv9o5zM+cePtlbMdLSVedca0WHTLfzuZUWC0K7JjbnQZu hIWI+rs3NGrcjGf96btYcQBuFF8FyagjB6AxxXyYXNCWStTKZ+cSfAoilA7NypaPVbvn poAihJNVg8R76uoPKe15rxjmd/rOnu05SJLhfrSSFmc2pBhOCF1JhAfw4cmPblDinkBH rKiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NWtoFOgkqhrjKC1PZ/5woHNifTuxnBnpaiOnfkbriws=; b=QuXrS/hMNfYY51+6wASZy1pOiPuGgR5Y1WGcRW7GJYTNUAJkzDfkY1FGls7IaEVIKh fCk0GndC5ZncRws9DvsP/APnGfnT8YvYLo4NDEy18T54RQX0o3Kj5lhARnramnHkZkby wMY3hPNimtWMOpJcmJ89yyd3x957EYO+npztxKlrRqtRlN+eBJYBKSomVszDUZYNF4f9 +CU3iL1rCzmyH7BTQT89NbBkCJtfMkHxpyQZFbtWE/Hwd8iAYYflI9eqcfZ+GRlR0hIM pvhTliL/WAWPpBlUP9PJMZVcta4mK9+OSfw/Xa7FOD2Qtmo9elC6L8v/qAMnLr5BqUcx rdLg== X-Gm-Message-State: AOAM530HOLccJ7VA96KT16fRnrhPKwc8h8g8RsdzIVdQn5cx3y3OqUa3 y0HnjKBZyIuF0bPClyTxHXTw78CIkdVRGt9y X-Google-Smtp-Source: ABdhPJzaSR9N11vg1emooWUvpnv55FK1HIsDdAr1mFlBRzQXJIXFQg3WeEsuMxc0PJES6h9o5zQd8g== X-Received: by 2002:a05:6402:35c5:: with SMTP id z5mr39914410edc.210.1622045318625; Wed, 26 May 2021 09:08:38 -0700 (PDT) Received: from tsr-vdi-mbaerts.nix.tessares.net (static.23.216.130.94.clients.your-server.de. [94.130.216.23]) by smtp.gmail.com with ESMTPSA id j7sm931655ejk.51.2021.05.26.09.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 09:08:38 -0700 (PDT) From: Matthieu Baerts To: mptcp@lists.linux.dev Cc: Florian Westphal Subject: [RESEND] [MPTCP] [PATCH MPTCP 5/5] mptcp: send fastclose if userspace closes socket with unread data Date: Wed, 26 May 2021 18:08:10 +0200 Message-ID: <20201105170126.5627-6-fw@strlen.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526160813.4160315-1-matthieu.baerts@tessares.net> References: <20210526160813.4160315-1-matthieu.baerts@tessares.net> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20210526160810.AQGZaK36PMDV5E686aHcYoQ1voldKfI3QvSTKQR_3rw@z> From: Florian Westphal Add building & sending of FASTCLOSE option. RFC 8684 describes two methods: A): Host sends an ACK containing the MP_FASTCLOSE option on one subflow [..] On all the other subflows, Host A sends a regular TCP RST to close these subflows and tears them down. [..] R): Host A sends a RST containing the MP_FASTCLOSE option on all subflows [..]. Host A can tear down the subflows and the connection immediately. This implements option R) only: All subflows are re-set with FASTCLOSE. Signed-off-by: Florian Westphal --- net/mptcp/options.c | 35 +++++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 32 +++++++++++++++++++++++++++++++- net/mptcp/protocol.h | 1 + 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 0a940687f738..08b60d527de0 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -681,6 +681,31 @@ static bool mptcp_established_options_rm_addr(struct sock *sk, return true; } +static bool mptcp_fastclose(const struct mptcp_sock *msk) +{ + return READ_ONCE(msk->snd_fastclose); +} + +static bool mptcp_established_options_fastclose(struct sock *sk, + unsigned int *size, + unsigned int remaining, + struct mptcp_out_options *opts) +{ + const struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + + if (likely(!mptcp_fastclose(mptcp_sk(subflow->conn)))) + return false; + + if (remaining < TCPOLEN_MPTCP_FASTCLOSE) + return false; + + *size = TCPOLEN_MPTCP_FASTCLOSE; + opts->suboptions |= OPTION_MPTCP_FASTCLOSE; + opts->rcvr_key = subflow->remote_key; + + return true; +} + static noinline void mptcp_established_options_rst(struct sock *sk, struct sk_buff *skb, unsigned int *size, unsigned int remaining, @@ -691,6 +716,9 @@ static noinline void mptcp_established_options_rst(struct sock *sk, struct sk_bu if (remaining < TCPOLEN_MPTCP_RST) return; + if (mptcp_established_options_fastclose(sk, size, remaining, opts)) + return; + *size = TCPOLEN_MPTCP_RST; opts->suboptions |= OPTION_MPTCP_RST; opts->reset_transient = subflow->reset_transient; @@ -1179,6 +1207,13 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, ptr += 5; } + if (OPTION_MPTCP_FASTCLOSE & opts->suboptions) { + *ptr++ = mptcp_option(MPTCPOPT_MP_FASTCLOSE, + TCPOLEN_MPTCP_FASTCLOSE, 0, 0); + put_unaligned_be64(opts->rcvr_key, ptr); + ptr += 2; + } + if (OPTION_MPTCP_RST & opts->suboptions) *ptr++ = mptcp_option(MPTCPOPT_RST, TCPOLEN_MPTCP_RST, diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 7e9705943813..6b6efa00cad5 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2133,6 +2133,29 @@ static void __mptcp_check_send_data_fin(struct sock *sk) } } +static void __mptcp_send_fastclose(struct sock *sk) +{ + struct mptcp_subflow_context *subflow, *tmp; + struct mptcp_sock *msk = mptcp_sk(sk); + + WRITE_ONCE(msk->snd_fastclose, true); + + __mptcp_flush_join_list(msk); + __mptcp_clear_xmit(sk); + + WRITE_ONCE(msk->snd_nxt, msk->write_seq); + + list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { + struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow); + + lock_sock(tcp_sk); + subflow->reset_transient = 0; + subflow->reset_reason = MPTCP_RST_EMPTCP; + mptcp_subflow_reset(tcp_sk); + release_sock(tcp_sk); + } +} + static void __mptcp_wr_shutdown(struct sock *sk) { struct mptcp_sock *msk = mptcp_sk(sk); @@ -2185,6 +2208,7 @@ static void mptcp_close(struct sock *sk, long timeout) { struct mptcp_subflow_context *subflow; bool do_cancel_work = false; + bool send_fin = false; lock_sock(sk); sk->sk_shutdown = SHUTDOWN_MASK; @@ -2197,7 +2221,13 @@ static void mptcp_close(struct sock *sk, long timeout) goto cleanup; } - if (mptcp_close_state(sk)) + send_fin = mptcp_close_state(sk); + if (!skb_queue_empty(&sk->sk_receive_queue)) { + __mptcp_send_fastclose(sk); + send_fin = false; + } + + if (send_fin) __mptcp_wr_shutdown(sk); sk_stream_wait_close(sk, timeout); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d4c99e091cb9..93352044bff9 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -243,6 +243,7 @@ struct mptcp_sock { bool fully_established; bool rcv_data_fin; bool snd_data_fin_enable; + bool snd_fastclose; bool rcv_fastclose; bool use_64bit_ack; /* Set when we received a 64-bit DSN */ spinlock_t join_list_lock;