public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: David Ahern <dsahern@kernel.org>
Cc: Benjamin Poirier <bpoirier@nvidia.com>,
	netdev@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next 3/4] nexthop: Do not return invalid nexthop object during multipath selection
Date: Wed, 31 May 2023 09:04:32 +0300	[thread overview]
Message-ID: <ZHbjcNZbz3dhY9qT@shredder> (raw)
In-Reply-To: <eb6a1866-7c71-53c6-241f-0a38a4047f7e@kernel.org>

On Tue, May 30, 2023 at 09:08:01AM -0600, David Ahern wrote:
> 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.

Yea, looking at it again not sure what I was thinking...

Thanks for the review!

> 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)
> 
> 

  reply	other threads:[~2023-05-31  6:04 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
2023-05-31  6:04     ` Ido Schimmel [this message]
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=ZHbjcNZbz3dhY9qT@shredder \
    --to=idosch@nvidia.com \
    --cc=bpoirier@nvidia.com \
    --cc=dsahern@kernel.org \
    --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