From patchwork Tue May 25 09:17:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12278269 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 6F2902FB0 for ; Tue, 25 May 2021 09:17:12 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id q16so255333pls.6 for ; Tue, 25 May 2021 02:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gMCKa3I+OdVG15KKyUTExe9FHj8cubNYgH9GkLPxXkQ=; b=ISqG2MCH8NPmfIjKXwnJjy6JcT2cDLQdLJMKmPTOuuG+RB4TskPquRZ60H3PRj1+LU PTozpSs/eYwvHmKXKDPT4TCrbMtMzyTiXE87Fc7dFVwVoH7vGT8CQf5DUVyitUs7u5hc umLfuYBqvZIyuiYgOY+xLkcOU7v/LOqcqnVPl/z9lg6Pj1zaQX0rNOvyzN7F4vmRV23E 7vx6MEiQiOIpz98+1IkA/JZZFP867ypCngq6fBeTrl4IgTjStyfl9IgGh0RfieOqVdZj xK5mtEwuean4HYZtGeNxlA1NZuXKPMfrQK72HBOY5lm5lPw3xK0DL/K26AdBeeGKGUBE MnXA== 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=gMCKa3I+OdVG15KKyUTExe9FHj8cubNYgH9GkLPxXkQ=; b=t3W3w5vwhnKnAoQ/TIh0MzS/CH1tkbR7O0eoPsexZcVrhHV6KyTbMPdrXdGoIW8G2i SkYqnFuTCUBmm4IFXNrxQ69fHacgRW8s9oclsvFmKZy0EQwzgbMu4tkMUjKOyxpvEmeK KLea5Ew+LGImp5gshloEadnNTuLfnA6n6caToGRUpZlOsnKwaeuiUHFjwF2D0MTu5G2h TxWVEJ7xPrwdBpEVPFLg/aRNQZuOMdmQJ0WbxKZRpK9O0jMaxj+zzvvSgKS4Btybhkf+ W/k8HgwUzkeMuhuLu2XCx7AsgoLDD/Pjk6CEejMNwaDr8ukvqYoJmvm3rVvJJW0WLuCe C85g== X-Gm-Message-State: AOAM533JkIE1blA+DVhYd8lA17/Q72dpTErtNxvjpojmL8s8jOxueXgk FAXov3/21Gbr8rnrEfYvbjc8QiGXkaFxOA== X-Google-Smtp-Source: ABdhPJwDn815X+myLl+hxbeHXwKtADm6RRRtJvq0d9FrmwMaJbSf5sX2tJXUR8tL5XkvJAlwDKNxHg== X-Received: by 2002:a17:90a:6644:: with SMTP id f4mr30014508pjm.154.1621934231953; Tue, 25 May 2021 02:17:11 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id h24sm13440024pfn.180.2021.05.25.02.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 02:17:11 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Florian Westphal Subject: [MPTCP][PATCH v8 mptcp-next 1/4] mptcp: add sysctl allow_join_initial_addr_port Date: Tue, 25 May 2021 17:17:03 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch added a new sysctl, named allow_join_initial_addr_port, to control whether allow peers to send join requests to the IP address and port number used by the initial subflow. Suggested-by: Florian Westphal Signed-off-by: Geliang Tang --- Documentation/networking/mptcp-sysctl.rst | 13 +++++++++++++ net/mptcp/ctrl.c | 16 ++++++++++++++++ net/mptcp/protocol.h | 1 + 3 files changed, 30 insertions(+) diff --git a/Documentation/networking/mptcp-sysctl.rst b/Documentation/networking/mptcp-sysctl.rst index ee06fd782465..76d939e688b8 100644 --- a/Documentation/networking/mptcp-sysctl.rst +++ b/Documentation/networking/mptcp-sysctl.rst @@ -32,3 +32,16 @@ checksum_enabled - BOOLEAN per-namespace sysctl. Default: 0 + +allow_join_initial_addr_port - BOOLEAN + Allow peers to send join requests to the IP address and port number used + by the initial subflow if the value is 1. This controls a flag that is + sent to the peer at connection time, and whether such join requests are + accepted or denied. + + Joins to addresses advertised with ADD_ADDR are not affected by this + value. + + This is a per-namespace sysctl. + + Default: 1 diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index 6c2639bb9c19..7d738bd06f2c 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -24,6 +24,7 @@ struct mptcp_pernet { u8 mptcp_enabled; unsigned int add_addr_timeout; u8 checksum_enabled; + u8 allow_join_initial_addr_port; }; static struct mptcp_pernet *mptcp_get_pernet(struct net *net) @@ -46,11 +47,17 @@ int mptcp_is_checksum_enabled(struct net *net) return mptcp_get_pernet(net)->checksum_enabled; } +int mptcp_allow_join_id0(struct net *net) +{ + return mptcp_get_pernet(net)->allow_join_initial_addr_port; +} + static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet) { pernet->mptcp_enabled = 1; pernet->add_addr_timeout = TCP_RTO_MAX; pernet->checksum_enabled = 0; + pernet->allow_join_initial_addr_port = 1; } #ifdef CONFIG_SYSCTL @@ -80,6 +87,14 @@ static struct ctl_table mptcp_sysctl_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE }, + { + .procname = "allow_join_initial_addr_port", + .maxlen = sizeof(u8), + .mode = 0644, + .proc_handler = proc_dou8vec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE + }, {} }; @@ -98,6 +113,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[0].data = &pernet->mptcp_enabled; table[1].data = &pernet->add_addr_timeout; table[2].data = &pernet->checksum_enabled; + table[3].data = &pernet->allow_join_initial_addr_port; hdr = register_net_sysctl(net, MPTCP_SYSCTL_PATH, table); if (!hdr) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 16e50caf200e..c07db980b5da 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -543,6 +543,7 @@ static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *su int mptcp_is_enabled(struct net *net); unsigned int mptcp_get_add_addr_timeout(struct net *net); int mptcp_is_checksum_enabled(struct net *net); +int mptcp_allow_join_id0(struct net *net); void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, struct mptcp_options_received *mp_opt); bool mptcp_subflow_data_available(struct sock *sk); From patchwork Tue May 25 09:17:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12278271 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 157862FB0 for ; Tue, 25 May 2021 09:17:15 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id p39so6776391pfw.8 for ; Tue, 25 May 2021 02:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PxiQ/zt4bv5qFhspO2jncT4eNc2X4LIM55ZlOeHgeMw=; b=MSURivzjX1kRIiAHybAbRf3+n5gKu6DQkez0iKiLhIwXYFqrtUyo1t5bN/VSblWosR 2hu4TCwMI9YOufyDB9QmDqnelZaQLRe1Na1OondXb2vVT47u51Dkz9Ro1B4mn3TWzVLe g4rWsdKj+mjjApoqxEQr9EfrUg5RgH7myozF3fX1pz3f0W9lLC6YUAiGSOVfwpDj4xW3 8BUCxw4siW+HNJD4xfzbt6aF6rdEjTdz/SB3QwagM+17Tt/0BbSYfdHmJo5tM1MNLnHn VndCtg7OXjsj88jOmFv5taB4JFWLtrZgGplMnDUTC6De1n37CRKf4631v9Er6sMGspY5 vuww== 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=PxiQ/zt4bv5qFhspO2jncT4eNc2X4LIM55ZlOeHgeMw=; b=m0lkrqR9scZ9dN4oCS3jM/LB1ZNTCyvSSRpGUt9UnQ57aqkq7oqMv0GzQ0KsjQzxrH FYKcoHdrLuIdHKlRoGUIb9BTNNwtzCmb6j85yqPLSxtfLueStobjlLuEtCGdmZnWmciP jJMFSAaxYZzxeC5Nu3euv2Eut57BHDvMwkLz44cdWVAJQKhmlAK3xOocGXpnG7MpsGNv 2bbByGdTGxQBpFDl40bf/W+pIIRqosbQRBjyuT8NCRvCzJTOL4HZMppEOAdpSGULMz6B EpwDdRUZnbwtBTqQeUSUBhvbXGyUgLUUYmXve8D78nOwnehlJ3tLIimxN3VqqSPbQyw0 zkLw== X-Gm-Message-State: AOAM533jDock5vXizedjHUJ3ezz5m2IAKIqlJgTM5twhRLWjZ7ll/dGY ZgnO/r59R5FOUtpto4jLlhl1jeK/TwOGZg== X-Google-Smtp-Source: ABdhPJxJav+hyhmFz58V+GpmQhzAlhpFBvGaqPkk4jFWd4IpQEBBulCrjFqHMeSNlhaS45u3mQZmmg== X-Received: by 2002:a63:aa48:: with SMTP id x8mr17853904pgo.359.1621934234609; Tue, 25 May 2021 02:17:14 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id mj6sm11910372pjb.8.2021.05.25.02.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 02:17:14 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [MPTCP][PATCH v8 mptcp-next 2/4] mptcp: add allow_join_id0 in mptcp_out_options Date: Tue, 25 May 2021 17:17:04 +0800 Message-Id: <57e35b700b797c875966ae26252ae07316853837.1621933974.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch defined a new flag MPTCP_CAP_DENY_JOIN_ID0 for the third bit, labeled "C" of the MP_CAPABLE option. Add a new flag allow_join_id0 in struct mptcp_out_options. If this flag is set, send out the MP_CAPABLE option with the flag MPTCP_CAP_DENY_JOIN_ID0. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 3 ++- net/mptcp/options.c | 6 ++++++ net/mptcp/protocol.h | 6 ++++-- net/mptcp/subflow.c | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index d61bbbf11979..cb580b06152f 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -67,7 +67,8 @@ struct mptcp_out_options { u8 backup; u8 reset_reason:4, reset_transient:1, - csum_reqd:1; + csum_reqd:1, + allow_join_id0:1; u32 nonce; u64 thmac; u32 token; diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 1aec01686c1a..1e921b5103bf 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -400,6 +400,7 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, if (subflow->request_mptcp) { opts->suboptions = OPTION_MPTCP_MPC_SYN; opts->csum_reqd = mptcp_is_checksum_enabled(sock_net(sk)); + opts->allow_join_id0 = mptcp_allow_join_id0(sock_net(sk)); *size = TCPOLEN_MPTCP_MPC_SYN; return true; } else if (subflow->request_join) { @@ -488,6 +489,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, opts->sndr_key = subflow->local_key; opts->rcvr_key = subflow->remote_key; opts->csum_reqd = READ_ONCE(msk->csum_enabled); + opts->allow_join_id0 = mptcp_allow_join_id0(sock_net(sk)); /* Section 3.1. * The MP_CAPABLE option is carried on the SYN, SYN/ACK, and ACK @@ -825,6 +827,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size, opts->suboptions = OPTION_MPTCP_MPC_SYNACK; opts->sndr_key = subflow_req->local_key; opts->csum_reqd = subflow_req->csum_reqd; + opts->allow_join_id0 = subflow_req->allow_join_id0; *size = TCPOLEN_MPTCP_MPC_SYNACK; pr_debug("subflow_req=%p, local_key=%llu", subflow_req, subflow_req->local_key); @@ -1199,6 +1202,9 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, if (opts->csum_reqd) flag |= MPTCP_CAP_CHECKSUM_REQD; + if (!opts->allow_join_id0) + flag |= MPTCP_CAP_DENY_JOIN_ID0; + *ptr++ = mptcp_option(MPTCPOPT_MP_CAPABLE, len, MPTCP_SUPPORTED_VERSION, flag); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c07db980b5da..1201ab04bcdf 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -79,8 +79,9 @@ #define MPTCP_VERSION_MASK (0x0F) #define MPTCP_CAP_CHECKSUM_REQD BIT(7) #define MPTCP_CAP_EXTENSIBILITY BIT(6) +#define MPTCP_CAP_DENY_JOIN_ID0 BIT(5) #define MPTCP_CAP_HMAC_SHA256 BIT(0) -#define MPTCP_CAP_FLAG_MASK (0x3F) +#define MPTCP_CAP_FLAG_MASK (0x1F) /* MPTCP DSS flags */ #define MPTCP_DSS_DATA_FIN BIT(4) @@ -352,7 +353,8 @@ struct mptcp_subflow_request_sock { u16 mp_capable : 1, mp_join : 1, backup : 1, - csum_reqd : 1; + csum_reqd : 1, + allow_join_id0 : 1; u8 local_id; u8 remote_id; u64 local_key; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 2f13d795c2fc..0f4dc708e9b2 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -109,6 +109,7 @@ static void subflow_init_req(struct request_sock *req, const struct sock *sk_lis subflow_req->mp_capable = 0; subflow_req->mp_join = 0; subflow_req->csum_reqd = mptcp_is_checksum_enabled(sock_net(sk_listener)); + subflow_req->allow_join_id0 = mptcp_allow_join_id0(sock_net(sk_listener)); subflow_req->msk = NULL; mptcp_token_init_request(req); } From patchwork Tue May 25 09:17:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12278273 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 5AEB170 for ; Tue, 25 May 2021 09:17:18 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id e17so12516465pfl.5 for ; Tue, 25 May 2021 02:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bivm2+CXlf+9WWCoscq7mDjfUNQM6qwfEvoAS8hWdHs=; b=UGIK2opBe+c2J27TgLUEfPJHKEzXyvn6TZtCBV17vFwxHDqvcl6Ewzn+ePMxITyQTf 4JZ3JDRTQI2PqqLc3knCJiZHUoIxJDvYnNd/cSw/gMJcjoJ2zbOUYlybU9lxD/1IIK1I pCt3Ml4RqGDDq7uODopB7QuWvYZiOsI6tYcnxbcqVlf5C4PSwn9+S40LmpvpCUWJ9bwG hdrZWSlFGS3FAjfI9oNYvGd2l0cmOgW7ln7DM8M59f0jYOW5LFRlcQO+aLYl27lyG6SJ wIH5MiH+ya9nJ3lx8IjBkHCrj7KwwoifS4WXYkfz1UBndlXgHHdIjlbf0yPG7SCEepbR I+BQ== 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=Bivm2+CXlf+9WWCoscq7mDjfUNQM6qwfEvoAS8hWdHs=; b=D7DYf9R6yBr5vHRPjaAwqHVSEQLq4YWjaacuRq1zg+C2xQMTx474J3KlAzU9hWoFBG lyd6dauAgBgfImrnx4M5xzNsTw/gubHXg1eA7bKoT5Q9j0wZr6kbFeyjWf7yrmlwm9gP vqhy5CnTcso0DfU9QcrceiZlipok28j5yIW5Yzlp/P11cuVLLASnokeRrw/+wxSrsTUC sIcpfWECsUkZTMxBxtTKxYLtk35rg5s2rNbc4KSS6uVIlGlB9djI0HKIWZekEKZ3n2YF SoZOKQ2Z/Z0I8JSWIIx60Yo3UnwwkZNFe79hFXkp6t5cBjbud2RzTnr5TJ7vWE9BVlLu M/1Q== X-Gm-Message-State: AOAM530pgshpg1NfNDEdLbKAj10dNn9B/KHyfnVKLt5cK5mTNLUCs1Ep nyS/uDMOYF0cR3HQcfK1iN/eAmaQZooT0A== X-Google-Smtp-Source: ABdhPJycR7Qn22zrrbPW0GyEoijGf5LPM4dFQ2ucC8hszQJRtpZpAg1MyR5EhrL5ALmfq9OP7UdVmg== X-Received: by 2002:aa7:8a18:0:b029:2dd:42f3:d42f with SMTP id m24-20020aa78a180000b02902dd42f3d42fmr29134045pfa.70.1621934237765; Tue, 25 May 2021 02:17:17 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id z1sm8777801pff.194.2021.05.25.02.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 02:17:17 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Florian Westphal Subject: [MPTCP][PATCH v8 mptcp-next 3/4] mptcp: add deny_join_id0 in mptcp_options_received Date: Tue, 25 May 2021 17:17:05 +0800 Message-Id: <5111dfce361c87c83e5355e78e55b6f593bac55b.1621933974.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <57e35b700b797c875966ae26252ae07316853837.1621933974.git.geliangtang@gmail.com> References: <57e35b700b797c875966ae26252ae07316853837.1621933974.git.geliangtang@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch added a new flag named deny_join_id0 in struct mptcp_options_received. Set it when MP_CAPABLE with the flag MPTCP_CAP_DENYJOIN_ID0 is received. Also add a new flag remote_deny_join_id0 in struct mptcp_pm_data. When the flag deny_join_id0 is set, set this remote_deny_join_id0 flag. In mptcp_pm_create_subflow_or_signal_addr, if the remote_deny_join_id0 flag is set, and the remote address id is zero, stop this connection. Suggested-by: Florian Westphal Signed-off-by: Geliang Tang --- net/mptcp/options.c | 6 ++++++ net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 3 ++- net/mptcp/protocol.h | 4 +++- net/mptcp/subflow.c | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 1e921b5103bf..0d30008f0313 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -83,6 +83,9 @@ static void mptcp_parse_option(const struct sk_buff *skb, if (flags & MPTCP_CAP_CHECKSUM_REQD) mp_opt->csum_reqd = 1; + if (flags & MPTCP_CAP_DENY_JOIN_ID0) + mp_opt->deny_join_id0 = 1; + mp_opt->mp_capable = 1; if (opsize >= TCPOLEN_MPTCP_MPC_SYNACK) { mp_opt->sndr_key = get_unaligned_be64(ptr); @@ -360,6 +363,7 @@ void mptcp_get_options(const struct sock *sk, mp_opt->mp_prio = 0; mp_opt->reset = 0; mp_opt->csum_reqd = READ_ONCE(msk->csum_enabled); + mp_opt->deny_join_id0 = 0; length = (th->doff * 4) - sizeof(struct tcphdr); ptr = (const unsigned char *)(th + 1); @@ -1047,6 +1051,8 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) } mptcp_get_options(sk, skb, &mp_opt); + if (mp_opt.deny_join_id0) + WRITE_ONCE(msk->pm.remote_deny_join_id0, true); if (!check_fully_established(msk, sk, subflow, skb, &mp_opt)) return; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 9d00fa6d22e9..639271e09604 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -320,6 +320,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) WRITE_ONCE(msk->pm.addr_signal, 0); WRITE_ONCE(msk->pm.accept_addr, false); WRITE_ONCE(msk->pm.accept_subflow, false); + WRITE_ONCE(msk->pm.remote_deny_join_id0, false); msk->pm.status = 0; spin_lock_init(&msk->pm.lock); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 09722598994d..e6a3f0a550bf 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -451,7 +451,8 @@ 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 < local_addr_max && - msk->pm.subflows < subflows_max) { + msk->pm.subflows < subflows_max && + !READ_ONCE(msk->pm.remote_deny_join_id0)) { local = select_local_address(pernet, msk); if (local) { struct mptcp_addr_info remote = { 0 }; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 1201ab04bcdf..bdf4a832975d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -138,7 +138,8 @@ struct mptcp_options_received { mp_prio : 1, echo : 1, csum_reqd : 1, - backup : 1; + backup : 1, + deny_join_id0 : 1; u32 token; u32 nonce; u64 thmac; @@ -193,6 +194,7 @@ struct mptcp_pm_data { bool work_pending; bool accept_addr; bool accept_subflow; + bool remote_deny_join_id0; u8 add_addr_signaled; u8 add_addr_accepted; u8 local_addr_used; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 0f4dc708e9b2..629be94f4d75 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -408,6 +408,8 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) if (mp_opt.csum_reqd) WRITE_ONCE(mptcp_sk(parent)->csum_enabled, true); + if (mp_opt.deny_join_id0) + WRITE_ONCE(mptcp_sk(parent)->pm.remote_deny_join_id0, true); subflow->mp_capable = 1; subflow->can_ack = 1; subflow->remote_key = mp_opt.sndr_key; From patchwork Tue May 25 09:17:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12278275 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 0281D70 for ; Tue, 25 May 2021 09:17:20 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id e17so12516529pfl.5 for ; Tue, 25 May 2021 02:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EYGMIxB7FtEIvW6MTDb+8whnN0GeDuVFPW3zXqBjsCo=; b=ECzfMVR8EQuFlgBOhlScFzjSVFvwHcClEJBGHPDxw85ViPjZ7SmrmYEGyD11Hw5c30 6hNL3PuD9uRAZgOSixmvHSWdqbOPK7TF5mBAgEMeHwQhlcIFX7nrHMmlXC5xGSWKYDvy ycJBNXfKA8JsfPW0e2DVkab2fiolhz5JbPIRr7llQIKpfwVJRq1Vb3vejK/8oLM4+6IE x5UdiJqHdfXOTSdeXSq8YdEhM1uKa5lfTvdomrn7PmMdpX7QuFWVLQswwT8epXUU5qCB /y1VVBrmW2UXmZSrk9ts86l/Opzbmz+zzy91JRru7GICugMI+qOUEypBHoAzTWIzSifV yQjg== 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=EYGMIxB7FtEIvW6MTDb+8whnN0GeDuVFPW3zXqBjsCo=; b=U5D1VncYo3EbyO3xPZhJJwTMAMltrfKqinZ87oJxux4ffKtwk5TQe49JC/R4QJyWYX AiSugUf/V5i0t4+Ih/HUl+JoI7SDl5casrzTL4jTOVIm2TtqBpS/UMZ+uIqxksDmbxBz pJrgHyqp60EVi2A0NaL6wwRf9jRsM0JT76cxlmBzyNccUHYPGVtDLkdS/5nGf2M1rter JCsiMY7NILWqVOVNLA/QLAm3h0VmDW+x5z1rFi2XroLO/ABdBNQxairrDsWMqny6YywI 95sjmW5ymH62xvFQH3U5LDpHuCpgxA6J5EnMFE/oNyGO1f/HGjplhJbCM+xfiyl0iAV+ S2mA== X-Gm-Message-State: AOAM530uYfKGU2KYs02vHKsMKl3HmZLuxfPB42vXiIB2JCNeCwfd9YqT /yEMZvM2wIIJ0VSp/3LkLYArtn5D1g56yA== X-Google-Smtp-Source: ABdhPJwwFeSEcZbgkJXFiHXP1vTkD9c+6f3u4YF6aBhzMNmLIeEfGnL2ijI/pUB+GD2LQC3sYfJIHg== X-Received: by 2002:a63:ee10:: with SMTP id e16mr18219224pgi.135.1621934240411; Tue, 25 May 2021 02:17:20 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id q24sm13613153pgk.32.2021.05.25.02.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 02:17:20 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [MPTCP][PATCH v8 mptcp-next 4/4] selftests: mptcp: add deny_join_id0 testcases Date: Tue, 25 May 2021 17:17:06 +0800 Message-Id: <067cd82f6acb01eec6fa44f3e9acdeb12e79dcf8.1621933974.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <5111dfce361c87c83e5355e78e55b6f593bac55b.1621933974.git.geliangtang@gmail.com> References: <57e35b700b797c875966ae26252ae07316853837.1621933974.git.geliangtang@gmail.com> <5111dfce361c87c83e5355e78e55b6f593bac55b.1621933974.git.geliangtang@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch added a new argument '-d' for mptcp_join.sh script, to invoke the testcases for the MP_CAPABLE 'C' flag. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 75 ++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 523c7797f30a..9a191c1a5de8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -139,6 +139,17 @@ reset_with_checksum() ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable } +reset_with_allow_join_id0() +{ + local ns1_enable=$1 + local ns2_enable=$2 + + reset + + ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable + ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable +} + ip -Version > /dev/null 2>&1 if [ $? -ne 0 ];then echo "SKIP: Could not run test without ip tool" @@ -1462,6 +1473,63 @@ checksum_tests() chk_csum_nr "checksum test 1 0" } +deny_join_id0_tests() +{ + # subflow allow join id0 ns1 + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 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 allow join id0 ns1" 1 1 1 + + # subflow allow join id0 ns2 + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 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 allow join id0 ns2" 0 0 0 + + # signal address allow join id0 ns1 + # ADD_ADDRs are not affected by allow_join_id0 value. + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 1 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 + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "signal address allow join id0 ns1" 1 1 1 + chk_add_nr 1 1 + + # signal address allow join id0 ns2 + # ADD_ADDRs are not affected by allow_join_id0 value. + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 1 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 + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "signal address allow join id0 ns2" 1 1 1 + chk_add_nr 1 1 + + # subflow and address allow join id0 ns1 + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 2 2 + ip netns exec $ns2 ./pm_nl_ctl limits 2 2 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 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 "subflow and address allow join id0 1" 2 2 2 + + # subflow and address allow join id0 ns2 + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 2 2 + ip netns exec $ns2 ./pm_nl_ctl limits 2 2 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 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 "subflow and address allow join id0 2" 1 1 1 +} + all_tests() { subflows_tests @@ -1476,6 +1544,7 @@ all_tests() add_addr_ports_tests syncookies_tests checksum_tests + deny_join_id0_tests } usage() @@ -1493,6 +1562,7 @@ usage() echo " -p add_addr_ports_tests" echo " -k syncookies_tests" echo " -S checksum_tests" + echo " -d deny_join_id0_tests" echo " -c capture pcap files" echo " -C enable data checksum" echo " -h help" @@ -1528,7 +1598,7 @@ if [ $do_all_tests -eq 1 ]; then exit $ret fi -while getopts 'fsltra64bpkchCS' opt; do +while getopts 'fsltra64bpkdchCS' opt; do case $opt in f) subflows_tests @@ -1566,6 +1636,9 @@ while getopts 'fsltra64bpkchCS' opt; do S) checksum_tests ;; + d) + deny_join_id0_tests + ;; c) ;; C)