Commit 720ccd9a authored by Petr Machata's avatar Petr Machata Committed by Jakub Kicinski

nexthop: Assert the invariant that a NH group is of only one type

Most of the code that deals with nexthop groups relies on the fact that the
group is of exactly one well-known type. Currently there is only one type,
"mpath", but as more next-hop group types come, it becomes desirable to
have a central place where the setting is validated. Introduce such place
into nexthop_create_group(), such that the check is done before the code
that relies on that invariant is invoked.
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 b9bae61b
...@@ -1466,10 +1466,13 @@ static struct nexthop *nexthop_create_group(struct net *net, ...@@ -1466,10 +1466,13 @@ static struct nexthop *nexthop_create_group(struct net *net,
nhg->nh_entries[i].nh_parent = nh; nhg->nh_entries[i].nh_parent = nh;
} }
if (cfg->nh_grp_type == NEXTHOP_GRP_TYPE_MPATH) { if (cfg->nh_grp_type == NEXTHOP_GRP_TYPE_MPATH)
nhg->mpath = 1; nhg->mpath = 1;
WARN_ON_ONCE(nhg->mpath != 1);
if (nhg->mpath)
nh_group_rebalance(nhg); nh_group_rebalance(nhg);
}
if (cfg->nh_fdb) if (cfg->nh_fdb)
nhg->fdb_nh = 1; nhg->fdb_nh = 1;
......
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