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)