From patchwork Tue Mar 29 02:13:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishen Maloor X-Patchwork-Id: 12794381 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C8AE20E6 for ; Tue, 29 Mar 2022 02:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648520050; x=1680056050; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=RJJAoZH769xw3Gm9uQPRUtnnIFyaZSVqSI6EX+533dU=; b=UB1AkJzxr7p/JmwrK8swkJ73Lv1vEUJpQ181gB1t6FNnAWAYvIb7eQ2M pHzW9T2RyURMmLQn6790Vmdeh4RcIKxrjBly8h8R0GE84zrnqDaF28wUv MoDxyoVl02JLxpxUQmXdHsC8Hsn8SGfg/5x4Txmka7xT8Hjamuva7w8ju ebp3jDM+9/M65+Zf5Lj+QC9EFxw+JfnF/OJchVvEW8C6axHcxjTYzRubz So/wRtjwoIjv7+ddybvDbNk3pjmaJvPww2MPLEDzrrh17wJwelDP/oWGb ndNXzfIJnum6kK+pbjMpX/e8/bv7O9YXG8jckEibFa3lp9ipfxTNCAahJ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345578742" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="345578742" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564202539" Received: from otc-tsn-4.jf.intel.com ([10.23.153.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:07 -0700 From: Kishen Maloor To: kishen.maloor@intel.com, mptcp@lists.linux.dev Subject: [PATCH mptcp-next v9 1/6] Squash-to: mptcp: Bypass kernel PM when userspace PM is enabled Date: Mon, 28 Mar 2022 22:13:56 -0400 Message-Id: <20220329021401.1196466-2-kishen.maloor@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329021401.1196466-1-kishen.maloor@intel.com> References: <20220329021401.1196466-1-kishen.maloor@intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Kishen Maloor --- 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 fd82fd113113..54d2b3b2d100 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -806,9 +806,9 @@ static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk) return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_RM_ADDR_SIGNAL); } -static inline bool mptcp_pm_is_userspace(struct mptcp_sock *msk) +static inline bool mptcp_pm_is_userspace(const struct mptcp_sock *msk) { - return READ_ONCE(msk->pm.pm_type) != MPTCP_PM_TYPE_KERNEL; + return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_USERSPACE; } static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port) From patchwork Tue Mar 29 02:13:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishen Maloor X-Patchwork-Id: 12794382 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A281D20E5 for ; Tue, 29 Mar 2022 02:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648520050; x=1680056050; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=JFfNMKu2BiP/IalZtdk4SedEQzW3OgEn1gkuHHI+jsU=; b=aXgN6Cs1gEFXN7x8caF4RGgbV4/67hhZ9OIievwgfOgcDcK/6mEWUamk oeGNFwN8TixnGo9YviYnejKtvCQWPVlDtZIWRk4150gdzP6iWfCK19/D/ BEcvtbQj+hzJ/vq0DlwmFLd8EXnDtR9dwHCmfugwmDz/gUV6BT+DSuIyH DAtrRYqBaMdZSRRypW/TcMic7y0F/VoraeE20rsbQ1+5qeAoGfFm4MYds ajuywYk3inBH0DLLz2BGMdfYGFNKHu8FJ4tBtMRkApHvdqpi3P+G/yc3O KlaqxjwWbESlhQCaHFTUvZ1wBbyjGJlZkEuRbWa/W8StvuzsM+xnY112C Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345578743" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="345578743" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564202542" Received: from otc-tsn-4.jf.intel.com ([10.23.153.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:07 -0700 From: Kishen Maloor To: kishen.maloor@intel.com, mptcp@lists.linux.dev Subject: [PATCH mptcp-next v9 2/6] mptcp: bypass in-kernel PM restrictions for non-kernel PMs Date: Mon, 28 Mar 2022 22:13:57 -0400 Message-Id: <20220329021401.1196466-3-kishen.maloor@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329021401.1196466-1-kishen.maloor@intel.com> References: <20220329021401.1196466-1-kishen.maloor@intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Current limits on the # of addresses/subflows must apply only to in-kernel PM managed sockets. Thus this change removes such restrictions on connections overseen by non-kernel (e.g. userspace) PMs. This change also ensures that the kernel does not record stats inside struct mptcp_pm_data updated along kernel code paths when exercised via non-kernel PMs. Additionally, address announcements are acknolwedged and subflow requests are honored only when it's deemed that a userspace path manager is active at the time. Signed-off-by: Kishen Maloor --- net/mptcp/pm.c | 15 +++++++++++++-- net/mptcp/pm_netlink.c | 10 ++++++++++ net/mptcp/protocol.h | 6 ++++++ net/mptcp/subflow.c | 4 +++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 57f67578a47f..8df9cb28d970 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -87,6 +87,9 @@ bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) unsigned int subflows_max; int ret = 0; + if (mptcp_pm_is_userspace(msk)) + return mptcp_userspace_pm_active(msk); + subflows_max = mptcp_pm_get_subflows_max(msk); pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows, @@ -179,7 +182,8 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock *ssk, bool update_subflows; update_subflows = (ssk->sk_state == TCP_CLOSE) && - (subflow->request_join || subflow->mp_join); + (subflow->request_join || subflow->mp_join) && + mptcp_pm_is_kernel(msk); if (!READ_ONCE(pm->work_pending) && !update_subflows) return; @@ -208,7 +212,14 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, spin_lock_bh(&pm->lock); - if (!READ_ONCE(pm->accept_addr) || mptcp_pm_is_userspace(msk)) { + if (mptcp_pm_is_userspace(msk)) { + if (mptcp_userspace_pm_active(msk)) { + mptcp_pm_announce_addr(msk, addr, true); + mptcp_pm_add_addr_send_ack(msk); + } else { + __MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP); + } + } else if (!READ_ONCE(pm->accept_addr)) { mptcp_pm_announce_addr(msk, addr, true); mptcp_pm_add_addr_send_ack(msk); } else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) { diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 10a73898c8db..491aedc486f1 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -798,6 +798,9 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (!removed) continue; + if (!mptcp_pm_is_kernel(msk)) + continue; + if (rm_type == MPTCP_MIB_RMADDR) { msk->pm.add_addr_accepted--; WRITE_ONCE(msk->pm.accept_addr, true); @@ -1848,6 +1851,13 @@ static void mptcp_nl_mcast_send(struct net *net, struct sk_buff *nlskb, gfp_t gf nlskb, 0, MPTCP_PM_EV_GRP_OFFSET, gfp); } +bool mptcp_userspace_pm_active(const struct mptcp_sock *msk) +{ + return genl_has_listeners(&mptcp_genl_family, + sock_net((const struct sock *)msk), + MPTCP_PM_EV_GRP_OFFSET); +} + static int mptcp_event_add_subflow(struct sk_buff *skb, const struct sock *ssk) { const struct inet_sock *issk = inet_sk(ssk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 54d2b3b2d100..85390146944d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -784,6 +784,7 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); void mptcp_event_addr_announced(const struct mptcp_sock *msk, const struct mptcp_addr_info *info); void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id); +bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { @@ -811,6 +812,11 @@ static inline bool mptcp_pm_is_userspace(const struct mptcp_sock *msk) return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_USERSPACE; } +static inline bool mptcp_pm_is_kernel(const struct mptcp_sock *msk) +{ + return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_KERNEL; +} + static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port) { u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 75c824b67ca9..9567231a4bfa 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -62,7 +62,9 @@ static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2, static bool mptcp_can_accept_new_subflow(const struct mptcp_sock *msk) { return mptcp_is_fully_established((void *)msk) && - READ_ONCE(msk->pm.accept_subflow); + ((mptcp_pm_is_userspace(msk) && + mptcp_userspace_pm_active(msk)) || + READ_ONCE(msk->pm.accept_subflow)); } /* validate received token and create truncated hmac and nonce for SYN-ACK */ From patchwork Tue Mar 29 02:13:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishen Maloor X-Patchwork-Id: 12794383 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E74B520E6 for ; Tue, 29 Mar 2022 02:14:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648520051; x=1680056051; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=GKhZx0nF/uINtofrjJx97ZVcvMzDhR2KV3qHhBQpcrw=; b=nSDeYqTnSeDnlB/vRqtVoHnVw1uBTffDLkC4KY703JyL9UbHwyZtLU22 9BLJ27hyt7syTVmA0A2pH6aLcsw1gRLEqFGF4A/AUtqqN1phwRW2mnBgg L1khLWr4sye4OAV37RTITnZZSy77EV/xDoZW6a7hxobzRxkDsS+1+aLnr 0QzrUTJf9e5Ums4z7byZeA3XStemO627vWV/qEzjkIMaJWSVpgc47Xk57 zg2KMaqOMvjdvabKIg3JCaWctf5kOucYdhEOUCO8xewmuBkANrGe35Gdl a99WMwsRAeGAytxnsIzWdSV6WGe6OiYCXm9c/wb8kCP4i6MkMPkw8v7tz w==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345578744" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="345578744" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564202544" Received: from otc-tsn-4.jf.intel.com ([10.23.153.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:07 -0700 From: Kishen Maloor To: kishen.maloor@intel.com, mptcp@lists.linux.dev Subject: [PATCH mptcp-next v9 3/6] mptcp: store remote id from MP_JOIN SYN/ACK in local ctx Date: Mon, 28 Mar 2022 22:13:58 -0400 Message-Id: <20220329021401.1196466-4-kishen.maloor@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329021401.1196466-1-kishen.maloor@intel.com> References: <20220329021401.1196466-1-kishen.maloor@intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This change reads the addr id assigned to the remote endpoint of a subflow from the MP_JOIN SYN/ACK message and stores it in the related subflow context. The remote id was not being captured prior to this change, and will now provide a consistent view of remote endpoints and their ids as seen through netlink events. Signed-off-by: Kishen Maloor --- net/mptcp/subflow.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 9567231a4bfa..a0e7af33fb26 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -443,6 +443,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->backup = mp_opt.backup; subflow->thmac = mp_opt.thmac; subflow->remote_nonce = mp_opt.nonce; + subflow->remote_id = mp_opt.join_id; pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u backup=%d", subflow, subflow->thmac, subflow->remote_nonce, subflow->backup); From patchwork Tue Mar 29 02:13:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishen Maloor X-Patchwork-Id: 12794384 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1049220E5 for ; Tue, 29 Mar 2022 02:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648520052; x=1680056052; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=M8VFKEXFq01Bzu5rjwUUaGZPLEnPWvxibr49JsGr9Tg=; b=S6sg2I7Yg7Zcdhcl/X035hmtBgsaLNApB8Sw2jBORp8rJfmbgjUk+nhy PKALkJV5rldmEQyn4Jv+C/5lBJ8YgY9+I4TKhz6sh+qORj5eLEQ22bUX6 4KE90RtvlY8ljUlqYRL7VvIZBuq7q2/WzHC9eIamYCc0Tq+Lkxs3nN+8H etxthkE/0GJ3MCZvKPWAp2I9Rnlbu4dE0JnPh04pfVm4hjW6/92Y9JCig uT4sbOj9ViwAwclzHTCfbVueilw1JKGtUeiftlRCW3jJ/fWTnjLG9e489 pcRnpYkT34bGubuIgGOG59iJbYlYkIUQzgVgkrdXpabZnL47SigOgWVGA A==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345578745" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="345578745" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564202547" Received: from otc-tsn-4.jf.intel.com ([10.23.153.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 From: Kishen Maloor To: kishen.maloor@intel.com, mptcp@lists.linux.dev Subject: [PATCH mptcp-next v9 4/6] mptcp: reflect remote port (not 0) in ANNOUNCED events Date: Mon, 28 Mar 2022 22:13:59 -0400 Message-Id: <20220329021401.1196466-5-kishen.maloor@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329021401.1196466-1-kishen.maloor@intel.com> References: <20220329021401.1196466-1-kishen.maloor@intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Per RFC 8684, if no port is specified in an ADD_ADDR message, MPTCP SHOULD attempt to connect to the specified address on the same port as the port that is already in use by the subflow on which the ADD_ADDR signal was sent. To facilitate that, this change reflects the specific remote port in use by that subflow in MPTCP_EVENT_ANNOUNCED events. Signed-off-by: Kishen Maloor --- v9: removed explicit 'struct inet_sock *' cast. --- net/mptcp/options.c | 2 +- net/mptcp/pm.c | 6 ++++-- net/mptcp/pm_netlink.c | 11 ++++++++--- net/mptcp/protocol.h | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 88f4ebbd6515..c9625fea3ef9 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1133,7 +1133,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) if ((mp_opt.suboptions & OPTION_MPTCP_ADD_ADDR) && add_addr_hmac_valid(msk, &mp_opt)) { if (!mp_opt.echo) { - mptcp_pm_add_addr_received(msk, &mp_opt.addr); + mptcp_pm_add_addr_received(sk, &mp_opt.addr); MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDR); } else { mptcp_pm_add_addr_echoed(msk, &mp_opt.addr); diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 8df9cb28d970..5d6832c4d9f2 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -200,15 +200,17 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock *ssk, spin_unlock_bh(&pm->lock); } -void mptcp_pm_add_addr_received(struct mptcp_sock *msk, +void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr) { + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); + struct mptcp_sock *msk = mptcp_sk(subflow->conn); struct mptcp_pm_data *pm = &msk->pm; pr_debug("msk=%p remote_id=%d accept=%d", msk, addr->id, READ_ONCE(pm->accept_addr)); - mptcp_event_addr_announced(msk, addr); + mptcp_event_addr_announced(ssk, addr); spin_lock_bh(&pm->lock); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 491aedc486f1..6b555b20fd6f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -2012,10 +2012,12 @@ void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id) kfree_skb(skb); } -void mptcp_event_addr_announced(const struct mptcp_sock *msk, +void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_info *info) { - struct net *net = sock_net((const struct sock *)msk); + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); + struct mptcp_sock *msk = mptcp_sk(subflow->conn); + struct net *net = sock_net(ssk); struct nlmsghdr *nlh; struct sk_buff *skb; @@ -2037,7 +2039,10 @@ void mptcp_event_addr_announced(const struct mptcp_sock *msk, if (nla_put_u8(skb, MPTCP_ATTR_REM_ID, info->id)) goto nla_put_failure; - if (nla_put_be16(skb, MPTCP_ATTR_DPORT, info->port)) + if (nla_put_be16(skb, MPTCP_ATTR_DPORT, + info->port == 0 ? + inet_sk(ssk)->inet_dport : + info->port)) goto nla_put_failure; switch (info->family) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 85390146944d..a762b789f5ab 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -753,7 +753,7 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk); bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk); void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock *ssk, const struct mptcp_subflow_context *subflow); -void mptcp_pm_add_addr_received(struct mptcp_sock *msk, +void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr); void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); @@ -782,7 +782,7 @@ int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list * void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); -void mptcp_event_addr_announced(const struct mptcp_sock *msk, const struct mptcp_addr_info *info); +void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_info *info); void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id); bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); From patchwork Tue Mar 29 02:14:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishen Maloor X-Patchwork-Id: 12794385 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B70720EA for ; Tue, 29 Mar 2022 02:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648520052; x=1680056052; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=d/xDT6btLh0ZvnslagoXCmEcD+Xgida3BERey+wbCB8=; b=AQuU7PONG3kSvKsXAF8MTTbEt6Uh+OTyao/sHgQ3B3/iHD7N8hPC7PRY PfsfQd54c3IBirZjRua/zuf1SfEu9yoaYB8uPmmJVzDCkVgnFeu7XZFli 08mBVeMi6rtT53/s7mVq8r+EyZ+zh801UW40R01EPhpigow9RV9filCUS 8c7ZDlRK8VkQX3wvFKC1maa2vtLB2nyxkQWA/mwzuR3mW4oVktYRHK9/c F78/A38gMpAIlrh+R21ELR3IDVpe7J/4F60wm2gQtzBL3lsWQ27YCWqdq 8BAxIkcDhYSZhp51iNPLbEbwB8UXM2SlU7wyhqktgkUF02E3lAGtBrMPf g==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345578746" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="345578746" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564202551" Received: from otc-tsn-4.jf.intel.com ([10.23.153.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 From: Kishen Maloor To: kishen.maloor@intel.com, mptcp@lists.linux.dev Subject: [PATCH mptcp-next v9 5/6] mptcp: establish subflows from either end of connection Date: Mon, 28 Mar 2022 22:14:00 -0400 Message-Id: <20220329021401.1196466-6-kishen.maloor@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329021401.1196466-1-kishen.maloor@intel.com> References: <20220329021401.1196466-1-kishen.maloor@intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This change updates internal logic to permit subflows to be established from either the client or server ends of MPTCP connections. This symmetry and added flexibility may be harnessed by PM implementations running on either end in creating new subflows. The essence of this change lies in not relying on the "server_side" flag (which continues to be available if needed). Signed-off-by: Kishen Maloor --- net/mptcp/options.c | 2 +- net/mptcp/protocol.c | 5 +---- net/mptcp/protocol.h | 8 ++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index c9625fea3ef9..e05d9458a025 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -931,7 +931,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, if (TCP_SKB_CB(skb)->seq == subflow->ssn_offset + 1 && TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq && subflow->mp_join && (mp_opt->suboptions & OPTIONS_MPTCP_MPJ) && - READ_ONCE(msk->pm.server_side)) + !subflow->request_join) tcp_send_ack(ssk); goto fully_established; } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d3887f628b54..b2c654992de0 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3327,15 +3327,12 @@ bool mptcp_finish_join(struct sock *ssk) return false; } - if (!msk->pm.server_side) + if (!list_empty(&subflow->node)) goto out; if (!mptcp_pm_allow_new_subflow(msk)) goto err_prohibited; - if (WARN_ON_ONCE(!list_empty(&subflow->node))) - goto err_prohibited; - /* active connections are already on conn_list. * If we can't acquire msk socket lock here, let the release callback * handle it diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a762b789f5ab..187c932deef0 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -911,13 +911,17 @@ static inline bool mptcp_check_infinite_map(struct sk_buff *skb) return false; } +static inline bool is_active_ssk(struct mptcp_subflow_context *subflow) +{ + return (subflow->request_mptcp || subflow->request_join); +} + static inline bool subflow_simultaneous_connect(struct sock *sk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); - struct sock *parent = subflow->conn; return sk->sk_state == TCP_ESTABLISHED && - !mptcp_sk(parent)->pm.server_side && + is_active_ssk(subflow) && !subflow->conn_finished; } From patchwork Tue Mar 29 02:14:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishen Maloor X-Patchwork-Id: 12794386 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2729C20E6 for ; Tue, 29 Mar 2022 02:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648520053; x=1680056053; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=kfzkYvxkvtrOkLLjy4C+eKMJJ5Jur2DgftgTUihqKsY=; b=CU8P/gSvWozSfHIOTDyW1/wEVXMUBCp8b6lXgGOR98jaXCJEtttoSfK+ rTGTu+wl44jG6DrcPvubWqCpB4esr9uCkdLJ2w0N1WqGldPjU7XEzRW49 Dg8HWtt6xPvXbHjw1Wd2ga5GVdXSUIOa85mfbdmYyiRFEkg/yUYhHC1Th 0KtPrhrh8mqVdo/EWu9lmLzx075P2cRsRUoKrj09Oc4kjm4lNA0oC7kgi KCQG5iKWskz7nH3OROkahK8e/d/i6hutvCNn50RlYc0kTONYbBPpwa5JM +vWAY3K9Ndv4M68xj9ezJ69lC1zi2RyjL8BKIZ6JK52bTV8OetA5RfI46 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345578747" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="345578747" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564202554" Received: from otc-tsn-4.jf.intel.com ([10.23.153.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:14:08 -0700 From: Kishen Maloor To: kishen.maloor@intel.com, mptcp@lists.linux.dev Subject: [PATCH mptcp-next v9 6/6] mptcp: expose server_side attribute in MPTCP netlink events Date: Mon, 28 Mar 2022 22:14:01 -0400 Message-Id: <20220329021401.1196466-7-kishen.maloor@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329021401.1196466-1-kishen.maloor@intel.com> References: <20220329021401.1196466-1-kishen.maloor@intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This change records the 'server_side' attribute of MPTCP_EVENT_CREATED and MPTCP_EVENT_ESTABLISHED events to inform their recipient about the Client/Server role of the running MPTCP application. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/246 Signed-off-by: Kishen Maloor --- include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 9690efedb5fa..e41ea01a94bb 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -188,6 +188,7 @@ enum mptcp_event_attr { MPTCP_ATTR_IF_IDX, /* s32 */ MPTCP_ATTR_RESET_REASON,/* u32 */ MPTCP_ATTR_RESET_FLAGS, /* u32 */ + MPTCP_ATTR_SERVER_SIDE, /* u8 */ __MPTCP_ATTR_AFTER_LAST }; diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 6b555b20fd6f..7c92af2ad900 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1978,6 +1978,9 @@ static int mptcp_event_created(struct sk_buff *skb, if (err) return err; + if (nla_put_u8(skb, MPTCP_ATTR_SERVER_SIDE, READ_ONCE(msk->pm.server_side))) + return -EMSGSIZE; + return mptcp_event_add_subflow(skb, ssk); }