diff mbox series

[net-next,03/12] nexthop: Introduce to struct nh_grp_entry a per-type union

Message ID 96736e8f9767633e73dacd59c0836547824d0ff8.1611836479.git.petrm@nvidia.com (mailing list archive)
State Accepted
Commit b9bae61be46645aa3b8b5d79d5cdfabe55ae1507
Delegated to: Netdev Maintainers
Headers show
Series nexthop: Preparations for resilient next-hop groups | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: yoshfuji@linux-ipv6.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 642 this patch: 642
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 667 this patch: 667
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Petr Machata Jan. 28, 2021, 12:49 p.m. UTC
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 <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
 include/net/nexthop.h | 7 ++++++-
 net/ipv4/nexthop.c    | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

David Ahern Jan. 29, 2021, 3:09 a.m. UTC | #1
On 1/28/21 5:49 AM, Petr Machata wrote:
> 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 <petrm@nvidia.com>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  include/net/nexthop.h | 7 ++++++-
>  net/ipv4/nexthop.c    | 4 ++--
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>
diff mbox series

Patch

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index 226930d66b63..d0e245b0635d 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 43bb5f451343..7a30df5aea75 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);
 	}
 }