From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH mptcp-net v2 3/3] mptcp: pm: avoid code duplication to lookup endp
Date: Fri, 25 Oct 2024 12:44:34 +0200 [thread overview]
Message-ID: <c99617a7-6f7c-486d-bfb5-4d9633229c90@kernel.org> (raw)
In-Reply-To: <42e959952d1a9a15e19e51bd17b129d1938364c5.camel@kernel.org>
Hi Geliang,
Thank you for the review!
On 25/10/2024 12:37, Geliang Tang wrote:
> On Fri, 2024-10-25 at 11:32 +0200, Matthieu Baerts (NGI0) wrote:
>> From: Geliang Tang <tanggeliang@kylinos.cn>
>>
>> The helper __lookup_addr_rcu() can be used in
>> mptcp_pm_nl_get_local_id()
>> and mptcp_pm_nl_is_backup() to simplify the code, and avoid code
>> duplication.
(...)
>> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
>> index
>> f38e1ccd34e95cd88b179a8b50e6965731542871..7c6e664b236d1659a554d003c78
>> c72ec91895ba5 100644
>> --- a/net/mptcp/pm_netlink.c
>> +++ b/net/mptcp/pm_netlink.c
(...)
>> @@ -1191,15 +1187,11 @@ bool mptcp_pm_nl_is_backup(struct mptcp_sock
>> *msk, struct mptcp_addr_info *skc)
>> {
>> struct pm_nl_pernet *pernet =
>> pm_nl_get_pernet_from_msk(msk);
>> struct mptcp_pm_addr_entry *entry;
>> - bool backup = false;
>> + bool backup;
>>
>> rcu_read_lock();
>> - list_for_each_entry_rcu(entry, &pernet->local_addr_list,
>> list) {
>> - if (mptcp_addresses_equal(&entry->addr, skc, entry-
>>> addr.port)) {
>> - backup = !!(entry->flags &
>> MPTCP_PM_ADDR_FLAG_BACKUP);
>> - break;
>> - }
>> - }
>> + entry = __lookup_addr_rcu(pernet, skc);
>> + backup = entry && !!(entry->flags &
>> MPTCP_PM_ADDR_FLAG_BACKUP);
>
> I think we should check whether entry is NULL here too. No?
Yes, but that's what I did, no?
backup = entry && (entry->flags & BACKUP)
"backup" is set to "true" if entry is not NULL and the backup flag is set.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2024-10-25 10:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 9:32 [PATCH mptcp-net v2 0/3] mptcp: pm: use _rcu variant under rcu_read_lock Matthieu Baerts (NGI0)
2024-10-25 9:32 ` [PATCH mptcp-net v2 1/3] " Matthieu Baerts (NGI0)
2024-10-25 9:32 ` [PATCH mptcp-net v2 2/3] mptcp: pm: lockless list traversal Matthieu Baerts (NGI0)
2024-10-25 14:25 ` Geliang Tang
2024-10-25 15:26 ` Matthieu Baerts
2024-10-28 2:08 ` Geliang Tang
2024-10-28 11:48 ` Matthieu Baerts
2024-10-29 8:43 ` Geliang Tang
2024-10-31 23:24 ` Mat Martineau
2024-11-06 16:03 ` Matthieu Baerts
2024-10-25 15:17 ` Matthieu Baerts
2024-10-31 22:14 ` Mat Martineau
2024-11-05 18:21 ` Paolo Abeni
2024-11-06 16:23 ` Matthieu Baerts
2024-10-25 9:32 ` [PATCH mptcp-net v2 3/3] mptcp: pm: avoid code duplication to lookup endp Matthieu Baerts (NGI0)
2024-10-25 10:37 ` Geliang Tang
2024-10-25 10:44 ` Matthieu Baerts [this message]
2024-10-25 10:47 ` Geliang Tang
2024-10-25 10:49 ` [PATCH mptcp-net v2 0/3] mptcp: pm: use _rcu variant under rcu_read_lock MPTCP CI
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=c99617a7-6f7c-486d-bfb5-4d9633229c90@kernel.org \
--to=matttbe@kernel.org \
--cc=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=pabeni@redhat.com \
/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.