MPTCP Linux Development
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v4 1/7] mptcp: add mptcp_pm_genl_fill_addr helper
Date: Thu, 23 Jan 2025 12:37:02 +0100	[thread overview]
Message-ID: <fe08c069-c54c-4791-b84f-5c3de42fae85@kernel.org> (raw)
In-Reply-To: <ad956e331f2ee8dc8898f5beaebdcf673fd3e355.1737012165.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 16/01/2025 08:26, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> To save some redundant code in dump_addr() interfaces of both the
> netlink PM and userspace PM, the code that calls netlink message
> helpers (genlmsg_put/cancel/end) and mptcp_nl_fill_addr() is wrapped
> into a new helper mptcp_pm_genl_fill_addr().

I'm OK with the suggested modification here below (just one small
detail, please see below), but ...

> This helper will also be used in BPF path managers.

... that doesn't sound right: I don't see why a BPF PM has to dump
addresses via Netlink. In your cover-letter, you mentioned the
dump_addr() will not be implemented in the BPF PM, so I guess you left
this line by accident, right?

If not: with the in-kernel PM, it is needed to dump the endpoints to
know what has been set. With the userspace PM, the dump is useful for a
userspace PM daemon to recover from a restart. For these two PM, Netlink
is used between the userspace and the kernelspace, so that makes sense
to continue to do so. With the BPF PM, I don't really see the point: all
the communication (configuration, status, decisions, etc.) should be
done via BPF, no?

(...)

> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index fef01692eaed..afd517ff260c 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1798,7 +1798,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
>  	struct mptcp_pm_addr_entry *entry;
>  	struct pm_nl_pernet *pernet;
>  	int id = cb->args[0];
> -	void *hdr;
>  	int i;
>  
>  	pernet = pm_nl_get_pernet(net);
> @@ -1813,19 +1812,10 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
>  			if (entry->addr.id <= id)
>  				continue;
>  
> -			hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
> -					  cb->nlh->nlmsg_seq, &mptcp_genl_family,
> -					  NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
> -			if (!hdr)
> +			if (mptcp_pm_genl_fill_addr(msg, cb, entry))

Even if technically, it is correct, it feels "strange" to see:

  if (foo())
      /* error path */

It feels a bit like having:

  if (success())
      /* error */

If the goal is to stop in case of error, better being explicit about that:

  if (foo() < 0)
      /* error path */

>  				break;
>  
> -			if (mptcp_nl_fill_addr(msg, entry) < 0) {
> -				genlmsg_cancel(msg, hdr);
> -				break;
> -			}
> -
>  			id = entry->addr.id;
> -			genlmsg_end(msg, hdr);
>  		}
>  	}
>  	rcu_read_unlock();
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 277cf092a870..b50462b527bd 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -641,7 +641,6 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
>  	struct mptcp_sock *msk;
>  	int ret = -EINVAL;
>  	struct sock *sk;
> -	void *hdr;
>  
>  	bitmap = (struct id_bitmap *)cb->ctx;
>  
> @@ -657,19 +656,10 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
>  		if (test_bit(entry->addr.id, bitmap->map))
>  			continue;
>  
> -		hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
> -				  cb->nlh->nlmsg_seq, &mptcp_genl_family,
> -				  NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
> -		if (!hdr)
> +		if (mptcp_pm_genl_fill_addr(msg, cb, entry))

Same here: < 0

>  			break;
>  
> -		if (mptcp_nl_fill_addr(msg, entry) < 0) {
> -			genlmsg_cancel(msg, hdr);
> -			break;
> -		}
> -
>  		__set_bit(entry->addr.id, bitmap->map);
> -		genlmsg_end(msg, hdr);
>  	}
>  	spin_unlock_bh(&msk->pm.lock);
>  	release_sock(sk);

(...)

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2025-01-23 11:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16  7:26 [PATCH mptcp-next v4 0/7] BPF path manager, part 3 Geliang Tang
2025-01-16  7:26 ` [PATCH mptcp-next v4 1/7] mptcp: add mptcp_pm_genl_fill_addr helper Geliang Tang
2025-01-23 11:37   ` Matthieu Baerts [this message]
2025-01-16  7:26 ` [PATCH mptcp-next v4 2/7] mptcp: add a build check for userspace_pm_dump_addr Geliang Tang
2025-01-23 11:37   ` Matthieu Baerts
2025-01-16  7:26 ` [PATCH mptcp-next v4 3/7] mptcp: add struct mptcp_pm_addr_id_bitmap Geliang Tang
2025-01-23 11:40   ` Matthieu Baerts
2025-01-16  7:26 ` [PATCH mptcp-next v4 4/7] mptcp: drop inet6_sk in mptcp_nl_find_ssk Geliang Tang
2025-01-23 11:40   ` Matthieu Baerts
2025-01-16  7:26 ` [PATCH mptcp-next v4 5/7] mptcp: drop match in userspace_pm_append_new_local_addr Geliang Tang
2025-01-23 11:41   ` Matthieu Baerts
2025-01-16  7:26 ` [PATCH mptcp-next v4 6/7] mptcp: hold msk lock before removing id 0 address Geliang Tang
2025-01-23 11:43   ` Matthieu Baerts
2025-01-16  7:26 ` [PATCH mptcp-next v4 7/7] mptcp: change is_backup interfaces as get_flags Geliang Tang
2025-01-23 11:45   ` Matthieu Baerts
2025-01-16  8:34 ` [PATCH mptcp-next v4 0/7] BPF path manager, part 3 MPTCP CI
2025-01-23 11:34 ` Matthieu Baerts

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=fe08c069-c54c-4791-b84f-5c3de42fae85@kernel.org \
    --to=matttbe@kernel.org \
    --cc=geliang@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox