Message ID | 72998c181b94560b3d1e1e5843250ee2815869ac.1730799589.git.tanggeliang@kylinos.cn (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | fixes for userspace pm | expand |
Context | Check | Description |
---|---|---|
matttbe/build | success | Build and static analysis OK |
matttbe/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 23 lines checked |
matttbe/shellcheck | success | MPTCP selftests files have not been modified |
matttbe/KVM_Validation__normal | success | Success! ✅ |
matttbe/KVM_Validation__debug | success | Success! ✅ |
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ | success | Success! ✅ |
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ | success | Success! ✅ |
Hi Geliang, On 05/11/2024 10:40, Geliang Tang wrote: > From: Geliang Tang <tanggeliang@kylinos.cn> > > 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. > > Use mptcp_userspace_pm_lookup_addr() helper to find the address entry on > userspace_pm_local_addr_list, if bkup is true, set the flags of the address > entry with FLAG_BACKUP, otherwise, clear FLAG_BACKUP. > > Fixes: 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace PMs") > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> > --- > net/mptcp/pm_userspace.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c > index 9c622b0e3e6e..0c0f6f65accb 100644 > --- a/net/mptcp/pm_userspace.c > +++ b/net/mptcp/pm_userspace.c > @@ -562,6 +562,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; > @@ -603,6 +604,16 @@ 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); > + entry = mptcp_userspace_pm_lookup_addr(msk, &loc.addr); (Linked to my comment from the previous patch) Adding only the helper, and squashing that in this patch here might be an option, but even that can cause conflicts. I think the simplest is not to add this small helper only used once for the moment: so simply calling list_for_each_entry() here, and add the following code inside it. WDYT? > + if (entry) { > + 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); Cheers, Matt
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 9c622b0e3e6e..0c0f6f65accb 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -562,6 +562,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; @@ -603,6 +604,16 @@ 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); + entry = mptcp_userspace_pm_lookup_addr(msk, &loc.addr); + if (entry) { + 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);