Subject: Re: [RFC PATCH 04/13] nexthop: Add implementation of resilient next-hop groups

From: Ido Schimmel <[email-masked]>
Date: Sat, 13 Feb 2021 22:20:39 +0200

On Sat, Feb 13, 2021 at 12:38:47PM -0700, David Ahern wrote:
> On 2/8/21 1:42 PM, Petr Machata wrote:
> > diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> > index 5d560d381070..4ce282b0a65f 100644
> > --- a/net/ipv4/nexthop.c
> > +++ b/net/ipv4/nexthop.c> @@ -734,6 +834,22 @@ static struct nexthop
> *nexthop_select_path_mp(struct nh_group *nhg, int hash)
> >  	return rc;
> >  }
> >  
> > +static struct nexthop *nexthop_select_path_res(struct nh_group *nhg, int hash)
> > +{
> > +	struct nh_res_table *res_table = rcu_dereference(nhg->res_table);
> > +	u32 bucket_index = hash % res_table->num_nh_buckets;
> 
> Have you considered requiring the number of buckets to be a power of 2
> to avoid the modulo in the hot path? Seems like those are the more
> likely size options.

We thought about it, but I think it is overly limiting. Even in Spectrum
(for some sizes) it does not have to be a power of 2.