From nobody Sun Dec 22 05:58:22 2024 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.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 AE9B6EDE for ; Sat, 30 Dec 2023 02:49:19 +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="X0D+RAte" 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=1703904556; 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=sT9yoo76F04uE3bDGChHpZ0QRIuxr7g9fKUWxi0v/LY=; b=X0D+RAteb0Z/kmN9SoS4OpQbTwLIbsCWIDMb5nHv0oh/pWd6cT1osRoXSHPrg+wgRvjgvH RC/kCurzTgZja+mw44LKFRmGAH6iOpCAASp0Ofqc3kcOlNUT5B4APtqXmp8rz/QKxxqYEI BYIxDXRqwVpRWjtc6HTZ8Os/9SHTI2A= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 01/24] mptcp: set set_id flag when parsing addr Date: Sat, 30 Dec 2023 10:47:56 +0800 Message-Id: <8f402f2cbd7571e85fbc41b9559cbb2d05bf7c58.1703904325.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" When userspace PM requires to create an ID 0 subflow in "userspace pm create id 0 subflow" test like this: userspace_pm_add_sf $ns2 10.0.3.2 0 An ID 1 subflow, in fact, is created. Since in mptcp_pm_nl_append_new_local_addr(), 'id 0' will be treated as no ID is set by userspace, and will allocate a new ID immediately: if (!e->addr.id) e->addr.id =3D find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 1); To solve this issue, a new flag 'MPTCP_PM_ADDR_FLAG_SET_ID' is added to distinguish between whether userspace PM has set an ID 0 or whether userspace PM has not set any address. Add a new parameter 'set_id' for mptcp_pm_parse_pm_addr_attr(), and pass a 'set_id' flag to them. If an address id is set from userspace, this 'set_id' will be set as true. If 'set_id' is set, then the newly added flag MPTCP_PM_ADDR_FLAG_SET_ID will be set. Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow") Signed-off-by: Geliang Tang --- include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 74cfe496891e..ef3663792765 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -36,6 +36,7 @@ #define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) #define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) #define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4) +#define MPTCP_PM_ADDR_FLAG_SET_ID (1 << 5) =20 struct mptcp_info { __u8 mptcpi_subflows; diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 661c226dad18..dedc5a038b10 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1159,7 +1159,8 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr = *tb[], const struct nlattr *attr, struct genl_info *info, struct mptcp_addr_info *addr, - bool require_family) + bool require_family, + bool *set_id) { int err, addr_addr; =20 @@ -1174,8 +1175,11 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr= *tb[], if (err) return err; =20 - if (tb[MPTCP_PM_ADDR_ATTR_ID]) + if (tb[MPTCP_PM_ADDR_ATTR_ID]) { addr->id =3D nla_get_u8(tb[MPTCP_PM_ADDR_ATTR_ID]); + if (set_id) + *set_id =3D true; + } =20 if (!tb[MPTCP_PM_ADDR_ATTR_FAMILY]) { if (!require_family) @@ -1223,7 +1227,7 @@ int mptcp_pm_parse_addr(struct nlattr *attr, struct g= enl_info *info, =20 memset(addr, 0, sizeof(*addr)); =20 - return mptcp_pm_parse_pm_addr_attr(tb, attr, info, addr, true); + return mptcp_pm_parse_pm_addr_attr(tb, attr, info, addr, true, NULL); } =20 int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info, @@ -1231,11 +1235,13 @@ int mptcp_pm_parse_entry(struct nlattr *attr, struc= t genl_info *info, struct mptcp_pm_addr_entry *entry) { struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1]; + bool set_id =3D false; int err; =20 memset(entry, 0, sizeof(*entry)); =20 - err =3D mptcp_pm_parse_pm_addr_attr(tb, attr, info, &entry->addr, require= _family); + err =3D mptcp_pm_parse_pm_addr_attr(tb, attr, info, &entry->addr, + require_family, &set_id); if (err) return err; =20 @@ -1248,6 +1254,9 @@ int mptcp_pm_parse_entry(struct nlattr *attr, struct = genl_info *info, if (tb[MPTCP_PM_ADDR_ATTR_FLAGS]) entry->flags =3D nla_get_u32(tb[MPTCP_PM_ADDR_ATTR_FLAGS]); =20 + if (set_id) + entry->flags |=3D MPTCP_PM_ADDR_FLAG_SET_ID; + if (tb[MPTCP_PM_ADDR_ATTR_PORT]) entry->addr.port =3D htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT])); =20 --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (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 9BE5B10EB for ; Sat, 30 Dec 2023 02:49: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="JLQJjO7e" 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=1703904557; 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=j475N8n3KfItrXX9HiKSyEPF7XizFnjVYbaNgHfUy+4=; b=JLQJjO7erbosz/ZUi7NnmxkGcmZByxJgIgbaE/rH5ZX8Gjqy7DdFMHKAOPNuWQH6gOCGiS CVGMaY52aKD1CE3AHH77eaToURrsGivO2kOp/WEdDw/n5uiVCdzws3BQdjs7TFLWNCrWQN caPwgPkwu9WtpiGs85hcR5jalif2DfA= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 02/24] mptcp: parse userspace pm entry to get flags Date: Sat, 30 Dec 2023 10:47:57 +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 uses mptcp_pm_parse_entry() to parse the local entry to get the flags of this entry, instead of using mptcp_pm_parse_addr() to parse the addr_l address when creating a subflow in userspace PM. Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow") Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index efecbe3cf415..8134dbdc7005 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -348,11 +348,12 @@ 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; } + addr_l =3D local.addr; =20 err =3D mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { @@ -366,7 +367,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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.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 8B75A10E9 for ; Sat, 30 Dec 2023 02:49: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="rwQP/sUu" 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=1703904558; 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=fhFcg1lf0oz36e4EdnbO4QVX48RSgjKf8OPDSUsbLAc=; b=rwQP/sUuuh+cWEVDAKAAss7bsxDN7D40rlRs3WCLmiXE5+iaGfOir2lDq2vkXDW0JAj2wt A8t8v1JEjn06CQJkpHHgSoPWga+adjZu5DgpyFlnVru+zmb/N6kZSWb/BfPhnuezFZVFPz CSlb7Tazw73Y+LxKDbYTAr/LWRt8gjg= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 03/24] mptcp: test set_id flag when appending addr Date: Sat, 30 Dec 2023 10:47:58 +0800 Message-Id: <28d19e02971710fa95575e944808fa6c9970bd1f.1703904325.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 tests MPTCP_PM_ADDR_FLAG_SET_ID flag when appending a new address in mptcp_pm_nl_append_new_local_addr() in pm_netlink.c and in mptcp_userspace_pm_append_new_local_addr() in pm_userspace.c. If this flag is set, do not alloc new address ID from id_bitmap, just keep the userspace set address ID. Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow") Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 7 +++++-- net/mptcp/pm_userspace.c | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index dedc5a038b10..8a311b497603 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -949,7 +949,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_= nl_pernet *pernet, } } =20 - if (!entry->addr.id) { + if (!entry->addr.id && !(entry->flags & MPTCP_PM_ADDR_FLAG_SET_ID)) { find_next: entry->addr.id =3D find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, @@ -960,9 +960,12 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm= _nl_pernet *pernet, } } =20 - if (!entry->addr.id) + if (!entry->addr.id && !(entry->flags & MPTCP_PM_ADDR_FLAG_SET_ID)) goto out; =20 + if (entry->flags & MPTCP_PM_ADDR_FLAG_SET_ID) + entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_SET_ID; + __set_bit(entry->addr.id, pernet->id_bitmap); if (entry->addr.id > pernet->next_id) pernet->next_id =3D entry->addr.id; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 8134dbdc7005..ce8ae7aa5aad 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -41,8 +41,11 @@ static int mptcp_userspace_pm_append_new_local_addr(stru= ct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { addr_match =3D mptcp_addresses_equal(&e->addr, &entry->addr, true); - if (addr_match && entry->addr.id =3D=3D 0) + if (addr_match && entry->addr.id =3D=3D 0 && + !(entry->flags & MPTCP_PM_ADDR_FLAG_SET_ID)) entry->addr.id =3D e->addr.id; + else if (entry->flags & MPTCP_PM_ADDR_FLAG_SET_ID) + entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_SET_ID; id_match =3D (e->addr.id =3D=3D entry->addr.id); if (addr_match && id_match) { match =3D e; @@ -64,10 +67,12 @@ static int mptcp_userspace_pm_append_new_local_addr(str= uct mptcp_sock *msk, } =20 *e =3D *entry; - if (!e->addr.id) + if (!e->addr.id && !(e->flags & MPTCP_PM_ADDR_FLAG_SET_ID)) e->addr.id =3D find_next_zero_bit(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 1); + else if (e->flags & MPTCP_PM_ADDR_FLAG_SET_ID) + e->flags &=3D ~MPTCP_PM_ADDR_FLAG_SET_ID; list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; ret =3D e->addr.id; --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.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 DE73110FF for ; Sat, 30 Dec 2023 02:49: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="kSzzlsKz" 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=1703904559; 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=Gtgoiwqxdm/klEwSghamsXVAd54NFxvjN2O4gUglT4c=; b=kSzzlsKzRuStogXwwhI7bMeEJVjgctEyA/DyGyLLheI1flhdae9lTnaErJ0BMpkPIzkIt4 Q5BvH6S2ICRMvuqKL8OjvR1o83C29YK4kLIt8IVmlJuaEw7qgtJINZCmz0QwtVr/IiFVzv /NLEG0Fyvbi87GQz9VHl5NHTxoRUAfw= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 04/24] mptcp: check addrs list in userspace_pm_get_local_id Date: Sat, 30 Dec 2023 10:47:59 +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" Before adding a new entry in mptcp_userspace_pm_get_local_id(), it's better to check whether this address is already in userspace pm local address list. If it's in the list, no need to add a new entry, just return it's address ID and use this address. Fixes: 8b20137012d9 ("mptcp: read attributes of addr entries managed by use= rspace PMs") Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau --- net/mptcp/pm_userspace.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index ce8ae7aa5aad..c592536b9889 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -135,10 +135,21 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(st= ruct mptcp_sock *msk, int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) { - struct mptcp_pm_addr_entry new_entry; + struct mptcp_pm_addr_entry *entry =3D NULL, *e, new_entry; __be16 msk_sport =3D ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; =20 + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { + if (mptcp_addresses_equal(&e->addr, skc, false)) { + entry =3D e; + break; + } + } + spin_unlock_bh(&msk->pm.lock); + if (entry) + return entry->addr.id; + memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); new_entry.addr =3D *skc; new_entry.addr.id =3D 0; --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.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 B034710F7 for ; Sat, 30 Dec 2023 02:49:23 +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="wG5EV7p6" 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=1703904561; 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=8wEloxO2vOuiuMPvXZ4ZhJE1zFc5IB7QZq4/N1e0jXM=; b=wG5EV7p6GnoP5zSLYXeESJesoJtjkWIqWD+uWipeCMqkXQiMIOFHDzS3lOfBX4IPlt4gTI 6L1uo8sY40glQe6JRSVIEBy6usH74xAID6jpidgSe+7r3PXvaMGLt2jV5VpDrTwLDypPU1 pXmOZguYtlfTkVysIViZNJ3+mF9S9K8= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 05/24] mptcp: map v4 address to v6 when destroying subflow Date: Sat, 30 Dec 2023 10:48:00 +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" In mptcp_pm_nl_subflow_destroy_doit(), before checking local address family with remote address family, map an IPv4 address to an IPv6 address if the pair is a v4-mapped address. Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establ= ishment") Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index c592536b9889..9df643373c39 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -499,6 +499,16 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *s= kb, struct genl_info *info goto destroy_err; } =20 +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + if (addr_l.family =3D=3D AF_INET && ipv6_addr_v4mapped(&addr_r.addr6)) { + ipv6_addr_set_v4mapped(addr_l.addr.s_addr, &addr_l.addr6); + addr_l.family =3D AF_INET6; + } + if (addr_r.family =3D=3D AF_INET && ipv6_addr_v4mapped(&addr_l.addr6)) { + ipv6_addr_set_v4mapped(addr_r.addr.s_addr, &addr_r.addr6); + addr_r.family =3D AF_INET6; + } +#endif if (addr_l.family !=3D addr_r.family) { GENL_SET_ERR_MSG(info, "address families do not match"); err =3D -EINVAL; --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) (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 D68751364 for ; Sat, 30 Dec 2023 02:49:23 +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="pvZdCuIS" 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=1703904562; 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=Y4R/pqJG2UmLc5vpvrVfzA6o8zMEKDkwsqLLvuh9Qcs=; b=pvZdCuISuOe4jgSPR958QiGnsZipR1r5QzNmif9koCh1T6fHb5Yup8sGFm/sQA5sl45wD0 HK6QPgZJXYCFEwZYNaaIdqC3awgMU1vvegPOcsCaCPl02HoqUJyQmasA1d5chErNj5orGY wwgd4YqpvP/fR8sGReqkcWEXxb6Z6sY= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 06/24] selftests: mptcp: rm subflow with v4/v4mapped addr Date: Sat, 30 Dec 2023 10:48:01 +0800 Message-Id: <7a78251539a8f39951087b337dc6ab809563c74e.1703904325.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" Now both a v4 address and a v4-mapped address are supported when destroying a userspace pm subflow, this patch adds random tests for both addresses. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 3a5b63026191..915ec79f5030 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3340,12 +3340,13 @@ userspace_pm_rm_sf() { local evts=3D$evts_ns1 local t=3D${3:-1} - local ip=3D4 + local ip local tk da dp sp local cnt =20 [ "$1" =3D=3D "$ns2" ] && evts=3D$evts_ns2 - if mptcp_lib_is_v6 $2; then ip=3D6; fi + [ -n "$(mptcp_lib_evts_get_info "saddr4" "$evts" $t)" ] && ip=3D4 + [ -n "$(mptcp_lib_evts_get_info "saddr6" "$evts" $t)" ] && ip=3D6 tk=3D$(mptcp_lib_evts_get_info token "$evts") da=3D$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t) dp=3D$(mptcp_lib_evts_get_info dport "$evts" $t) @@ -3448,7 +3449,11 @@ userspace_tests() chk_subflows_total 2 2 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 userspace_pm_rm_addr $ns1 10 - userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED + if [ $((RANDOM%2)) -eq 0 ]; then + userspace_pm_rm_sf $ns1 ::ffff:10.0.2.1 $SUB_ESTABLISHED + else + userspace_pm_rm_sf $ns1 10.0.2.1 $SUB_ESTABLISHED + fi chk_rm_nr 1 1 invert chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1 --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.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 EECC410FF for ; Sat, 30 Dec 2023 02:49: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="fse2/PwL" 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=1703904563; 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=UL2y88wdaVfD0h78UovmL8ymMx6E5PuCKxgLZns8MqU=; b=fse2/PwLGfixRs43BJ/QxFZi5dwdfo/wGNu5/g0Swe/91HIXBOUS7LJGW8X4lbDWroJd15 7VNlAUmoucQNQlx17X3VlYMWiK5/DqHsLB9c9xGyJy9Qd6SjNKnMM7+xXs0SsyVr47IoQM r56XFBcjigV2yDY2n2aHFOgFCz+EKXs= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 07/24] mptcp: export mptcp_genl_family & mptcp_nl_fill_addr Date: Sat, 30 Dec 2023 10:48:02 +0800 Message-Id: <7aefa9112cfecd19a39bd597613aaa3341d20e2e.1703904325.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 exports struct mptcp_genl_family and mptcp_nl_fill_addr() helper to allow them can be used in pm_userspace.c. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 9 +++------ net/mptcp/protocol.h | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 8a311b497603..b777561eeaa0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -18,9 +18,6 @@ #include "protocol.h" #include "mib.h" =20 -/* forward declaration */ -static struct genl_family mptcp_genl_family; - static int pm_nl_pernet_id; =20 struct mptcp_pm_add_entry { @@ -1631,8 +1628,8 @@ int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb,= struct genl_info *info) return 0; } =20 -static int mptcp_nl_fill_addr(struct sk_buff *skb, - struct mptcp_pm_addr_entry *entry) +int mptcp_nl_fill_addr(struct sk_buff *skb, + struct mptcp_pm_addr_entry *entry) { struct mptcp_addr_info *addr =3D &entry->addr; struct nlattr *attr; @@ -2276,7 +2273,7 @@ void mptcp_event(enum mptcp_event_type type, const st= ruct mptcp_sock *msk, nlmsg_free(skb); } =20 -static struct genl_family mptcp_genl_family __ro_after_init =3D { +struct genl_family mptcp_genl_family __ro_after_init =3D { .name =3D MPTCP_PM_NAME, .version =3D MPTCP_PM_VER, .netnsok =3D true, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f7b9c1b995df..9b0b3fa65ae5 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -341,6 +341,8 @@ struct mptcp_sock { #define mptcp_for_each_subflow_safe(__msk, __subflow, __tmp) \ list_for_each_entry_safe(__subflow, __tmp, &((__msk)->conn_list), node) =20 +extern struct genl_family mptcp_genl_family; + static inline void msk_owned_by_me(const struct mptcp_sock *msk) { sock_owned_by_me((const struct sock *)msk); @@ -961,6 +963,8 @@ void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *m= sk, struct mptcp_subflow_ const struct mptcp_options_received *mp_opt); void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context= *subflow, struct request_sock *req); +int mptcp_nl_fill_addr(struct sk_buff *skb, + struct mptcp_pm_addr_entry *entry); =20 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.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 D151210F7 for ; Sat, 30 Dec 2023 02:49:25 +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="SPGo1jKr" 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=1703904564; 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=FgTdm/XOz2Rrnitnhkt+8EUYXC6bzTHAf5eOQaZ3tzw=; b=SPGo1jKrRnsNJ7VlaPLhQNz+duvACzpgqXmltxQmuLhqWjfz6hy7kMDT1Et36GGeVL2BJe cXFeZYx9kQtJhIHyhETTpa/PbVE0RPB2+yE3sNkr8yiZU2nyrgueoRAk8GXSBDe03Ote0U SOrlVIOpnux77bMGE4kmOfcnugURVNY= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 08/24] mptcp: implement mptcp_userspace_pm_dump_addr Date: Sat, 30 Dec 2023 10:48:03 +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_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 | 58 ++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 2 ++ 2 files changed, 60 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 9df643373c39..98237108ddcf 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -576,3 +576,61 @@ 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) +{ + struct id_bitmap { + DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); + } *bitmap; + 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; + struct nlattr *token; + int ret =3D -EINVAL; + struct sock *sk; + void *hdr; + + bitmap =3D (struct id_bitmap *)cb->ctx; + token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; + + msk =3D mptcp_token_get_sock(net, nla_get_u32(token)); + if (!msk) { + NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token"); + return ret; + } + + if (!mptcp_pm_is_userspace(msk)) { + GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); + return ret; + } + + 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 (test_bit(entry->addr.id, bitmap->map)) + continue; + + 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); + break; + } + + __set_bit(entry->addr.id, bitmap->map); + genlmsg_end(msg, hdr); + } + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + + *((struct id_bitmap *)cb->ctx) =3D *bitmap; + return msg->len; +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 9b0b3fa65ae5..7c0d592a9a45 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1029,6 +1029,8 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, = unsigned int remaining, 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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 53C66138C for ; Sat, 30 Dec 2023 02:49: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="vGUWqHIv" 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=1703904565; 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=bcqlf4ZgGM6kEYWHYSK/3lt0xXX3xSvw2Ja+nCwyoVU=; b=vGUWqHIvg9lFUnGt01DEk1JiVt49n0s+eRwOO6tl+1omCKPNsEdnijQ2g9xb4dvpe2xSAa BNCgxMlZixrnrUVUe0ZRCMpu89jPJK/xV4ml2b+6scF0SzS2K6B1vnlwZ+JvfJV10TKVAW aAA2XrUXOUg8QOZNUFOXJzQ8L/sQDKg= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 09/24] mptcp: add token for get-addr in yaml Date: Sat, 30 Dec 2023 10:48:04 +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_pm.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_pm.yaml --source \ -o net/mptcp/mptcp_pm_gen.c ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec Documentation/netlink/specs/mptcp_pm.yaml --header \ -o net/mptcp/mptcp_pm_gen.h Signed-off-by: Geliang Tang --- Documentation/netlink/specs/mptcp_pm.yaml | 3 ++- net/mptcp/mptcp_pm_gen.c | 7 ++++--- net/mptcp/mptcp_pm_gen.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/netlink/specs/mptcp_pm.yaml b/Documentation/netl= ink/specs/mptcp_pm.yaml index 49f90cfb4698..af525ed29792 100644 --- a/Documentation/netlink/specs/mptcp_pm.yaml +++ b/Documentation/netlink/specs/mptcp_pm.yaml @@ -292,13 +292,14 @@ 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 diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c index 670da7822e6c..c30a2a90a192 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 ac9fc7225b6a..e24258f6f819 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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) (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 47F3D10F5 for ; Sat, 30 Dec 2023 02:49: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="rwVxNl8x" 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=1703904566; 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=ngi46ZjU+8e1bL6bIkm2qigwKMygN+U59Gu9a3yP2qE=; b=rwVxNl8x3wMYCnplPQggjdOtIwwop0onbEg1HUEnRRFLb8j/eBeRtg9DjvkD02XFczKa/o J8mMh+NkboY3qX0yhT9/uxOQXwYdWLTqEZ2hwOwtAVjKvFg/bV0lRNoxnBRzGiT+Pfx4kQ yKRgK+YemcXB5c0A3YSX59XQzUYzky4= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 10/24] mptcp: dump addrs in userspace pm list Date: Sat, 30 Dec 2023 10:48:05 +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 renames mptcp_pm_nl_get_addr_dumpit() as a dedicated in-kernel netlink PM dump addrs function mptcp_pm_nl_dump_addr(), and invoke a newly added wrapper mptcp_pm_dump_addr() in mptcp_pm_nl_get_addr_dumpit(). Invoke in-kernel PM dump addrs function mptcp_pm_nl_dump_addr() or userspace PM dump addrs function mptcp_userspace_pm_dump_addr() based on whether the token parameter is passed in or not in the wrapper. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 10 ++++++++++ net/mptcp/pm_netlink.c | 10 ++++++++-- net/mptcp/protocol.h | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 4ae19113b8eb..a251487d3315 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -441,6 +441,16 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_= sock *msk, unsigned int id return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); } =20 +int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) +{ + const struct genl_info *info =3D genl_info_dump(cb); + + if (info->attrs[MPTCP_PM_ATTR_TOKEN]) + return mptcp_userspace_pm_dump_addr(msg, cb); + + return mptcp_pm_nl_dump_addr(msg, cb); +} + int mptcp_pm_set_flags(struct net *net, struct nlattr *token, struct mptcp_pm_addr_entry *loc, struct mptcp_pm_addr_entry *rem, u8 bkup) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index b777561eeaa0..0a9826be3593 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1717,8 +1717,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) +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; @@ -1760,6 +1760,12 @@ 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_dump_addr(msg, cb); +} + static int parse_limit(struct genl_info *info, int id, unsigned int *limit) { struct nlattr *attr =3D info->attrs[id]; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 7c0d592a9a45..d52124490f8b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1029,6 +1029,9 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, = unsigned int remaining, 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_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); +int mptcp_pm_nl_dump_addr(struct sk_buff *msg, + struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); =20 --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.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 283B6EA8 for ; Sat, 30 Dec 2023 02:49: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="TAuDowTN" 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=1703904567; 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=Zp71Y18YzNEQJyWF7DHB8p9je0w3P5vKcVX2AdEfyDo=; b=TAuDowTNnKsHNhFbU6+knNtun5RQvI7bglRznDMi0ZLFXB7yjZLDn4BbKwWJGh1x00OKf4 ISVdUY6Zrf7b6Ku7MVuwo9Uxget16wdEi8/RPLyzDI6lAAIf+61/kEkTsvGqxOJ9hEXjFn Ltd0soH18AnX4LGTW1IxflQ9+ccmfgI= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 11/24] mptcp: check userspace pm subflow flag Date: Sat, 30 Dec 2023 10:48:06 +0800 Message-Id: <264d927f841e3ce0f3258e6cc9c78de167e08e81.1703904325.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 checks MPTCP_PM_ADDR_FLAG_SUBFLOW flag when creating a subflow by userspace PM in mptcp_pm_nl_subflow_create_doit(). If it's not set, don't create the subflow. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 98237108ddcf..b9f5dfe922f9 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -371,6 +371,12 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *sk= b, struct genl_info *info) } addr_l =3D local.addr; =20 + if (!(local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) { + GENL_SET_ERR_MSG(info, "invalid addr flags"); + err =3D -EINVAL; + goto create_err; + } + 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"); --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.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 4781C10EB for ; Sat, 30 Dec 2023 02:49: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="vTJhPc6F" 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=1703904568; 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=OjMgqGa5MiMIJYBmhvr9i3URbzHKk+MypOKb7FAFaEY=; b=vTJhPc6F//7FDV24Krrkn6vlko4yM+d2gJsIpgajoJstIzPQHEmmiSGJE88dIsB2FRpuNo VtjP3v+rWt+L7f1T71cGDHCVfwRh7ppjCHtX4G5RdKBQ6LfmjD/JY2ikuvC3VeTzvbJAWe nqOGYj6GnJkFAr9WiX6bTtoxO4TvzHQ= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 12/24] selftests: mptcp: add userspace pm subflow flag Date: Sat, 30 Dec 2023 10:48:07 +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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (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 6D300EDC for ; Sat, 30 Dec 2023 02:49:31 +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="xOxme25O" 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=1703904569; 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=elnfC3kiUln0kUdIoW4sMFNmDfg5c0tbwFo3j5pB284=; b=xOxme25O1HxWuFm9IsaLXZTr9fKRUJQOnYpesuFvi6pT0cvZKHW5fSi7twy/X8ni9vL7he 4ntm8WNlOoyP3lcpf3fcDi515nXqF6W48EUN6xPztMVwNvjLbk3mSKKhW/SwZa21j+UCa1 0MnKw5bl7eb8IvLDbsSfIbdOhQrPOd0= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 13/24] selftests: mptcp: add token for dump_addr Date: Sat, 30 Dec 2023 10:48:08 +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 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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.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 76A0F10E9 for ; Sat, 30 Dec 2023 02:49: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="N+ImToSD" 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=1703904570; 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=TfRFxdx4Oij2Lgz7VstVO9Awq0ps6fIXas5s/JPAWn0=; b=N+ImToSDUXLZ8v5DsB2N4q2hsHnP7g7BSFQYgWZv+2n1+IRPDtVfEOxYJAy3jQpM9sFthm BXXsedpAxrblJtDBSfM1olmDlw1EudoC646Nn9ow/Fef8Qj3QSUQR0xsA7sWv6807rNQCB UPYsIjDXL+mJ+GdOW4WBubpPbCo2HAI= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 14/24] selftests: mptcp: add check_output helper Date: Sat, 30 Dec 2023 10:48:09 +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" 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 915ec79f5030..f4043baa59c6 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 @@ -3358,6 +3361,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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.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 A6632EA8 for ; Sat, 30 Dec 2023 02:49: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="xKzA4UO6" 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=1703904571; 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=IU2k4zQ15+YPk3PM7rccTLc+5h8Xe4ZxQDyLoKz/3z0=; b=xKzA4UO6JWQWs7YbzHi+lXEVSep/ZqEHF713YmYVT1oY4rgTy8Yo0BF70rXg1+52RFrnGR 3VOmETVNItXxxC+h+nl0lAWwqBwSB4PYCnNn4RIEsKp+L1VBq4Ovl1D+UhRwkhuEfT1Djs 55YsZh60TnXH3tF6t1EtDcJ4VspQ20M= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 15/24] selftests: mptcp: dump after creating id 0 subflow Date: Sat, 30 Dec 2023 10:48:10 +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. Use this helper to check whether an ID 0 subflow is listed in the output of dump command after creating an ID 0 subflow in "userspace pm create id 0 subflow" test. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index f4043baa59c6..a92fb5469621 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3361,6 +3361,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" @@ -3522,6 +3534,9 @@ userspace_tests() chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1 userspace_pm_add_sf $ns2 10.0.3.2 0 + check_output "userspace_pm_dump $ns2" \ + "id 0 flags subflow 10.0.3.2" \ + " dump addrs id 0 subflow" chk_join_nr 1 1 1 chk_mptcp_info subflows 1 subflows 1 chk_subflows_total 2 2 --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) (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 9CA3C10F5 for ; Sat, 30 Dec 2023 02:49: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="atamn2AM" 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=1703904573; 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=tVJ2Qjank7o+zY5F7QvISoAr2BpCFqSYg9+3eruw0ng=; b=atamn2AM00Kk5oDi80AS+pnokblOK8D+kLtz3P9LNR1+4Nfib1ECls2vvuD7PCqxj3PU4E FV1VR+TEOPqLKIJTb0IUIlldPTW0LsoCa4eZmKxAyC5s+7UkfythVDG2fdQ7sTpXfcba5F zCKTd2U7rXC/e1QN0wdEdbBmF5SNGTc= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 16/24] selftests: mptcp: dump userspace addrs list Date: Sat, 30 Dec 2023 10:48:11 +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 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 | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index a92fb5469621..cec4bfc5193b 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3593,6 +3593,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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 0F21EEDC for ; Sat, 30 Dec 2023 02:49:35 +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="Mn0ikQNh" 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=1703904574; 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=2S34Zt9JfY75Cq6XhyqKkBbGN6GEPRJaz2xqAgp7IXA=; b=Mn0ikQNhkCsSd6CfkZ2KFVCE2EVm8qh6F/laval6XA/2swEn/tVsDLUgSs01ivCLpPdHm3 qixsFfDuV5ecxMk6csnhndsnYAQtFodwcd0PR9bCQdgSgqoJm9Vy3naEjdT4MM4+jh5HFH ZH4I6XN6kNAXXHcJzOWaQLnh9myKKr0= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 17/24] mptcp: add userspace_pm_lookup_addr_by_id helper Date: Sat, 30 Dec 2023 10:48:12 +0800 Message-Id: <53462f6727b05268b0210696334a0817d3c2bfe8.1703904325.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 b9f5dfe922f9..6d514054fe15 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -110,19 +110,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; @@ -265,7 +272,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); @@ -302,13 +309,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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.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 92C2E10F7 for ; Sat, 30 Dec 2023 02:49:36 +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="Mzsv4KPj" 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=1703904575; 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=beVa6SDo8B0FuvaeGiUxMPc3/ZWdiLk/Niq8/zvlkCo=; b=Mzsv4KPjplXmvjTq5cAuN8MBj3lHYjXfa3z8Ew/QIMtwmqwIEejvTd8hLxJubQmot0emIQ CGQDQeJX2/MkRPvR8V6rqkIkfKMC3SmCrL4IOqz7XjQwMHE0Q1ZqkSsGjKBt1DmhCCMWo4 A9gIG2RDRRkC5vrf6OVueMRGkIGBmTA= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 18/24] mptcp: implement mptcp_userspace_pm_get_addr Date: Sat, 30 Dec 2023 10:48:13 +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 | 70 ++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 2 ++ 2 files changed, 72 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 6d514054fe15..4afcd5b589f0 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -641,3 +641,73 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, *((struct id_bitmap *)cb->ctx) =3D *bitmap; return msg->len; } + +int mptcp_userspace_pm_get_addr(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 mptcp_pm_addr_entry addr, *entry; + struct net *net =3D sock_net(skb->sk); + struct mptcp_sock *msk; + struct sk_buff *msg; + int ret =3D -EINVAL; + struct sock *sk; + void *reply; + + msk =3D mptcp_token_get_sock(net, nla_get_u32(token)); + if (!msk) { + NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token"); + return ret; + } + + if (!mptcp_pm_is_userspace(msk)) { + GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); + return ret; + } + + ret =3D mptcp_pm_parse_entry(attr, info, false, &addr); + if (ret < 0) + return 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; + } + + sk =3D (struct sock *)msk; + + lock_sock(sk); + spin_lock_bh(&msk->pm.lock); + entry =3D mptcp_userspace_pm_lookup_addr_by_id(msk, addr.addr.id); + if (!entry) { + GENL_SET_ERR_MSG(info, "address not found"); + ret =3D -EINVAL; + goto unlock_fail; + } + + ret =3D mptcp_nl_fill_addr(msg, entry); + if (ret) + goto unlock_fail; + + genlmsg_end(msg, reply); + ret =3D genlmsg_reply(msg, info); + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + return ret; + +unlock_fail: + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + +fail: + nlmsg_free(msg); + return ret; +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d52124490f8b..c560c310d7a6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1034,6 +1034,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); +int mptcp_userspace_pm_get_addr(struct sk_buff *skb, + struct genl_info *info); =20 void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.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 11653EDC for ; Sat, 30 Dec 2023 02:49:37 +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="ApIIERTw" 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=1703904576; 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=+Y3hR6uaX++P0llC8ADN+iL1rjjyN/eb2lJZcBcEAMQ=; b=ApIIERTw6AXuUFnMqneSx3/+HFLmyGvoj9Iy6lndH5Pqzu6PlSn/oJcURimkmydfNYMw/U 7tbmf6OKBza6ClCijxU/ib2UjyOcXKMQbrIe0Z0MzYAPZnKZ05nhtsfHEznAM3jzXb0A1F 4RpiWH8S3RW8iBPtEDT71NCnXRODYXE= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 19/24] mptcp: get addr in userspace pm list Date: Sat, 30 Dec 2023 10:48:14 +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 renames mptcp_pm_nl_get_addr_doit() as a dedicated in-kernel netlink PM get addr function mptcp_pm_nl_get_addr(). and invoke a new wrapper mptcp_pm_get_addr() in mptcp_pm_nl_get_addr_doit. If a token is gotten in the wrapper, that means a userspace PM is used. So invoke mptcp_userspace_pm_get_addr() to get addr in userspace PM list. Otherwise, invoke mptcp_pm_nl_get_addr(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 8 ++++++++ net/mptcp/pm_netlink.c | 7 ++++++- net/mptcp/protocol.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index a251487d3315..86cd65dd94df 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -441,6 +441,14 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_= sock *msk, unsigned int id return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); } =20 +int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) +{ + if (info->attrs[MPTCP_PM_ATTR_TOKEN]) + return mptcp_userspace_pm_get_addr(skb, info); + + return mptcp_pm_nl_get_addr(skb, info); +} + int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { const struct genl_info *info =3D genl_info_dump(cb); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 0a9826be3593..cbf5c8dcf167 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1667,7 +1667,7 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } =20 -int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr(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); @@ -1717,6 +1717,11 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, s= truct genl_info *info) return ret; } =20 +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) +{ + return mptcp_pm_get_addr(skb, info); +} + int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c560c310d7a6..f6f592971936 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1034,6 +1034,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); +int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info); int mptcp_userspace_pm_get_addr(struct sk_buff *skb, struct genl_info *info); =20 --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) (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 0458810E9 for ; Sat, 30 Dec 2023 02:49:38 +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="qV4vaxqg" 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=1703904577; 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=fqafRV8FgNEn/C7+5uIpfRh/2+IqQnYH8SF0WUD/Gd4=; b=qV4vaxqg5Z+A5gNvCpxYZDuASLkc0BICQn9o3IBT21Z9qwCIX2oF3FZdHZ4MT7zHFP3DZz TnGDmDy70r1Jyj5JG57Npr+9k67DCvhgJUOi7kvIZZSFsFb/C1FeE4HoHRURsGBBZuO4C8 L+7SXojbtIWUG0QPgCMelc1A+LCY1MA= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 20/24] selftests: mptcp: add token for get_addr Date: Sat, 30 Dec 2023 10:48:15 +0800 Message-Id: <778948dc657f43f9fa50045f12f35aa44d193107.1703904325.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 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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.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 1582410FF for ; Sat, 30 Dec 2023 02:49:39 +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="LOpmnQAn" 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=1703904578; 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=3nzZ8wKNp85moBzUTEOojjQzfk5kfKzJq/zvTsXTS2k=; b=LOpmnQAnoVTJDZej9NWefRYCYqfqS/naAPwQuuqhbSTHJhDkSvE5a4xYS6XkoPF81d9leh P6HJFH0t+dcrSuwMUNDVamaB0Y1giZkTRPQF8ngnDSunkLEHtp0Wz1OPWFxY5t+DOWjRUM HsPKnFO49+lozzRxyJnzs2mfMUNXW80= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 21/24] selftests: mptcp: userspace pm get addr tests Date: Sat, 30 Dec 2023 10:48:16 +0800 Message-Id: <512929c8007a7b66c658d3776afa8e09fb28b36e.1703904325.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 cec4bfc5193b..0b325b5efccf 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3373,6 +3373,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" @@ -3610,6 +3622,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 @@ -3632,6 +3646,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.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.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 EB899EC3 for ; Sat, 30 Dec 2023 02:49:40 +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="bLe8XXf7" 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=1703904579; 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=ALkIl0tBpFHD3jcqrh3HQpWOz+L1eqHaSKUY6KLhDbI=; b=bLe8XXf7e7U/xAIqa+wLADXrIM7oxIhMxf8mm4c+dH+momOEN9XUUbb9hAk126petL0b8M ceVFIVWhe3yGc/mAoDxIf1DwlDSwsW0dClUO012P+fJ/UMVyyzVlsvfn7PIbdTvBmqxf4z JIjiVrKSvVCWG1EPNV/kKitRaYtWrfo= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 22/24] mptcp: update set_flags interfaces Date: Sat, 30 Dec 2023 10:48:17 +0800 Message-Id: <1966089ebeea6a7b788edc4552ff22db35e4e376.1703904325.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 updates set_flags interfaces, make it more similar to the interfaces of dump_addr and get_addr: mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 11 ++++---- net/mptcp/pm_netlink.c | 58 +++++++++++++++++----------------------- net/mptcp/pm_userspace.c | 32 +++++++++++++++++----- net/mptcp/protocol.h | 10 +++---- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 86cd65dd94df..4ee742831918 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -459,13 +459,12 @@ int mptcp_pm_dump_addr(struct sk_buff *msg, struct ne= tlink_callback *cb) return mptcp_pm_nl_dump_addr(msg, cb); } =20 -int mptcp_pm_set_flags(struct net *net, struct nlattr *token, - struct mptcp_pm_addr_entry *loc, - struct mptcp_pm_addr_entry *rem, u8 bkup) +int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) { - if (token) - return mptcp_userspace_pm_set_flags(net, token, loc, rem, bkup); - return mptcp_pm_nl_set_flags(net, loc, bkup); + if (info->attrs[MPTCP_PM_ATTR_TOKEN]) + return mptcp_userspace_pm_set_flags(skb, info); + + return mptcp_pm_nl_set_flags(skb, info); } =20 void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock = *ssk) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index cbf5c8dcf167..a94e38e01631 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1885,66 +1885,58 @@ static int mptcp_nl_set_flags(struct net *net, return ret; } =20 -int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *add= r, u8 bkup) +int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) { - struct pm_nl_pernet *pernet =3D pm_nl_get_pernet(net); + struct mptcp_pm_addr_entry addr =3D { .addr =3D { .family =3D AF_UNSPEC }= , }; + struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; u8 changed, mask =3D MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; + struct net *net =3D sock_net(skb->sk); struct mptcp_pm_addr_entry *entry; + struct pm_nl_pernet *pernet; u8 lookup_by_id =3D 0; + u8 bkup =3D 0; + int ret; + + pernet =3D pm_nl_get_pernet(net); + + ret =3D mptcp_pm_parse_entry(attr, info, false, &addr); + if (ret < 0) + return ret; =20 - if (addr->addr.family =3D=3D AF_UNSPEC) { + if (addr.addr.family =3D=3D AF_UNSPEC) { lookup_by_id =3D 1; - if (!addr->addr.id) + if (!addr.addr.id) return -EOPNOTSUPP; } =20 + if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) + bkup =3D 1; + spin_lock_bh(&pernet->lock); - entry =3D __lookup_addr(pernet, &addr->addr, lookup_by_id); + entry =3D __lookup_addr(pernet, &addr.addr, lookup_by_id); if (!entry) { spin_unlock_bh(&pernet->lock); return -EINVAL; } - if ((addr->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && + if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); return -EINVAL; } =20 - changed =3D (addr->flags ^ entry->flags) & mask; - entry->flags =3D (entry->flags & ~mask) | (addr->flags & mask); - *addr =3D *entry; + changed =3D (addr.flags ^ entry->flags) & mask; + entry->flags =3D (entry->flags & ~mask) | (addr.flags & mask); + addr =3D *entry; spin_unlock_bh(&pernet->lock); =20 - mptcp_nl_set_flags(net, &addr->addr, bkup, changed); + mptcp_nl_set_flags(net, &addr.addr, bkup, changed); return 0; } =20 int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { - struct mptcp_pm_addr_entry remote =3D { .addr =3D { .family =3D AF_UNSPEC= }, }; - struct mptcp_pm_addr_entry addr =3D { .addr =3D { .family =3D AF_UNSPEC }= , }; - struct nlattr *attr_rem =3D info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; - struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; - struct net *net =3D sock_net(skb->sk); - u8 bkup =3D 0; - int ret; - - ret =3D mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - return ret; - - if (attr_rem) { - ret =3D mptcp_pm_parse_entry(attr_rem, info, false, &remote); - if (ret < 0) - return ret; - } - - if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) - bkup =3D 1; - - return mptcp_pm_set_flags(net, token, &addr, &remote, bkup); + return mptcp_pm_set_flags(skb, info); } =20 static void mptcp_nl_mcast_send(struct net *net, struct sk_buff *nlskb, gf= p_t gfp) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4afcd5b589f0..5a734fa25e8d 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -551,14 +551,19 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *= skb, struct genl_info *info return err; } =20 -int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token, - struct mptcp_pm_addr_entry *loc, - struct mptcp_pm_addr_entry *rem, u8 bkup) +int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *in= fo) { + struct mptcp_pm_addr_entry loc =3D { .addr =3D { .family =3D AF_UNSPEC },= }; + struct mptcp_pm_addr_entry rem =3D { .addr =3D { .family =3D AF_UNSPEC },= }; + struct nlattr *attr_rem =3D info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; + struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; + struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; + struct net *net =3D sock_net(skb->sk); struct mptcp_sock *msk; int ret =3D -EINVAL; struct sock *sk; u32 token_val; + u8 bkup =3D 0; =20 token_val =3D nla_get_u32(token); =20 @@ -571,12 +576,27 @@ int mptcp_userspace_pm_set_flags(struct net *net, str= uct nlattr *token, if (!mptcp_pm_is_userspace(msk)) goto set_flags_err; =20 - if (loc->addr.family =3D=3D AF_UNSPEC || - rem->addr.family =3D=3D AF_UNSPEC) + ret =3D mptcp_pm_parse_entry(attr, info, false, &loc); + if (ret < 0) + return ret; + + if (attr_rem) { + ret =3D mptcp_pm_parse_entry(attr_rem, info, false, &rem); + if (ret < 0) + return ret; + } + + if (loc.addr.family =3D=3D AF_UNSPEC || + rem.addr.family =3D=3D AF_UNSPEC) { + ret =3D -EINVAL; goto set_flags_err; + } + + if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP) + bkup =3D 1; =20 lock_sock(sk); - ret =3D mptcp_pm_nl_mp_prio_send_ack(msk, &loc->addr, &rem->addr, bkup); + ret =3D mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup); release_sock(sk); =20 set_flags_err: diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f6f592971936..89c2ff0f4b6b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -933,13 +933,9 @@ int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mpt= cp_sock *msk, unsigned int int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex); -int mptcp_pm_set_flags(struct net *net, struct nlattr *token, - struct mptcp_pm_addr_entry *loc, - struct mptcp_pm_addr_entry *rem, u8 bkup); -int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *add= r, u8 bkup); -int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token, - struct mptcp_pm_addr_entry *loc, - struct mptcp_pm_addr_entry *rem, u8 bkup); +int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info); +int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *in= fo); int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool echo); --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) (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 6D182EA8 for ; Sat, 30 Dec 2023 02:49:42 +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="B7QJj8C6" 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=1703904580; 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=i59hKRxb9raxsP0miossJSre0249qr+cHgBrRC814d0=; b=B7QJj8C6Rz0QpVomd4fU4nyR65gAcM5rhDroOShO+y9y1BO/wDtQIAiFs6G/irQb+m3YLl NRR8t6atxJv1v8GtVNyrUn/ZPa1MwnEuD6wBVIpR2Ea/kls95hJMaxB81GtJlQRkqRd303 UNKP+ot1LicYmVyap56RIBsmvxsHzmE= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 23/24] mptcp: set error messages for set_flags Date: Sat, 30 Dec 2023 10:48:18 +0800 Message-Id: <98296480a16748edf4ff313248bdb55724c683c2.1703904325.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" In addition to returning the error value, this patch also sets an error messages with GENL_SET_ERR_MSG or NL_SET_ERR_MSG_ATTR both for pm_netlink.c and pm_userspace.c. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 6 +++++- net/mptcp/pm_userspace.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a94e38e01631..5b7f08b9b0f0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1906,8 +1906,10 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struc= t genl_info *info) =20 if (addr.addr.family =3D=3D AF_UNSPEC) { lookup_by_id =3D 1; - if (!addr.addr.id) + if (!addr.addr.id) { + GENL_SET_ERR_MSG(info, "missing required inputs"); return -EOPNOTSUPP; + } } =20 if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) @@ -1917,11 +1919,13 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, stru= ct genl_info *info) entry =3D __lookup_addr(pernet, &addr.addr, lookup_by_id); if (!entry) { spin_unlock_bh(&pernet->lock); + GENL_SET_ERR_MSG(info, "address not found"); return -EINVAL; } if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); + GENL_SET_ERR_MSG(info, "invalid addr flags"); return -EINVAL; } =20 diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 5a734fa25e8d..b5aa272c83b4 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -568,13 +568,17 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb,= struct genl_info *info) token_val =3D nla_get_u32(token); =20 msk =3D mptcp_token_get_sock(net, token_val); - if (!msk) + if (!msk) { + NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token"); return ret; + } =20 sk =3D (struct sock *)msk; =20 - if (!mptcp_pm_is_userspace(msk)) + if (!mptcp_pm_is_userspace(msk)) { + GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); goto set_flags_err; + } =20 ret =3D mptcp_pm_parse_entry(attr, info, false, &loc); if (ret < 0) @@ -588,6 +592,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, s= truct genl_info *info) =20 if (loc.addr.family =3D=3D AF_UNSPEC || rem.addr.family =3D=3D AF_UNSPEC) { + GENL_SET_ERR_MSG(info, "address families do not match"); ret =3D -EINVAL; goto set_flags_err; } --=20 2.39.2 From nobody Sun Dec 22 05:58:22 2024 Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.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 86E2510EB for ; Sat, 30 Dec 2023 02:49:43 +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="WxtxL4qX" 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=1703904581; 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=fdqDizggJbRNEdgSBLTE06hoqwpzgVksNqm6OQ/Vkjk=; b=WxtxL4qXTWa/C81OFEEyMehUeow+OPAfztw7gKX+eNuhfMpmspGpqjbRp382Pwp4M+PS9v cV7n6gcnpUmpKUXDjJRPprZIPrmbXurnPftg2jZL8QCysD0q+3qvqaEWnaQNOhrYQ+euio YxG3L3nNtjAksr6TNfSlpMC3nQaVgB4= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 24/24] selftests: mptcp: flush userspace addrs list Date: Sat, 30 Dec 2023 10:48:19 +0800 Message-Id: <21d0da867665e8fc693b12e3cecd4610efced6e2.1703904325.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_flush() to flush all addresses for the userspace PM. Invoke it in userspace pm dump address and subflow tests. And use dump commands to check if the userspace pm local address list is empty after addresses flushing. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 0b325b5efccf..86101e2b8a92 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3409,6 +3409,31 @@ check_output() fi } =20 +# $1: ns ; $2: addr +userspace_pm_flush() +{ + local ns=3D$1 + local line + + userspace_pm_dump $ns | while read -r line; do + local arr=3D($line) + local nr=3D0 + local id + local addr + local i + for i in "${arr[@]}"; do + if [ $i =3D "id" ]; then + id=3D${arr[$nr+1]} + fi + nr=3D$((nr + 1)) + done + addr=3D${arr[$nr-1]} + [ $ip_mptcp -eq 1 ] && addr=3D${arr[0]} + userspace_pm_rm_addr $ns $id + userspace_pm_rm_sf $ns "$addr" $MPTCP_LIB_SUB_ESTABLISHED + done +} + userspace_tests() { # userspace pm type prevents add_addr @@ -3606,8 +3631,8 @@ userspace_tests() wait $tests_pid fi =20 - # userspace pm dump address - if reset_with_events "userspace pm dump address" && + # userspace pm dump & flush address + if reset_with_events "userspace pm dump & flush 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 @@ -3626,12 +3651,18 @@ userspace_tests() "$dump" " get id 10 addr" check_output "userspace_pm_dump $ns1" \ "$dump" " dump addrs signal" + userspace_pm_flush $ns1 + check_output "userspace_pm_dump $ns1" \ + "" " dump addrs after flush" + chk_rm_nr 1 1 invert + chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 kill_events_pids wait $tests_pid fi =20 - # userspace pm dump subflow - if reset_with_events "userspace pm dump subflow" && + # userspace pm dump & flush subflow + if reset_with_events "userspace pm dump & flush 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 @@ -3650,6 +3681,12 @@ userspace_tests() "$dump" " get id 20 addr" check_output "userspace_pm_dump $ns2" \ "$dump" " dump addrs subflow" + userspace_pm_flush $ns2 + check_output "userspace_pm_dump $ns2" \ + "" " dump addrs after flush" + chk_rm_nr 1 1 + chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 kill_events_pids wait $tests_pid fi --=20 2.39.2