Skip to contentSkip to conversation

fixes for userspace pm

PATCH In review Geliang Tang 3 participants 6 messages Nov 6, 2024

Subsystems (2)
lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

v2 cover fixes for userspace pm

From: Geliang Tang <[email protected]>

v2:
- move "add lookup_addr for userspace pm" out of this set.

Two fixes for userspace pm extract from "BPF path manager" series.

Geliang Tang (2):
mptcp: update local address flags when setting it
mptcp: hold pm lock when deleting entry

 net/mptcp/pm_userspace.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Signature · 1 line
2.45.2
author reviewer
#1 lore raw

PATCH v2 1/2 mptcp: update local address flags when setting it

From: Geliang Tang <[email protected]>

Just like in-kernel pm, when userspace pm does set_flags, it needs to send out MP_PRIO signal, and also modify the flags of the corresponding address entry in the local address list. This patch implements the missing logic.

Traverse all address entries on userspace_pm_local_addr_list to find the local address entry, if bkup is true, set the flags of this entry with FLAG_BACKUP, otherwise, clear FLAG_BACKUP.

Fixes 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace PMs")
---
 net/mptcp/pm_userspace.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
net/mptcp/pm_userspace.c +12 -0
index 56dfea9862b7..3f888bfe1462 100644
@@ -560,6 +560,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
 	struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
 	struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
 	struct net *net = sock_net(skb->sk);
+	struct mptcp_pm_addr_entry *entry;
 	struct mptcp_sock *msk;
 	int ret = -EINVAL;
 	struct sock *sk;
@@ -601,6 +602,17 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
 	if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP)
 		bkup = 1;
 
+	spin_lock_bh(&msk->pm.lock);
+	list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
+		if (mptcp_addresses_equal(&entry->addr, &loc.addr, false)) {
+			if (bkup)
+				entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
+			else
+				entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP;
+		}
+	}
+	spin_unlock_bh(&msk->pm.lock);
+
 	lock_sock(sk);
 	ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup);
 	release_sock(sk);
Signature · 1 line
2.45.2
author reviewer
#2 lore raw

PATCH v2 2/2 mptcp: hold pm lock when deleting entry

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

When traversing userspace_pm_local_addr_list and deleting an entry from it in mptcp_pm_nl_remove_doit(), msk->pm.lock should be held.

This patch holds this lock before mptcp_userspace_pm_lookup_addr_by_id() and releases it after list_move() in mptcp_pm_nl_remove_doit().

Fixes d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
---
 net/mptcp/pm_userspace.c | 3 +++
 1 file changed, 3 insertions(+)
net/mptcp/pm_userspace.c +3 -0
index 3f888bfe1462..e35178f5205f 100644
@@ -308,14 +308,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
 
 	lock_sock(sk);
 
+	spin_lock_bh(&msk->pm.lock);
 	match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val);
 	if (!match) {
 		GENL_SET_ERR_MSG(info, "address with specified id not found");
+		spin_unlock_bh(&msk->pm.lock);
 		release_sock(sk);
 		goto out;
 	}
 
 	list_move(&match->list, &free_list);
+	spin_unlock_bh(&msk->pm.lock);
 
 	mptcp_pm_remove_addrs(msk, &free_list);
 
Signature · 1 line
2.45.2
#3 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Unstable: 1 failed test(s): packetdrill_regressions 🔴
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/11696918672

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/63b85be8ec5d
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=906742

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

maintainer
#5 lore raw
In reply to Geliang Tang

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

v2:
- move "add lookup_addr for userspace pm" out of this set.

Two fixes for userspace pm extract from "BPF path manager" series.

Thank you for the patches!

Now in our tree:

New patches for t/upstream-net and t/upstream:
- 4cc0bb30ea08: mptcp: update local address flags when setting it
- f084b1c81ee0: mptcp: hold pm lock when deleting entry
- Results: a54ff4f9af98..36fd4e465722 (export-net)
- Results: 370ec37a4049..ca26062fcd85 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/1243f63870234a0da9483ac30bf8e5ac56f5363e/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/d632a6992fcb583953f094dc46a417cf33e61303/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.