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 v3] mptcp: use GENL_REQ_ATTR_CHECK for token
Date: Sat, 21 Dec 2024 11:39:18 +0100	[thread overview]
Message-ID: <c5d1e778-7989-4ed4-ac90-cf8334604cc3@kernel.org> (raw)
In-Reply-To: <f10fd4d16e3fe406dbac0c8dc17d37c5ab2431b6.camel@kernel.org>

Hi Geliang,

On 20/12/2024 10:50, Geliang Tang wrote:
> Hi Matt,
> 
> On Mon, 2024-12-16 at 12:24 +0100, Matthieu Baerts wrote:
>> Hi Geliang,
>>
>> On 16/12/2024 09:31, Geliang Tang wrote:
>>> From: Geliang Tang <tanggeliang@kylinos.cn>
>>>
>>> A more general way to check if MPTCP_PM_ATTR_TOKEN exists in 'info'
>>> is to use GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_TOKEN) instead of
>>> directly reading info->attrs[MPTCP_PM_ATTR_TOKEN] and then checking
>>> if it's NULL.
>>>
>>> So this patch uses GENL_REQ_ATTR_CHECK() for 'token' in 'info' in
>>> mptcp_userspace_pm_get_sock().
>>>
>>> 'Suggested-by: Jakub Kicinski <kuba@kernel.org>'
>>> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
>>> ---
>>> v3:
>>>  - use GENL_REQ_ATTR_CHECK in mptcp_userspace_pm_get_sock only
>>>  - drop GENL_SET_ERR_MSG as Matt suggested (thanks)
>>
>> Thank you for the v3. While at it, do you want to do a similar change
>> everywhere we do:
>>
>>   struct nlattr *X = info->attrs[MPTCP_PM_ATTR_Y]:
>>   if (!X) {
>>       GENL_SET_ERR_MSG(info, "missing ...");
>>       return Z;
>>   }
>>
>> e.g. in mptcp_pm_nl_announce_doit() (addr), mptcp_pm_nl_remove_doit()
>> (id), mptcp_pm_nl_subflow_create_doit() (raddr, laddr),
>> mptcp_pm_nl_subflow_destroy_doit() (raddr, laddr).
>> (and maybe mptcp_pm_parse_pm_addr_attr(), but it needs more changes
>> around to pass the attribute ID, probably best not to change that)
> 
> Thanks for this suggestion, I updated this in v4.

Thank you!

>> Also, do you know if 'pm_nl_ctl' will continue to indicate a helpful
>> message if such attribute is missing (that's a message more for
> 
> 'pm_nl_ctl' can't display nl error msg, this is a bug in nl_error():
> 
>  $ sudo ip mptcp endpoint del id 100
>  Error: address not found.
>  $ sudo ./pm_nl_ctl del 100
>  netlink error -22 (Invalid argument)
>  ./pm_nl_ctl: bailing out due to netlink error[s]
> 
> Look at this test, nl error msg "address not found" in
> mptcp_pm_nl_del_addr_doit() can be displayed in 'ip mptcp', but not in
> 'pm_nl_ctl'. I'll try to fix it.

It might help developers if pm_nl_ctl could also print errors generated
by GENL_REQ_ATTR_CHECK(), not only the ones generated with
GENL_SET_ERR_MSG().

>> userspace app dev)? Or does it need to be modified to display the
>> missing argument set by GENL_REQ_ATTR_CHECK()?
> 
> I think no need to modify this, since after GENL_REQ_ATTR_CHECK(), we
> will also call NL_SET_ERR_MSG_ATTR/GENL_SET_ERR_MSG to set nl error msg
> in the error paths.

If GENL_REQ_ATTR_CHECK() is used, it should no longer needed to use
NL_SET_ERR_MSG_ATTR/GENL_SET_ERR_MSG. I guess the userspace should be
able to find the arguments that are missing, no?

This can be done in another series of course.

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


      reply	other threads:[~2024-12-21 10:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16  8:31 [PATCH mptcp-next v3] mptcp: use GENL_REQ_ATTR_CHECK for token Geliang Tang
2024-12-16  9:29 ` MPTCP CI
2024-12-16 11:24 ` Matthieu Baerts
2024-12-20  9:50   ` Geliang Tang
2024-12-21 10:39     ` Matthieu Baerts [this message]

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=c5d1e778-7989-4ed4-ac90-cf8334604cc3@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