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 7/7] mptcp: add local parameter for set_flags
Date: Fri, 10 Jan 2025 12:53:15 +0100 [thread overview]
Message-ID: <68170ee3-dfef-4720-b132-b8f70eafcf7c@kernel.org> (raw)
In-Reply-To: <3613363fc62da1323303ff776fba2914433e95c7.1736494320.git.tanggeliang@kylinos.cn>
Hi Geliang,
On 10/01/2025 08:36, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> This patch updates the interfaces set_flags to reduce repetitive
> code, adds a new parameter 'local' for them. The local address is
> parsed in public helper mptcp_pm_nl_set_flags_doit(), then pass
> it to mptcp_pm_nl_set_flags() and mptcp_userspace_pm_set_flags().
(...)
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 52fd9830b685..ec6afa5c3525 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1951,61 +1951,51 @@ static int mptcp_nl_set_flags(struct net *net,
> return ret;
> }
>
> -int mptcp_pm_nl_set_flags(struct genl_info *info)
> +int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
> + struct genl_info *info)
> {
> - struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, };
> u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP |
> MPTCP_PM_ADDR_FLAG_FULLMESH;
> struct net *net = genl_info_net(info);
> struct mptcp_pm_addr_entry *entry;
> struct pm_nl_pernet *pernet;
> - struct nlattr *attr;
> u8 lookup_by_id = 0;
> u8 bkup = 0;
> - int ret;
> -
> - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR))
> - return -EINVAL;
>
> pernet = pm_nl_get_pernet(net);
>
> - attr = info->attrs[MPTCP_PM_ATTR_ADDR];
As I mentioned in the "use GENL_REQ_ATTR_CHECK in userspace pm" series,
I think this 'attr' can be kept here -- because we still have access to
'info' -- ...
> - ret = mptcp_pm_parse_entry(attr, info, false, &addr);
> - if (ret < 0)
> - return ret;
> -
> - if (addr.addr.family == AF_UNSPEC) {
> + if (local->addr.family == AF_UNSPEC) {
> lookup_by_id = 1;
> - if (!addr.addr.id) {
> + if (!local->addr.id) {
> GENL_SET_ERR_MSG(info, "missing address ID");
... and use NL_SET_ERR_MSG_ATTR() here and below.
That way, the code around the reporting of errors would be uniformed
with the rest, and that could still help userspace devs.
I can do the modifications when applying the patches of the other series
and this one here.
(...)
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 4007f67cc7b1..431454578021 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -564,19 +564,18 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
> return err;
> }
>
> -int mptcp_userspace_pm_set_flags(struct genl_info *info)
> +int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
> + struct genl_info *info)
> {
> - struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, };
> struct mptcp_addr_info rem = { .family = AF_UNSPEC, };
> struct mptcp_pm_addr_entry *entry;
> - struct nlattr *attr, *attr_rem;
> + struct nlattr *attr_rem;
> struct mptcp_sock *msk;
> int ret = -EINVAL;
> struct sock *sk;
> u8 bkup = 0;
>
> - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) ||
> - GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE))
> + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE))
> return ret;
>
> msk = mptcp_userspace_pm_get_sock(info);
> @@ -585,12 +584,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info)
>
> sk = (struct sock *)msk;
>
> - attr = info->attrs[MPTCP_PM_ATTR_ADDR];
Same here.
> - ret = mptcp_pm_parse_entry(attr, info, false, &loc);
> - if (ret < 0)
> - goto set_flags_err;
> -
> - if (loc.addr.family == AF_UNSPEC) {
> + if (local->addr.family == AF_UNSPEC) {
> GENL_SET_ERR_MSG(info, "invalid local address family");
> ret = -EINVAL;
> goto set_flags_err;
(...)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2025-01-10 11:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 7:36 [PATCH mptcp-next v4 0/7] BPF path manager, part 2 Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 1/7] mptcp: make three pm wrappers static Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 2/7] mptcp: drop skb parameter of get_addr Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 3/7] mptcp: add id parameter for get_addr Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 4/7] mptcp: reuse sending nlmsg code in get_addr Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 5/7] mptcp: drop skb parameter of set_flags Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 6/7] mptcp: change rem type " Geliang Tang
2025-01-10 7:36 ` [PATCH mptcp-next v4 7/7] mptcp: add local parameter for set_flags Geliang Tang
2025-01-10 11:53 ` Matthieu Baerts [this message]
2025-01-10 9:12 ` [PATCH mptcp-next v4 0/7] BPF path manager, part 2 MPTCP CI
2025-01-10 11:53 ` Matthieu Baerts
2025-01-10 12:40 ` Geliang Tang
2025-01-12 13:09 ` 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=68170ee3-dfef-4720-b132-b8f70eafcf7c@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