All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Kishen Maloor <kishen.maloor@intel.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v6 03/14] mptcp: read attributes of addr entries managed by userspace PMs
Date: Fri, 1 Apr 2022 12:13:36 -0700 (PDT)	[thread overview]
Message-ID: <2ec27254-4b37-e4ed-94c-fbb81af7438f@linux.intel.com> (raw)
In-Reply-To: <20220329021437.1196552-4-kishen.maloor@intel.com>

On Mon, 28 Mar 2022, Kishen Maloor wrote:

> This change introduces a parallel path in the kernel for retrieving
> the local id, flags, if_index for an addr entry in the context of
> an MPTCP connection that's being managed by a userspace PM. The
> userspace and in-kernel PM modes deviate in their procedures for
> obtaining this information.
>
> Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
> ---
> net/mptcp/pm_netlink.c | 95 ++++++++++++++++++++++++++++--------------
> net/mptcp/protocol.h   |  3 +-
> net/mptcp/subflow.c    |  2 +-
> 3 files changed, 67 insertions(+), 33 deletions(-)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 836f6df9f744..a258593f2cb1 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1036,31 +1036,47 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
>
> 	pernet = net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id);
>
> -	rcu_read_lock();
> -	list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) {
> -		if (mptcp_addresses_equal(&entry->addr, &skc_local, entry->addr.port)) {
> -			ret = entry->addr.id;
> -			break;
> +	if (mptcp_pm_is_kernel(msk)) {
> +		rcu_read_lock();
> +		list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) {
> +			if (mptcp_addresses_equal(&entry->addr, &skc_local, entry->addr.port)) {
> +				ret = entry->addr.id;
> +				break;
> +			}
> 		}
> +		rcu_read_unlock();
> +		if (ret >= 0)
> +			return ret;
> +
> +		/* address not found, add to local list */
> +		entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
> +		if (!entry)
> +			return -ENOMEM;
> +
> +		entry->addr = skc_local;
> +		entry->addr.id = 0;
> +		entry->addr.port = 0;
> +		entry->ifindex = 0;
> +		entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
> +		entry->lsk = NULL;
> +		ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
> +		if (ret < 0)
> +			kfree(entry);
> +	} else if (mptcp_pm_is_userspace(msk)) {
> +		struct mptcp_pm_addr_entry new_entry;
> +		__be16 msk_sport =  ((struct inet_sock *)
> +				     inet_sk((struct sock *)msk))->inet_sport;
> +
> +		memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry));
> +		new_entry.addr = skc_local;
> +		new_entry.addr.id = 0;
> +		new_entry.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
> +
> +		if (new_entry.addr.port == msk_sport)
> +			new_entry.addr.port = 0;
> +
> +		ret = mptcp_userspace_pm_append_new_local_addr(msk, &new_entry);
> 	}
> -	rcu_read_unlock();
> -	if (ret >= 0)
> -		return ret;
> -
> -	/* address not found, add to local list */
> -	entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
> -	if (!entry)
> -		return -ENOMEM;
> -
> -	entry->addr = skc_local;
> -	entry->addr.id = 0;
> -	entry->addr.port = 0;
> -	entry->ifindex = 0;
> -	entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
> -	entry->lsk = NULL;
> -	ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
> -	if (ret < 0)
> -		kfree(entry);
>
> 	return ret;
> }
> @@ -1298,22 +1314,39 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info)
> 	return 0;
> }
>
> -int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id,
> +int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id,
> 					 u8 *flags, int *ifindex)
> {
> -	struct mptcp_pm_addr_entry *entry;
> +	struct mptcp_pm_addr_entry *entry, *match = NULL;
> +	struct sock *sk = (struct sock *)msk;
> +	struct net *net = sock_net(sk);
>
> 	*flags = 0;
> 	*ifindex = 0;
>
> 	if (id) {
> -		rcu_read_lock();
> -		entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id);
> -		if (entry) {
> -			*flags = entry->flags;
> -			*ifindex = entry->ifindex;
> +		if (mptcp_pm_is_kernel(msk)) {
> +			rcu_read_lock();
> +			entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id);

Another conflict here due to the "mptcp: add pm_nl_pernet helpers" 
commit, the changes in existing code would be avoided with Paolo's 
suggestion to add a thin layer to call this function (unmodified) or a 
separate version for the userspace PM.

But also be sure to use the new pm_nl_pernet helpers in the new userspace 
PM code.


--
Mat Martineau
Intel

  parent reply	other threads:[~2022-04-01 19:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  2:14 [PATCH mptcp-next v6 00/14] mptcp: APIs and self-tests for userspace path management Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 01/14] mptcp: allow ADD_ADDR reissuance by userspace PMs Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 02/14] mptcp: handle local addrs announced " Kishen Maloor
2022-04-01 14:43   ` Paolo Abeni
2022-04-07  1:57     ` Kishen Maloor
2022-04-01 19:02   ` Mat Martineau
2022-03-29  2:14 ` [PATCH mptcp-next v6 03/14] mptcp: read attributes of addr entries managed " Kishen Maloor
2022-04-01 15:03   ` Paolo Abeni
2022-04-07  1:58     ` Kishen Maloor
2022-04-01 19:13   ` Mat Martineau [this message]
2022-03-29  2:14 ` [PATCH mptcp-next v6 04/14] mptcp: netlink: split mptcp_pm_parse_addr into two functions Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 05/14] mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 06/14] selftests: mptcp: support MPTCP_PM_CMD_ANNOUNCE Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 07/14] mptcp: netlink: Add MPTCP_PM_CMD_REMOVE Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 08/14] selftests: mptcp: support MPTCP_PM_CMD_REMOVE Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 09/14] mptcp: netlink: allow userspace-driven subflow establishment Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 10/14] selftests: mptcp: support MPTCP_PM_CMD_SUBFLOW_CREATE Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 11/14] selftests: mptcp: support MPTCP_PM_CMD_SUBFLOW_DESTROY Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 12/14] selftests: mptcp: capture netlink events Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 13/14] selftests: mptcp: create listeners to receive MPJs Kishen Maloor
2022-03-29  2:14 ` [PATCH mptcp-next v6 14/14] selftests: mptcp: functional tests for the userspace PM type Kishen Maloor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ec27254-4b37-e4ed-94c-fbb81af7438f@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --cc=kishen.maloor@intel.com \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.