From: Petr Machata Date: Thu, 28 Jan 2021 12:49:15 +0000 (+0100) Subject: nexthop: Introduce to struct nh_grp_entry a per-type union X-Git-Tag: v5.12-rc1~200^2~214^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b9bae61be46645aa3b8b5d79d5cdfabe55ae1507;p=thirdparty%2Fkernel%2Flinux.git nexthop: Introduce to struct nh_grp_entry a per-type union The values that a next-hop group needs to keep track of depend on the group type. Introduce a union to separate fields specific to the mpath groups from fields specific to other group types. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel Reviewed-by: David Ahern Signed-off-by: Jakub Kicinski --- diff --git a/include/net/nexthop.h b/include/net/nexthop.h index 226930d66b637..d0e245b0635d9 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h @@ -66,7 +66,12 @@ struct nh_info { struct nh_grp_entry { struct nexthop *nh; u8 weight; - atomic_t upper_bound; + + union { + struct { + atomic_t upper_bound; + } mpath; + }; struct list_head nh_list; struct nexthop *nh_parent; /* nexthop of group with this entry */ diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 43bb5f4513436..7a30df5aea755 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -689,7 +689,7 @@ static struct nexthop *nexthop_select_path_mp(struct nh_group *nhg, int hash) struct nh_grp_entry *nhge = &nhg->nh_entries[i]; struct nh_info *nhi; - if (hash > atomic_read(&nhge->upper_bound)) + if (hash > atomic_read(&nhge->mpath.upper_bound)) continue; nhi = rcu_dereference(nhge->nh->nh_info); @@ -924,7 +924,7 @@ static void nh_group_rebalance(struct nh_group *nhg) w += nhge->weight; upper_bound = DIV_ROUND_CLOSEST_ULL((u64)w << 31, total) - 1; - atomic_set(&nhge->upper_bound, upper_bound); + atomic_set(&nhge->mpath.upper_bound, upper_bound); } }