Commit 79bc55e3 authored by Petr Machata's avatar Petr Machata Committed by Jakub Kicinski

nexthop: Dispatch nexthop_select_path() by group type

The logic for selecting path depends on the next-hop group type. Adapt the
nexthop_select_path() to dispatch according to the group type.
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5d1f0f09
......@@ -680,16 +680,11 @@ static bool ipv4_good_nh(const struct fib_nh *nh)
return !!(state & NUD_VALID);
}
struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
static struct nexthop *nexthop_select_path_mp(struct nh_group *nhg, int hash)
{
struct nexthop *rc = NULL;
struct nh_group *nhg;
int i;
if (!nh->is_group)
return nh;
nhg = rcu_dereference(nh->nh_grp);
for (i = 0; i < nhg->num_nh; ++i) {
struct nh_grp_entry *nhge = &nhg->nh_entries[i];
struct nh_info *nhi;
......@@ -721,6 +716,21 @@ struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
return rc;
}
struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
{
struct nh_group *nhg;
if (!nh->is_group)
return nh;
nhg = rcu_dereference(nh->nh_grp);
if (nhg->mpath)
return nexthop_select_path_mp(nhg, hash);
/* Unreachable. */
return NULL;
}
EXPORT_SYMBOL_GPL(nexthop_select_path);
int nexthop_for_each_fib6_nh(struct nexthop *nh,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment