From nobody Thu Oct 31 23:57:45 2024 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 6099612B8F for ; Mon, 18 Dec 2023 09:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="CduSA2Fj" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DpSBD9N/x5aEGxIPRRsMeG+JJ/FV1c5vPkV2EXAaxMg=; b=CduSA2Fj5BfzqY9/Ao4zSg49gBxs9qdJTtSFBo4pGm6bP0Z9pRnEFRN7KqFZoLmDqrMXbP f1J0KN+78eiofWElLrq/SxUJ92D+xGt96Kp5lxr1eRpBFy6t69R2zx3HnVZ4n8485GdztD GEwgPTT6Poj4UMIk1GHD7SGoYIbWc1o= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 01/15] mptcp: add mptcp_pm_nl_put_entry_msg helper Date: Mon, 18 Dec 2023 17:23:30 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Extract the genlmsg related code from mptcp_pm_nl_get_addr_dumpit() into a new helper mptcp_pm_nl_put_entry_msg(). It will be used in the userspace PM dump_addr(). Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 35 ++++++++++++++++++++++++----------- net/mptcp/protocol.h | 3 +++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c84cc0908cfc..43062cd23ba3 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1658,6 +1658,29 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } =20 +int mptcp_pm_nl_put_entry_msg(struct sk_buff *msg, + struct netlink_callback *cb, + struct mptcp_pm_addr_entry *entry) +{ + void *hdr; + int ret; + + hdr =3D genlmsg_put(msg, NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, &mptcp_genl_family, + NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR); + if (!hdr) + return -EMSGSIZE; + + ret =3D mptcp_nl_fill_addr(msg, entry); + if (ret < 0) { + genlmsg_cancel(msg, hdr); + return ret; + } + + genlmsg_end(msg, hdr); + return 0; +} + int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; @@ -1715,7 +1738,6 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; int id =3D cb->args[0]; - void *hdr; int i; =20 pernet =3D pm_nl_get_pernet(net); @@ -1730,19 +1752,10 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, if (entry->addr.id <=3D id) continue; =20 - hdr =3D genlmsg_put(msg, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, &mptcp_genl_family, - NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR); - if (!hdr) - break; - - if (mptcp_nl_fill_addr(msg, entry) < 0) { - genlmsg_cancel(msg, hdr); + if (mptcp_pm_nl_put_entry_msg(msg, cb, entry)) break; - } =20 id =3D entry->addr.id; - genlmsg_end(msg, hdr); } } spin_unlock_bh(&pernet->lock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f7b9c1b995df..23d4742f3f30 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1022,6 +1022,9 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk,= const struct sk_buff *skb, bool *drop_other_suboptions); bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remainin= g, struct mptcp_rm_list *rm_list); +int mptcp_pm_nl_put_entry_msg(struct sk_buff *msg, + struct netlink_callback *cb, + struct mptcp_pm_addr_entry *entry); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inf= o *skc); int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_a= ddr_info *skc); --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (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 A90BD12B92 for ; Mon, 18 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="KsHM3W10" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3VT602ytGc/YyEW8cf2FVP8n4BkeEbtLefQdnbdFZgc=; b=KsHM3W109u6vFINGEhToQPx+ALTtoKJjONQiieDGUHlVaWdzz6Kl4KTbjm5vkYyG+iNJ9+ O9aCJyZ5j4Ke41y1nVLvzkoXmZv9XsLay4bKR9XkOJxoyyapMxM6K6wvmjpivfVu183f3U HzfZ+sDZtE7Z8ivsFHx4D00d7ANF8vI= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 02/15] mptcp: implement mptcp_userspace_pm_dump_addr Date: Mon, 18 Dec 2023 17:23:31 +0800 Message-Id: <8f08f61a98463a38e6617a01dc789c78b0d414e5.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch implements mptcp_userspace_pm_dump_addr() to dump addresses from userspace pm address list. Use mptcp_token_get_sock() to get the msk from the given token, if userspace PM is enabled in it, traverse each address entry in address list, put every entry to userspace using mptcp_pm_nl_put_entry_msg(). Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 39 +++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 2 ++ 2 files changed, 41 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index efecbe3cf415..a497148039c6 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -550,3 +550,42 @@ int mptcp_userspace_pm_set_flags(struct net *net, stru= ct nlattr *token, sock_put(sk); return ret; } + +int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, + struct netlink_callback *cb) +{ + const struct genl_info *info =3D genl_info_dump(cb); + struct net *net =3D sock_net(msg->sk); + struct mptcp_pm_addr_entry *entry; + struct mptcp_sock *msk; + int id =3D cb->args[0]; + int ret =3D -EINVAL; + + if (!info->attrs[MPTCP_PM_ATTR_TOKEN]) + return ret; + + msk =3D mptcp_token_get_sock(net, nla_get_u32(info->attrs[MPTCP_PM_ATTR_T= OKEN])); + if (!msk) + return ret; + + if (mptcp_pm_is_userspace(msk)) { + struct sock *sk =3D (struct sock *)msk; + + lock_sock(sk); + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (entry->addr.id <=3D id) + continue; + + if (mptcp_pm_nl_put_entry_msg(msg, cb, entry)) + break; + + id =3D entry->addr.id; + } + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + } + + cb->args[0] =3D id; + return msg->len; +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 23d4742f3f30..a05a6745bc31 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1028,6 +1028,8 @@ int mptcp_pm_nl_put_entry_msg(struct sk_buff *msg, int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inf= o *skc); int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_a= ddr_info *skc); +int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, + struct netlink_callback *cb); =20 void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 E038C11720 for ; Mon, 18 Dec 2023 09:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="U5C6AcaA" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZGwYV0voJIRUqJBzl5iZjI7koy5k2JcEawmoV2Jif+0=; b=U5C6AcaATsOmzUYAQ9INx3LIOAfw93NiwJihTep6qt42xeTn246BPzoWJkZsbv6fwtzuiy 6n6DSIYzgF9giry43dP9LCgWOJpXiZ/l45I/Fj7mWl8M/yHcGOFCBLMZyrHHHg9GU8hHah mHt10BIBOqlmo18khlGY2wm2EPfAhiw= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 03/15] mptcp: dump addrs in userspace pm list Date: Mon, 18 Dec 2023 17:23:32 +0800 Message-Id: <313245a67713d1b70a0e52544a195af2f91f0825.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch renames mptcp_pm_nl_get_addr_dumpit() to in-kernel netlink PM dump addrs function mptcp_pm_nl_dump_addr(), then invoke both in-kernel PM mptcp_pm_nl_dump_addr() and userspace PM mptcp_userspace_pm_dump_addr() dump addrs functions in mptcp_pm_nl_get_addr_dumpit(). Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 43062cd23ba3..ced8cab36b41 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1731,8 +1731,8 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, st= ruct genl_info *info) return ret; } =20 -int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, - struct netlink_callback *cb) +static int mptcp_pm_nl_dump_addr(struct sk_buff *msg, + struct netlink_callback *cb) { struct net *net =3D sock_net(msg->sk); struct mptcp_pm_addr_entry *entry; @@ -1764,6 +1764,13 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, return msg->len; } =20 +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) +{ + return mptcp_pm_nl_dump_addr(msg, cb) + + mptcp_userspace_pm_dump_addr(msg, cb); +} + static int parse_limit(struct genl_info *info, int id, unsigned int *limit) { struct nlattr *attr =3D info->attrs[id]; --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 28320101F0 for ; Mon, 18 Dec 2023 09:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="H7rOAwmg" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cS9X+f5CmxyCG9MPPvqJrOoYT5xRvqFNgYpAlm6iWdE=; b=H7rOAwmgd7mFVzOmyqmkch91MkgJxlyNnuuES00uBjXqv5hJE7j/GhIK7YUVaJ4anEZxlQ atzvF8++ZsPbfEqp2EE4+0Yuz7+k5B81NR4QCLsJfgwvpa8kTHvNqJiy1l7ADm7tZknru7 Jkq1g0q+m4TGl9KB7H/Ba/EWSxXId94= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 04/15] mptcp: check userspace pm subflow flag Date: Mon, 18 Dec 2023 17:23:33 +0800 Message-Id: <7dad529ef954a342a0391fb8e5e0a9dc094b227c.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch uses mptcp_pm_parse_entry() instead of mptcp_pm_parse_addr() to get the flags of the entry. Add MPTCP_PM_ADDR_FLAG_SUBFLOW flag check in mptcp_pm_nl_subflow_create_doit(). Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index a497148039c6..b4345d62bdad 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -348,12 +348,19 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *s= kb, struct genl_info *info) goto create_err; } =20 - err =3D mptcp_pm_parse_addr(laddr, info, &addr_l); + err =3D mptcp_pm_parse_entry(laddr, info, true, &local); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); goto create_err; } =20 + if (!(local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) { + GENL_SET_ERR_MSG(info, "invalid addr flags"); + err =3D -EINVAL; + goto create_err; + } + addr_l =3D local.addr; + err =3D mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); @@ -366,7 +373,6 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb= , struct genl_info *info) goto create_err; } =20 - local.addr =3D addr_l; err =3D mptcp_userspace_pm_append_new_local_addr(msk, &local); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 509C611720 for ; Mon, 18 Dec 2023 09:25:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="e5PwgIEH" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gjqYl5HjrE/PcyKOI4j2xbJwPljHGTqCFh0OUGGn4/o=; b=e5PwgIEHhS1yISTADxEaACw9B5LzBgYCmjXZolcGmRGMZ6oedxO5GpBxGKqXHInivgFvV9 kSQzO4tNlWRToKmNNlFpK26Nh2jluIoU6NsCEDx2ubqkHazJ4IVMFDP+ZQpI/ZNbs8JQh/ vRoPJzG59uI8NXntZtMdxIFkhPfm7Ds= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 05/15] mptcp: add token for get-addr in yaml Date: Mon, 18 Dec 2023 17:23:34 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch adds token paramenter together with addr in get-addr section in mptcp.yaml, then use the following commands to update mptcp_pm_gen.c and mptcp_pm_gen.h: ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec Documentation/netlink/specs/mptcp.yaml --source \ -o net/mptcp/mptcp_pm_gen.c ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec Documentation/netlink/specs/mptcp.yaml --header \ -o net/mptcp/mptcp_pm_gen.h Signed-off-by: Geliang Tang --- Documentation/netlink/specs/mptcp.yaml | 5 ++++- net/mptcp/mptcp_pm_gen.c | 7 ++++--- net/mptcp/mptcp_pm_gen.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink= /specs/mptcp.yaml index 49f90cfb4698..cc731dbaa427 100644 --- a/Documentation/netlink/specs/mptcp.yaml +++ b/Documentation/netlink/specs/mptcp.yaml @@ -292,20 +292,23 @@ operations: - name: get-addr doc: Get endpoint information - attribute-set: endpoint + attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] do: &get-addr-attrs request: attributes: - addr + - token reply: attributes: - addr + - token dump: reply: attributes: - addr + - token - name: flush-addrs doc: flush addresses diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c index a2325e70ddab..69c8857b4c5d 100644 --- a/net/mptcp/mptcp_pm_gen.c +++ b/net/mptcp/mptcp_pm_gen.c @@ -32,8 +32,9 @@ const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP= _PM_ENDPOINT_ADDR + 1] }; =20 /* MPTCP_PM_CMD_GET_ADDR - do */ -const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR= + 1] =3D { - [MPTCP_PM_ENDPOINT_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy= ), +const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ATTR_TOKEN + = 1] =3D { + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, }; =20 /* MPTCP_PM_CMD_FLUSH_ADDRS - do */ @@ -110,7 +111,7 @@ const struct genl_ops mptcp_pm_nl_ops[11] =3D { .doit =3D mptcp_pm_nl_get_addr_doit, .dumpit =3D mptcp_pm_nl_get_addr_dumpit, .policy =3D mptcp_pm_get_addr_nl_policy, - .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .maxattr =3D MPTCP_PM_ATTR_TOKEN, .flags =3D GENL_UNS_ADMIN_PERM, }, { diff --git a/net/mptcp/mptcp_pm_gen.h b/net/mptcp/mptcp_pm_gen.h index 10579d184587..3963c55950b7 100644 --- a/net/mptcp/mptcp_pm_gen.h +++ b/net/mptcp/mptcp_pm_gen.h @@ -18,7 +18,7 @@ extern const struct nla_policy mptcp_pm_add_addr_nl_polic= y[MPTCP_PM_ENDPOINT_ADD =20 extern const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1]; =20 -extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1]; +extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ATTR_T= OKEN + 1]; =20 extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_END= POINT_ADDR + 1]; =20 --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (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 DCF0011CAA for ; Mon, 18 Dec 2023 09:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Xx0SDC5C" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iCRljyM6OH4MsBLRN/q3Q8fR6iBdnpBdYGMdYVR28SY=; b=Xx0SDC5CpXCCKo13ZUhXGQnywFeVtVbORf8KOoUh9rFWnN/ekN/UIwAp9urSYB4Nu61bEH beUpGhaIB/GKAxI0Hhd8PmOv3ODEM6j5F+eZxIGRgo01mphYmKfb5FGAC2LDqtmCp8PW1w pPtnSnmSFgnm5jRdLsOgoKByGsgB5EQ= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 06/15] selftests: mptcp: add userspace pm subflow flag Date: Mon, 18 Dec 2023 17:23:35 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch adds the address flag MPTCP_PM_ADDR_FLAG_SUBFLOW in csf() in pm_nl_ctl.c when subflow is created by a userspace PM. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/= selftests/net/mptcp/pm_nl_ctl.c index 49369c4a5f26..e97856323ec3 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -453,6 +453,7 @@ int csf(int fd, int pm_family, int argc, char *argv[]) char data[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct genlmsghdr)) + 1024]; + u_int32_t flags =3D MPTCP_PM_ADDR_FLAG_SUBFLOW; const char *params[5]; struct nlmsghdr *nh; struct rtattr *addr; @@ -558,6 +559,13 @@ int csf(int fd, int pm_family, int argc, char *argv[]) off +=3D NLMSG_ALIGN(rta->rta_len); } =20 + /* addr flags */ + rta =3D (void *)(data + off); + rta->rta_type =3D MPTCP_PM_ADDR_ATTR_FLAGS; + rta->rta_len =3D RTA_LENGTH(4); + memcpy(RTA_DATA(rta), &flags, 4); + off +=3D NLMSG_ALIGN(rta->rta_len); + addr->rta_len =3D off - addr_start; } =20 --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (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 3194F11CB2 for ; Mon, 18 Dec 2023 09:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="SBM5g0Sz" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IUNLUS9kjQsNN5jTynBv12p6pFgdSs7eV0RbzSa0hYU=; b=SBM5g0SzdCtw6P0AVXG3k0O50kmo5qCAdMFo2g3D5rxTDlmsFq2G9gLpOSjF49q1Nm/LMT u772y3hEONTBPgPwOLF4M0avUGDjCsMEndYtg1PoCrCy0iapiZvRDJeBZWcIW6Kpggi2Bd sTkkKM1mbWuiErbX1KiVBpYGr3Rj+Pk= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 07/15] selftests: mptcp: add token for dump_addr Date: Mon, 18 Dec 2023 17:23:36 +0800 Message-Id: <6a993de9b349c4c596a96e4488b972e290615fc8.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The command dump_addr() of pm_nl_ctl can be used like this in in-kernel PM: pm_nl_ctl dump This patch adds token argument for it to support userspace PM: pm_nl_ctl dump token $token If 'token $token' is passed to dump_addr(), copy it into the kernel netlink. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/= selftests/net/mptcp/pm_nl_ctl.c index e97856323ec3..8d7d1b4ed28e 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -1127,8 +1127,16 @@ int dump_addrs(int fd, int pm_family, int argc, char= *argv[]) 1024]; pid_t pid =3D getpid(); struct nlmsghdr *nh; + u_int32_t token =3D 0; + struct rtattr *rta; int off =3D 0; =20 + if (argc !=3D 2 && argc !=3D 4) + syntax(argv); + + if (argc =3D=3D 4 && !strcmp(argv[2], "token")) + token =3D strtoul(argv[3], NULL, 10); + memset(data, 0, sizeof(data)); nh =3D (void *)data; off =3D init_genl_req(data, pm_family, MPTCP_PM_CMD_GET_ADDR, @@ -1138,6 +1146,15 @@ int dump_addrs(int fd, int pm_family, int argc, char= *argv[]) nh->nlmsg_pid =3D pid; nh->nlmsg_len =3D off; =20 + /* token */ + if (token) { + rta =3D (void *)(data + off); + rta->rta_type =3D MPTCP_PM_ATTR_TOKEN; + rta->rta_len =3D RTA_LENGTH(4); + memcpy(RTA_DATA(rta), &token, 4); + off +=3D NLMSG_ALIGN(rta->rta_len); + } + print_addrs(nh, pm_family, do_nl_req(fd, nh, off, sizeof(data))); return 0; } --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 7018311724 for ; Mon, 18 Dec 2023 09:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XmG/Qd/4" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ERiB6Pet9ivx6wj4QdFsUs/qDRxTIgiskMJwm/GxbRs=; b=XmG/Qd/4gEHlJ7f1O04xF/260rMr/oGbmUVnOduV+dEBWcs7qFkjPw813eFcxRbx78qiCv Gn9HfX7HMwKBWVKu/HI/abZbcub8e2ijIkcziedPvXW+muuCC1AAatKT8vtvQOZRAGlfM0 uAMjFkQsOdC6XQdfr1QpiuWGDIZL5XY= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 08/15] selftests: mptcp: add check_output helper Date: Mon, 18 Dec 2023 17:23:37 +0800 Message-Id: <8fbe47ba2065f6c2d659ccda914965d00bd84c34.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Similar to check() in pm_netlink.sh, add a new helper check_output() in mptcp_join.sh to check the output of the given commands. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 3a5b63026191..25d3f32644ed 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -21,6 +21,7 @@ cinfail=3D"" cinsent=3D"" tmpfile=3D"" cout=3D"" +check_output_err=3D"" capout=3D"" ns1=3D"" ns2=3D"" @@ -186,6 +187,7 @@ init() { cout=3D$(mktemp) evts_ns1=3D$(mktemp) evts_ns2=3D$(mktemp) + check_output_err=3D$(mktemp) =20 trap cleanup EXIT =20 @@ -199,6 +201,7 @@ cleanup() rm -f "$sin" "$sout" "$cinsent" "$cinfail" rm -f "$tmpfile" rm -rf $evts_ns1 $evts_ns2 + rm -f $check_output_err cleanup_partial } =20 @@ -3357,6 +3360,30 @@ userspace_pm_rm_sf() wait_rm_sf $1 "${cnt}" } =20 +check_output() +{ + local cmd=3D"$1" + local expected=3D"$2" + local msg=3D"$3" + local out=3D`$cmd 2>$check_output_err` + local cmd_ret=3D$? + + printf "%-42s" "$msg" + if [ $cmd_ret -ne 0 ]; then + mptcp_lib_print_err "[ FAIL ] command execution '$cmd' stderr " + cat $check_output_err + ret=3D${KSFT_FAIL} + return $cmd_ret + elif [ "$out" =3D "$expected" ]; then + mptcp_lib_print_ok "[ OK ]" + return 0 + else + mptcp_lib_print_err "[ FAIL ] expected '$expected' got '$out'" + ret=3D${KSFT_FAIL} + return 1 + fi +} + userspace_tests() { # userspace pm type prevents add_addr --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 4E5C311C82 for ; Mon, 18 Dec 2023 09:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="IZNwkyVB" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z/Ii6GsSUtx5/gkFNNJl6jtYbkzb/prif7eMb5oRvzo=; b=IZNwkyVBeg5u+u875IgqBisP+MxzqEB7GgvsBEhKg5dHY0xRs8UcQ59RE6Bnxc/1d+kVAL a0XLZQU/bo7zGfbkKUT69+omj3Aulsfp1WyYYfSuzH0sxTeE3QCo9vbI/WDY9m9mjZdN7l 0izvlOqKmTnr8aeOtPzPnbnz/v+J4oc= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 09/15] selftests: mptcp: dump userspace addrs list Date: Mon, 18 Dec 2023 17:23:38 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch adds a new helper userspace_pm_dump() to dump addresses for the userspace PM. Add two new tests for userspace pm dump address and subflow. Use userspace_pm_add_addr() and userspace_pm_add_sf() to add an address and a suflow. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 25d3f32644ed..403200394aa7 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3360,6 +3360,18 @@ userspace_pm_rm_sf() wait_rm_sf $1 "${cnt}" } =20 +# $1: ns +userspace_pm_dump() +{ + local evts=3D$evts_ns1 + local tk + + [ "$1" =3D=3D "$ns2" ] && evts=3D$evts_ns2 + tk=3D$(mptcp_lib_evts_get_info token "$evts") + + ip netns exec $1 ./pm_nl_ctl dump token $tk +} + check_output() { local cmd=3D"$1" @@ -3573,6 +3585,50 @@ userspace_tests() kill_events_pids wait $tests_pid fi + + # userspace pm dump address + if reset_with_events "userspace pm dump address" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + pm_nl_set_limits $ns2 1 1 + speed=3D5 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=3D$! + wait_mpj $ns1 + userspace_pm_add_addr $ns1 10.0.2.1 10 + chk_join_nr 1 1 1 + chk_add_nr 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows_total 2 2 + chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 + local dump=3D"id 10 flags signal 10.0.2.1" + check_output "userspace_pm_dump $ns1" \ + "$dump" " dump addrs signal" + kill_events_pids + wait $tests_pid + fi + + # userspace pm dump subflow + if reset_with_events "userspace pm dump subflow" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 + speed=3D5 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=3D$! + wait_mpj $ns2 + chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 + userspace_pm_add_sf $ns2 10.0.3.2 20 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows_total 2 2 + local dump=3D"id 20 flags subflow 10.0.3.2" + check_output "userspace_pm_dump $ns2" \ + "$dump" " dump addrs subflow" + kill_events_pids + wait $tests_pid + fi } =20 endpoint_tests() --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 6B49211CA6 for ; Mon, 18 Dec 2023 09:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XvRGTE2o" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9w/fUzw4JViPoJVWSNkuhUWi6+5X27/3IVJYmQG0Wls=; b=XvRGTE2oh/PqUSAklBwp6NaUJTboqgn1kjWqlVPSIoUKFK/WBY6R2I76VWb6EUGvJe72lf h4wRwWmhOuxDfr/JXGemEGXm/0f2nsg5EQbcjMSmeW+X5aP4yy75BO6ltmzr7joUkQZ6dj u5nM62J1MzLlTQftLXvfebzmG4l3pMg= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 10/15] mptcp: add userspace_pm_lookup_addr_by_id helper Date: Mon, 18 Dec 2023 17:23:39 +0800 Message-Id: <144fc76c364c8145c8bb8e31c5934af4a6977277.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Corresponding __lookup_addr_by_id() helper in the in-kernel netlink PM, this patch adds a new helper mptcp_userspace_pm_lookup_addr_by_id() to lookup the address entry with the given id on the userspace pm local address list. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index b4345d62bdad..0046cde103bb 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -105,19 +105,26 @@ static int mptcp_userspace_pm_delete_local_addr(struc= t mptcp_sock *msk, return -EINVAL; } =20 +static struct mptcp_pm_addr_entry * +mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int = id) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (entry->addr.id =3D=3D id) + return entry; + } + return NULL; +} + int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex) { - struct mptcp_pm_addr_entry *entry, *match =3D NULL; + struct mptcp_pm_addr_entry *match; =20 spin_lock_bh(&msk->pm.lock); - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (id =3D=3D entry->addr.id) { - match =3D entry; - break; - } - } + match =3D mptcp_userspace_pm_lookup_addr_by_id(msk, id); spin_unlock_bh(&msk->pm.lock); if (match) { *flags =3D match->flags; @@ -249,7 +256,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct= genl_info *info) { struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *id =3D info->attrs[MPTCP_PM_ATTR_LOC_ID]; - struct mptcp_pm_addr_entry *match =3D NULL; + struct mptcp_pm_addr_entry *match; struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; LIST_HEAD(free_list); @@ -286,13 +293,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struc= t genl_info *info) =20 lock_sock(sk); =20 - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (entry->addr.id =3D=3D id_val) { - match =3D entry; - break; - } - } - + match =3D mptcp_userspace_pm_lookup_addr_by_id(msk, id_val); if (!match) { GENL_SET_ERR_MSG(info, "address with specified id not found"); release_sock(sk); --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (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 B7450125A5 for ; Mon, 18 Dec 2023 09:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="eGHpaB33" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cSLlR/Ahfy2sIgGydhs0AHNUxKs1tMzf1n/TUL8pYvU=; b=eGHpaB33sD2XpXY8p79megRwpJgvKy6An5h+OCT6qfC4NhLaOTakSOs8akfmUCkngVfY4d 1Ng4E9GHSZzX//bufsqrbZw2LdN/4mDMfUmNOQhxTnTGgFuh2b4HrU1MA4vPvHRYQmdI5L AfYxy4y+Vlc30+WOEoFM0aWAHyLWPok= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 11/15] mptcp: add mptcp_pm_nl_put_entry_info helper Date: Mon, 18 Dec 2023 17:23:40 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch extracts the nlmsg related code from mptcp_pm_nl_get_addr_doit() into a new helper mptcp_pm_nl_put_entry_info(). It will be used in the userspace PM get_addr(). Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 55 ++++++++++++++++++++++++------------------ net/mptcp/protocol.h | 2 ++ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ced8cab36b41..ebc9841224a7 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1658,6 +1658,37 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } =20 +int mptcp_pm_nl_put_entry_info(struct genl_info *info, + struct mptcp_pm_addr_entry *entry) +{ + struct sk_buff *msg; + void *reply; + int ret; + + msg =3D nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + reply =3D genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, + info->genlhdr->cmd); + if (!reply) { + GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); + ret =3D -EMSGSIZE; + goto fail; + } + + ret =3D mptcp_nl_fill_addr(msg, entry); + if (ret) + goto fail; + + genlmsg_end(msg, reply); + ret =3D genlmsg_reply(msg, info); + return ret; +fail: + nlmsg_free(msg); + return ret; +} + int mptcp_pm_nl_put_entry_msg(struct sk_buff *msg, struct netlink_callback *cb, struct mptcp_pm_addr_entry *entry) @@ -1686,26 +1717,12 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, = struct genl_info *info) struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; - struct sk_buff *msg; - void *reply; int ret; =20 ret =3D mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; =20 - msg =3D nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; - - reply =3D genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, - info->genlhdr->cmd); - if (!reply) { - GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); - ret =3D -EMSGSIZE; - goto fail; - } - spin_lock_bh(&pernet->lock); entry =3D __lookup_addr_by_id(pernet, addr.addr.id); if (!entry) { @@ -1714,20 +1731,12 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, = struct genl_info *info) goto unlock_fail; } =20 - ret =3D mptcp_nl_fill_addr(msg, entry); - if (ret) - goto unlock_fail; - - genlmsg_end(msg, reply); - ret =3D genlmsg_reply(msg, info); + ret =3D mptcp_pm_nl_put_entry_info(info, entry); spin_unlock_bh(&pernet->lock); return ret; =20 unlock_fail: spin_unlock_bh(&pernet->lock); - -fail: - nlmsg_free(msg); return ret; } =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a05a6745bc31..a82a42c57c3d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1025,6 +1025,8 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, = unsigned int remaining, int mptcp_pm_nl_put_entry_msg(struct sk_buff *msg, struct netlink_callback *cb, struct mptcp_pm_addr_entry *entry); +int mptcp_pm_nl_put_entry_info(struct genl_info *info, + struct mptcp_pm_addr_entry *entry); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inf= o *skc); int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_a= ddr_info *skc); --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 07FEE125AE for ; Mon, 18 Dec 2023 09:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ofRSi15d" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891529; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zfuprda/gONUUIH7uJvmQpPtt0J+ycKWCsYEL6kIEFw=; b=ofRSi15dty9GiF8QGNU1gl4Esnl3eQ8b3bIiisWw7O4kKCuXrbp2hVf571G06eYTySqqNE TXVa6by8xlo/u0Iz9rJsmkGhz0sqFPzcmgDz4Ve48YBVEGxIDnMtLMwOvTCk1Ose23g6S5 bT8E3LHKrjIF5K+rlpyKv/74SBYVLEE= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 12/15] mptcp: implement mptcp_userspace_pm_get_addr Date: Mon, 18 Dec 2023 17:23:41 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch implements mptcp_userspace_pm_get_addr() to get an address from userspace pm address list according the given 'token' and 'id'. Use nla_get_u32() to get the u32 value of 'token', then pass it to mptcp_token_get_sock() to get the msk. Pass 'msk' and 'id' to the helper mptcp_userspace_pm_lookup_addr_by_id() to get the address entry. Put this entry to userspace using mptcp_pm_nl_put_entry_info(). Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 23 +++++++++++++++++++++++ net/mptcp/protocol.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 0046cde103bb..4a62739be1b8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -596,3 +596,26 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, cb->args[0] =3D id; return msg->len; } + +int mptcp_userspace_pm_get_addr(struct net *net, struct genl_info *info, + u32 token, u8 id) +{ + struct mptcp_pm_addr_entry *entry; + struct mptcp_sock *msk; + int ret =3D -EINVAL; + + msk =3D mptcp_token_get_sock(net, token); + if (!msk) + return ret; + + if (!mptcp_pm_is_userspace(msk)) + return ret; + + entry =3D mptcp_userspace_pm_lookup_addr_by_id(msk, id); + if (!entry) { + GENL_SET_ERR_MSG(info, "address not found"); + return ret; + } + + return mptcp_pm_nl_put_entry_info(info, entry); +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a82a42c57c3d..9632b52bb95a 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1032,6 +1032,8 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, = struct mptcp_addr_info *skc int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_a= ddr_info *skc); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); +int mptcp_userspace_pm_get_addr(struct net *net, struct genl_info *info, + u32 token, u8 id); =20 void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (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 72F67125B6 for ; Mon, 18 Dec 2023 09:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="n9EJ7v3W" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L9YhqeR0jXsf88rmbsJtmwXf+/JD9Gcu+n14D4b1+jg=; b=n9EJ7v3WDi/q46gF46E4IIcA/SiDMjjqrhUfpNEBeBDnugrt3RkMVk6E9BrjC+oRzNNO5g Nr94CIptF8qPs9yYS36ioJjiDkCOOCfp+uBMV+qq2z8MN840TJd3SJ/my7ZNu7yjbIZAxo eBvRDPIe21bHgabfrm449scfH470MWc= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 13/15] mptcp: get addr in userspace pm list Date: Mon, 18 Dec 2023 17:23:42 +0800 Message-Id: <836d60383d7989a23b0252a9d2f81f0cb36591b3.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" If a token is gotten in mptcp_pm_nl_get_addr_doit(), that means a userspace PM is used. Invoke mptcp_userspace_pm_get_addr() to get addr in userspace PM list. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ebc9841224a7..cd99c0e5281f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1715,14 +1715,20 @@ int mptcp_pm_nl_put_entry_msg(struct sk_buff *msg, int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; + struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; + struct net *net =3D sock_net(skb->sk); int ret; =20 ret =3D mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; =20 + if (token) + return mptcp_userspace_pm_get_addr(net, info, nla_get_u32(token), + addr.addr.id); + spin_lock_bh(&pernet->lock); entry =3D __lookup_addr_by_id(pernet, addr.addr.id); if (!entry) { --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 B4F2B11CB9 for ; Mon, 18 Dec 2023 09:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PeFJr2ph" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9YLvVFOoCNrJSE4AAms04hq4jtYeWYnHs4+hrwO8rGs=; b=PeFJr2phKYa7oE2aH56b6ofDtQlAJT9u0dSZrHU22OSo8nk9h+HR5bnDhIG/3aljD9uDZZ DXRPJ+A1hQBjOqrMKecZXeIKt2SofD/zfJkBWB2PGr3Zibu+ZkMH+yZHA/iv3HC1nDIkEt wZznmSEy0JSEjbnZIFOADykhGjOtZ1U= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 14/15] selftests: mptcp: add token for get_addr Date: Mon, 18 Dec 2023 17:23:43 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The command get_addr() of pm_nl_ctl can be used like this in in-kernel PM: pm_nl_ctl get $id This patch adds token argument for it to support userspace PM: pm_nl_ctl get $id token $token If 'token $token' is passed to get_addr(), copy it into the kernel netlink. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/= selftests/net/mptcp/pm_nl_ctl.c index 8d7d1b4ed28e..7426a2cbd4a0 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -1087,6 +1087,7 @@ int get_addr(int fd, int pm_family, int argc, char *a= rgv[]) 1024]; struct rtattr *rta, *nest; struct nlmsghdr *nh; + u_int32_t token =3D 0; int nest_start; u_int8_t id; int off =3D 0; @@ -1097,10 +1098,12 @@ int get_addr(int fd, int pm_family, int argc, char = *argv[]) MPTCP_PM_VER); =20 /* the only argument is the address id */ - if (argc !=3D 3) + if (argc !=3D 3 && argc !=3D 5) syntax(argv); =20 id =3D atoi(argv[2]); + if (argc =3D=3D 5 && !strcmp(argv[3], "token")) + token =3D strtoul(argv[4], NULL, 10); =20 nest_start =3D off; nest =3D (void *)(data + off); @@ -1116,6 +1119,15 @@ int get_addr(int fd, int pm_family, int argc, char *= argv[]) off +=3D NLMSG_ALIGN(rta->rta_len); nest->rta_len =3D off - nest_start; =20 + /* token */ + if (token) { + rta =3D (void *)(data + off); + rta->rta_type =3D MPTCP_PM_ATTR_TOKEN; + rta->rta_len =3D RTA_LENGTH(4); + memcpy(RTA_DATA(rta), &token, 4); + off +=3D NLMSG_ALIGN(rta->rta_len); + } + print_addrs(nh, pm_family, do_nl_req(fd, nh, off, sizeof(data))); return 0; } --=20 2.35.3 From nobody Thu Oct 31 23:57:45 2024 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 C252211CA6 for ; Mon, 18 Dec 2023 09:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ljn7QlL4" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702891533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hdzLm6bVu2drPN48mINIesrGgiK0TBHVz/DyGjVUDz0=; b=ljn7QlL42ef7YMZLMtZb6RrLhE2Wh4/bkHk8aF3HpLa8EEsTgfU9BpUQZlE59yAESV6+Mx xph14B1ycMzIYsuCkQjdGl6ZXYjM2gigi3c2EUliWP2MF2MjXfbeNdE7cLDs6vIVNCsvxq l2B7LirLbVwTwGn75UVIUmkdNF0EOKg= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 15/15] selftests: mptcp: userspace pm get addr tests Date: Mon, 18 Dec 2023 17:23:44 +0800 Message-Id: <7eaf5f34e18dd3349683d4b65d9957ff776df28d.1702891194.git.geliang.tang@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch adds a new helper userspace_pm_get_addr() in mptcp_join.sh. In it, parse the token value from the output of 'pm_nl_ctl events', then pass it to pm_nl_ctl get_addr command. Use this helper in userspace pm dump tests. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 403200394aa7..e603baa1d4a8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3372,6 +3372,18 @@ userspace_pm_dump() ip netns exec $1 ./pm_nl_ctl dump token $tk } =20 +# $1: ns ; $2: id +userspace_pm_get_addr() +{ + local evts=3D$evts_ns1 + local tk + + [ "$1" =3D=3D "$ns2" ] && evts=3D$evts_ns2 + tk=3D$(mptcp_lib_evts_get_info token "$evts") + + ip netns exec $1 ./pm_nl_ctl get $2 token $tk +} + check_output() { local cmd=3D"$1" @@ -3602,6 +3614,8 @@ userspace_tests() chk_subflows_total 2 2 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 local dump=3D"id 10 flags signal 10.0.2.1" + check_output "userspace_pm_get_addr $ns1 10" \ + "$dump" " get id 10 addr" check_output "userspace_pm_dump $ns1" \ "$dump" " dump addrs signal" kill_events_pids @@ -3624,6 +3638,8 @@ userspace_tests() chk_mptcp_info subflows 1 subflows 1 chk_subflows_total 2 2 local dump=3D"id 20 flags subflow 10.0.3.2" + check_output "userspace_pm_get_addr $ns2 20" \ + "$dump" " get id 20 addr" check_output "userspace_pm_dump $ns2" \ "$dump" " dump addrs subflow" kill_events_pids --=20 2.35.3