Skip to content

Commit

Permalink
nexthop: Add a dedicated flag for multipath next-hop groups
Browse files Browse the repository at this point in the history
With the introduction of resilient nexthop groups, there will be two types
of multipath groups: the current hash-threshold "mpath" ones, and resilient
groups. Both are multipath, but to determine the fact, the system needs to
consider two flags. This might prove costly in the datapath. Therefore,
introduce a new flag, that should be set for next-hop groups that have more
than one nexthop, and should be considered multipath.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Mar 12, 2021
1 parent 96a8562 commit 90e1a9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions include/net/nexthop.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct nh_grp_entry {
struct nh_group {
struct nh_group *spare; /* spare group for removals */
u16 num_nh;
bool is_multipath;
bool mpath;
bool fdb_nh;
bool has_v4;
Expand Down Expand Up @@ -212,7 +213,7 @@ static inline bool nexthop_is_multipath(const struct nexthop *nh)
struct nh_group *nh_grp;

nh_grp = rcu_dereference_rtnl(nh->nh_grp);
return nh_grp->mpath;
return nh_grp->is_multipath;
}
return false;
}
Expand All @@ -227,7 +228,7 @@ static inline unsigned int nexthop_num_path(const struct nexthop *nh)
struct nh_group *nh_grp;

nh_grp = rcu_dereference_rtnl(nh->nh_grp);
if (nh_grp->mpath)
if (nh_grp->is_multipath)
rc = nh_grp->num_nh;
}

Expand Down Expand Up @@ -308,7 +309,7 @@ struct fib_nh_common *nexthop_fib_nhc(struct nexthop *nh, int nhsel)
struct nh_group *nh_grp;

nh_grp = rcu_dereference_rtnl(nh->nh_grp);
if (nh_grp->mpath) {
if (nh_grp->is_multipath) {
nh = nexthop_mpath_select(nh_grp, nhsel);
if (!nh)
return NULL;
Expand Down
5 changes: 4 additions & 1 deletion net/ipv4/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
}

newg->has_v4 = false;
newg->is_multipath = nhg->is_multipath;
newg->mpath = nhg->mpath;
newg->fdb_nh = nhg->fdb_nh;
newg->num_nh = nhg->num_nh;
Expand Down Expand Up @@ -1488,8 +1489,10 @@ static struct nexthop *nexthop_create_group(struct net *net,
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->is_multipath = true;
}

WARN_ON_ONCE(nhg->mpath != 1);

Expand Down

0 comments on commit 90e1a9e

Please sign in to comment.