From: David Ahern <dsahern@kernel.org>
To: Benjamin Poirier <bpoirier@nvidia.com>, netdev@vger.kernel.org
Cc: Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH net-next 3/4] nexthop: Do not return invalid nexthop object during multipath selection
Date: Tue, 30 May 2023 09:08:01 -0600 [thread overview]
Message-ID: <eb6a1866-7c71-53c6-241f-0a38a4047f7e@kernel.org> (raw)
In-Reply-To: <20230529201914.69828-4-bpoirier@nvidia.com>
On 5/29/23 2:19 PM, Benjamin Poirier wrote:
> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index c12acbf39659..ca501ced04fb 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c
> @@ -1186,6 +1186,7 @@ static struct nexthop *nexthop_select_path_fdb(struct nh_group *nhg, int hash)
> static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash)
> {
> struct nexthop *rc = NULL;
> + bool first = false;
> int i;
>
> if (nhg->fdb_nh)
> @@ -1194,20 +1195,24 @@ static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash)
> for (i = 0; i < nhg->num_nh; ++i) {
> struct nh_grp_entry *nhge = &nhg->nh_entries[i];
>
> - if (hash > atomic_read(&nhge->hthr.upper_bound))
> - continue;
> -
> /* nexthops always check if it is good and does
> * not rely on a sysctl for this behavior
> */
> - if (nexthop_is_good_nh(nhge->nh))
> - return nhge->nh;
> + if (!nexthop_is_good_nh(nhge->nh))
> + continue;
>
> - if (!rc)
> + if (!first) {
Setting 'first' and 'rc' are equivalent, so 'first' is not needed. As I
recall it was used in fib_select_multipath before the nexthop
refactoring (eba618abacade) because nhsel == 0 is valid, so the loop
could not rely on it.
> rc = nhge->nh;
> + first = true;
> + }
> +
> + if (hash > atomic_read(&nhge->hthr.upper_bound))
> + continue;
> +
> + return nhge->nh;
> }
>
> - return rc;
> + return rc ? : nhg->nh_entries[0].nh;
> }
>
> static struct nexthop *nexthop_select_path_res(struct nh_group *nhg, int hash)
next prev parent reply other threads:[~2023-05-30 15:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 20:19 [PATCH net-next 0/4] nexthop: Refactor and fix nexthop selection for multipath routes Benjamin Poirier
2023-05-29 20:19 ` [PATCH net-next 1/4] nexthop: Factor out hash threshold fdb nexthop selection Benjamin Poirier
2023-05-30 14:57 ` David Ahern
2023-07-19 13:54 ` Benjamin Poirier
2023-05-29 20:19 ` [PATCH net-next 2/4] nexthop: Factor out neighbor validity check Benjamin Poirier
2023-05-30 14:58 ` David Ahern
2023-05-29 20:19 ` [PATCH net-next 3/4] nexthop: Do not return invalid nexthop object during multipath selection Benjamin Poirier
2023-05-30 15:08 ` David Ahern [this message]
2023-05-31 6:04 ` Ido Schimmel
2023-05-29 20:19 ` [PATCH net-next 4/4] selftests: net: Add test cases for nexthop groups with invalid neighbors Benjamin Poirier
2023-05-30 15:10 ` David Ahern
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=eb6a1866-7c71-53c6-241f-0a38a4047f7e@kernel.org \
--to=dsahern@kernel.org \
--cc=bpoirier@nvidia.com \
--cc=idosch@nvidia.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).