Skip to content

Commit 84c531f

Browse files
geliangtangkuba-moo
authored andcommitted
mptcp: userspace pm send RM_ADDR for ID 0
This patch adds the ability to send RM_ADDR for local ID 0. Check whether id 0 address is removed, if not, put id 0 into a removing list, pass it to mptcp_pm_remove_addr() to remove id 0 address. There is no reason not to allow the userspace to remove the initial address (ID 0). This special case was not taken into account not letting the userspace to delete all addresses as announced. Closes: multipath-tcp/mptcp_net-next#379 Reviewed-by: Matthieu Baerts <matttbe@kernel.org> Signed-off-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Mat Martineau <martineau@kernel.org> Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-3-db8f25f798eb@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9168ea0 commit 84c531f

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

net/mptcp/pm_userspace.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,40 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
208208
return err;
209209
}
210210

211+
static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,
212+
struct genl_info *info)
213+
{
214+
struct mptcp_rm_list list = { .nr = 0 };
215+
struct mptcp_subflow_context *subflow;
216+
struct sock *sk = (struct sock *)msk;
217+
bool has_id_0 = false;
218+
int err = -EINVAL;
219+
220+
lock_sock(sk);
221+
mptcp_for_each_subflow(msk, subflow) {
222+
if (subflow->local_id == 0) {
223+
has_id_0 = true;
224+
break;
225+
}
226+
}
227+
if (!has_id_0) {
228+
GENL_SET_ERR_MSG(info, "address with id 0 not found");
229+
goto remove_err;
230+
}
231+
232+
list.ids[list.nr++] = 0;
233+
234+
spin_lock_bh(&msk->pm.lock);
235+
mptcp_pm_remove_addr(msk, &list);
236+
spin_unlock_bh(&msk->pm.lock);
237+
238+
err = 0;
239+
240+
remove_err:
241+
release_sock(sk);
242+
return err;
243+
}
244+
211245
int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
212246
{
213247
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
@@ -239,6 +273,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
239273
goto remove_err;
240274
}
241275

276+
if (id_val == 0) {
277+
err = mptcp_userspace_pm_remove_id_zero_address(msk, info);
278+
goto remove_err;
279+
}
280+
242281
lock_sock((struct sock *)msk);
243282

244283
list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {

0 commit comments

Comments
 (0)