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 v2 6/7] mptcp: add check_id for lookup_anno_list_by_saddr
Date: Mon, 26 Feb 2024 11:07:35 +0100 [thread overview]
Message-ID: <426ebb6d-18af-4a8f-a291-82faddb66b30@kernel.org> (raw)
In-Reply-To: <608dcc5649b212dc1a37c72fa7b465d3e8619316.1708588977.git.tanggeliang@kylinos.cn>
Hi Geliang,
On 22/02/2024 09:03, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> This patch adds a new helper mptcp_addresses_equal_check_id() to test the
> address ids, as well as the address. This can be used to test if the two
> given addresses are identically equal, they have both the same address and
> the same address id.
>
> Add a new parameter check_id for mptcp_lookup_anno_list_by_saddr(), pass
> it to mptcp_addresses_equal_check_id(). Then in mptcp_pm_del_add_timer(),
> the input parameter check_id can be passed as the new parameter into
> mptcp_lookup_anno_list_by_saddr(). After this, this condition:
>
> (!check_id || entry->addr.id == addr->id)
>
> can be dropped, only test if 'entry' is NULL is enough.
Or use an extra variable? Please see below.
(...)
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 5c17d39146ea..7d755c0a32bb 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
(...)
> @@ -324,12 +325,12 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk,
> struct sock *sk = (struct sock *)msk;
>
> spin_lock_bh(&msk->pm.lock);
> - entry = mptcp_lookup_anno_list_by_saddr(msk, addr);
> - if (entry && (!check_id || entry->addr.id == addr->id))
> + entry = mptcp_lookup_anno_list_by_saddr(msk, addr, check_id);
> + if (entry)
> entry->retrans_times = ADD_ADDR_RETRANS_MAX;
> spin_unlock_bh(&msk->pm.lock);
>
> - if (entry && (!check_id || entry->addr.id == addr->id))
> + if (entry)
I probably missed something, but why not only do the modification here
as suggested in the v1 instead of changing the signature of
mptcp_lookup_anno_list_by_saddr() and introducing
mptcp_addresses_equal_check_id() which is indirectly only used once from
here?
bool stop_retrans;
(...)
spin_lock_bh(&msk->pm.lock);
entry = mptcp_lookup_anno_list_by_saddr(msk, addr);
stop_retrans = entry && (!check_id || entry->addr.id == addr->id);
if (stop_retrans)
entry->retrans_times = ADD_ADDR_RETRANS_MAX;
spin_unlock_bh(&msk->pm.lock);
if (stop_retrans)
sk_stop_timer_sync(sk, &entry->add_timer);
The refactoring would make sense if you have multiple users of this long
conditions. Here, it looks like it is adding more complexity to get
functions more generic, with more checks, just to handle one particular
case that can be extracted here, no?
> sk_stop_timer_sync(sk, &entry->add_timer);
>
> return entry;
(...)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2024-02-26 10:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 8:03 [PATCH mptcp-next v2 0/7] some cleanups Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 1/7] mptcp: make pm_remove_addrs_and_subflows static Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 2/7] mptcp: drop duplicate header inclusions Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 3/7] mptcp: update set_flags interfaces Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 4/7] mptcp: set error messages for set_flags Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 5/7] mptcp: drop lookup_by_id in lookup_addr Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 6/7] mptcp: add check_id for lookup_anno_list_by_saddr Geliang Tang
2024-02-26 10:07 ` Matthieu Baerts [this message]
2024-03-28 18:27 ` Matthieu Baerts
2024-03-29 4:50 ` Geliang Tang
2024-02-22 8:03 ` [PATCH mptcp-next v2 7/7] selftests: mptcp: flush userspace addrs list Geliang Tang
2024-02-22 8:51 ` selftests: mptcp: flush userspace addrs list: Tests Results MPTCP CI
2024-02-26 10:07 ` [PATCH mptcp-next v2 7/7] selftests: mptcp: flush userspace addrs list Matthieu Baerts
2024-02-26 10:06 ` [PATCH mptcp-next v2 0/7] some cleanups Matthieu Baerts
2024-02-27 1:40 ` Geliang Tang
2024-02-27 9:11 ` Matthieu Baerts
2024-02-27 9:12 ` 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=426ebb6d-18af-4a8f-a291-82faddb66b30@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 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.