All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 4/5] mptcp: remove id 0 address
@ 2021-03-03 20:09 Mat Martineau
  0 siblings, 0 replies; only message in thread
From: Mat Martineau @ 2021-03-03 20:09 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 3101 bytes --]

On Wed, 3 Mar 2021, Geliang Tang wrote:

> This patch added a new function mptcp_nl_remove_id_zero_address to
> remove the id 0 address.
>
> In this function, fill the remove list with the id 0, and pass it to
> mptcp_pm_remove_addr and mptcp_pm_remove_subflow.
>
> Suggested-by: Paolo Abeni <pabeni(a)redhat.com>
> Suggested-by: Matthieu Baerts <matthieu.baerts(a)tessares.net>
> Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
> ---
> net/mptcp/pm_netlink.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 2bd61d55186b..6d04f5f77c61 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1164,6 +1164,33 @@ static void mptcp_pm_free_addr_entry(struct mptcp_pm_addr_entry *entry)
> 	}
> }
>
> +static int mptcp_nl_remove_id_zero_address(struct net *net)
> +{
> +	struct mptcp_sock *msk;
> +	long s_slot = 0, s_num = 0;
> +	struct mptcp_rm_list list = { .nr = 0 };
> +
> +	list.ids[list.nr++] = 0;
> +
> +	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
> +		struct sock *sk = (struct sock *)msk;
> +
> +		if (list_empty(&msk->conn_list))
> +			goto next;
> +
> +		lock_sock(sk);
> +		mptcp_pm_remove_addr(msk, &list);
> +		mptcp_pm_remove_subflow(msk, &list);
> +		release_sock(sk);
> +
> +next:
> +		sock_put(sk);
> +		cond_resched();
> +	}
> +
> +	return 0;
> +}
> +
> static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
> {
> 	struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
> @@ -1176,6 +1203,14 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
> 	if (ret < 0)
> 		return ret;
>
> +	/* the zero id address is special: the first address used by the msk
> +	 * always gets such an id, so different subflows can have different zero
> +	 * id addresses. Additionally zero id is not accounted for in id_bitmap.
> +	 * Let's use an 'mptcp_rm_list' instead of the common remove code.
> +	 */
> +	if (addr.addr.id == 0)
> +		return mptcp_nl_remove_id_zero_address(sock_net(skb->sk));
> +

For nonzero address IDs, we know that the ID maps to a single IP address 
for all MPTCP connections in the namespace.

For address ID == 0, different MPTCP connections could be using different 
IP addresses for id 0:

Socket A: using IP 1.2.3.4 for id 0, IP 11.22.33.44 for id 1
Socket B: using IP 5.6.7.8 for id 0, IP 11.22.33.44 for id 1

I don't think there is a use case for userspace asking to "delete all 
subflows with local ID 0 regardless of IP address".

Instead, I suggest that the del_addr netlink command require the full IP 
address when using id 0. If you pass the address in to 
mptcp_nl_remove_id_zero_address(), it can then remove only subflows using 
id 0 and the exact IP.


Thanks for the revisions, the first three patches look good!

Mat


> 	spin_lock_bh(&pernet->lock);
> 	entry = __lookup_addr_by_id(pernet, addr.addr.id);
> 	if (!entry) {
> -- 
> 2.29.2

--
Mat Martineau
Intel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-03 20:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-03 20:09 [MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 4/5] mptcp: remove id 0 address Mat Martineau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.