diff mbox series

[net-next] nexthop: Rename artifacts related to legacy multipath nexthop groups

Message ID 2e29627ba3c4e6edf5ee2c053da52dab22f3d514.1616764400.git.petrm@nvidia.com (mailing list archive)
State Accepted
Commit de1d1ee3e3e9f028623e7beb4c090a2b68572f10
Delegated to: Netdev Maintainers
Headers show
Series [net-next] nexthop: Rename artifacts related to legacy multipath nexthop 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 fail 4 maintainers not CCed: yoshfuji@linux-ipv6.org dsahern@kernel.org davem@davemloft.net kuba@kernel.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: 517 this patch: 517
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, 192 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 542 this patch: 542
netdev/header_inline success Link

Commit Message

Petr Machata March 26, 2021, 1:20 p.m. UTC
After resilient next-hop groups have been added recently, there are two
types of multipath next-hop groups: the legacy "mpath", and the new
"resilient". Calling the legacy next-hop group type "mpath" is unfortunate,
because that describes the fact that a packet could be forwarded in one of
several paths, which is also true for the resilient next-hop groups.

Therefore, to make the naming clearer, rename various artifacts to reflect
the assumptions made. Therefore as of this patch:

- The flag for multipath groups is nh_grp_entry::is_multipath. This
  includes the legacy and resilient groups, as well as any future group
  types that behave as multipath groups.
  Functions that assume this have "mpath" in the name.

- The flag for legacy multipath groups is nh_grp_entry::hash_threshold.
  Functions that assume this have "hthr" in the name.

- The flag for resilient groups is nh_grp_entry::resilient.
  Functions that assume this have "res" in the name.

Besides the above, struct nh_grp_entry::mpath was renamed to ::hthr as
well.

UAPI artifacts were obviously left intact.

Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 include/net/nexthop.h |  4 ++--
 net/ipv4/nexthop.c    | 56 +++++++++++++++++++++----------------------
 2 files changed, 30 insertions(+), 30 deletions(-)

Comments

David Ahern March 26, 2021, 3:13 p.m. UTC | #1
On 3/26/21 7:20 AM, Petr Machata wrote:
> After resilient next-hop groups have been added recently, there are two
> types of multipath next-hop groups: the legacy "mpath", and the new
> "resilient". Calling the legacy next-hop group type "mpath" is unfortunate,
> because that describes the fact that a packet could be forwarded in one of
> several paths, which is also true for the resilient next-hop groups.
> 
> Therefore, to make the naming clearer, rename various artifacts to reflect
> the assumptions made. Therefore as of this patch:
> 
> - The flag for multipath groups is nh_grp_entry::is_multipath. This
>   includes the legacy and resilient groups, as well as any future group
>   types that behave as multipath groups.
>   Functions that assume this have "mpath" in the name.
> 
> - The flag for legacy multipath groups is nh_grp_entry::hash_threshold.
>   Functions that assume this have "hthr" in the name.
> 
> - The flag for resilient groups is nh_grp_entry::resilient.
>   Functions that assume this have "res" in the name.
> 
> Besides the above, struct nh_grp_entry::mpath was renamed to ::hthr as
> well.
> 
> UAPI artifacts were obviously left intact.
> 
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Petr Machata <petrm@nvidia.com>
> ---
>  include/net/nexthop.h |  4 ++--
>  net/ipv4/nexthop.c    | 56 +++++++++++++++++++++----------------------
>  2 files changed, 30 insertions(+), 30 deletions(-)
> 

Thanks for the followup.

Reviewed-by: David Ahern <dsahern@kernel.org>
patchwork-bot+netdevbpf@kernel.org March 29, 2021, 1 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri, 26 Mar 2021 14:20:22 +0100 you wrote:
> After resilient next-hop groups have been added recently, there are two
> types of multipath next-hop groups: the legacy "mpath", and the new
> "resilient". Calling the legacy next-hop group type "mpath" is unfortunate,
> because that describes the fact that a packet could be forwarded in one of
> several paths, which is also true for the resilient next-hop groups.
> 
> Therefore, to make the naming clearer, rename various artifacts to reflect
> the assumptions made. Therefore as of this patch:
> 
> [...]

Here is the summary with links:
  - [net-next] nexthop: Rename artifacts related to legacy multipath nexthop groups
    https://git.kernel.org/netdev/net-next/c/de1d1ee3e3e9

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index ba94868a21d5..ace54bf90b2c 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -102,7 +102,7 @@  struct nh_grp_entry {
 	union {
 		struct {
 			atomic_t	upper_bound;
-		} mpath;
+		} hthr;
 		struct {
 			/* Member on uw_nh_entries. */
 			struct list_head	uw_nh_entry;
@@ -120,7 +120,7 @@  struct nh_group {
 	struct nh_group		*spare; /* spare group for removals */
 	u16			num_nh;
 	bool			is_multipath;
-	bool			mpath;
+	bool			hash_threshold;
 	bool			resilient;
 	bool			fdb_nh;
 	bool			has_v4;
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index f09fe3a5608f..5a2fc8798d20 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -116,8 +116,8 @@  static void nh_notifier_single_info_fini(struct nh_notifier_info *info)
 	kfree(info->nh);
 }
 
-static int nh_notifier_mp_info_init(struct nh_notifier_info *info,
-				    struct nh_group *nhg)
+static int nh_notifier_mpath_info_init(struct nh_notifier_info *info,
+				       struct nh_group *nhg)
 {
 	u16 num_nh = nhg->num_nh;
 	int i;
@@ -181,8 +181,8 @@  static int nh_notifier_grp_info_init(struct nh_notifier_info *info,
 {
 	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
 
-	if (nhg->mpath)
-		return nh_notifier_mp_info_init(info, nhg);
+	if (nhg->hash_threshold)
+		return nh_notifier_mpath_info_init(info, nhg);
 	else if (nhg->resilient)
 		return nh_notifier_res_table_info_init(info, nhg);
 	return -EINVAL;
@@ -193,7 +193,7 @@  static void nh_notifier_grp_info_fini(struct nh_notifier_info *info,
 {
 	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
 
-	if (nhg->mpath)
+	if (nhg->hash_threshold)
 		kfree(info->nh_grp);
 	else if (nhg->resilient)
 		vfree(info->nh_res_table);
@@ -406,7 +406,7 @@  static int call_nexthop_res_table_notifiers(struct net *net, struct nexthop *nh,
 	 * could potentially veto it in case of unsupported configuration.
 	 */
 	nhg = rtnl_dereference(nh->nh_grp);
-	err = nh_notifier_mp_info_init(&info, nhg);
+	err = nh_notifier_mpath_info_init(&info, nhg);
 	if (err) {
 		NL_SET_ERR_MSG(extack, "Failed to initialize nexthop notifier info");
 		return err;
@@ -661,7 +661,7 @@  static int nla_put_nh_group(struct sk_buff *skb, struct nh_group *nhg)
 	u16 group_type = 0;
 	int i;
 
-	if (nhg->mpath)
+	if (nhg->hash_threshold)
 		group_type = NEXTHOP_GRP_TYPE_MPATH;
 	else if (nhg->resilient)
 		group_type = NEXTHOP_GRP_TYPE_RES;
@@ -992,9 +992,9 @@  static bool valid_group_nh(struct nexthop *nh, unsigned int npaths,
 		struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
 
 		/* Nesting groups within groups is not supported. */
-		if (nhg->mpath) {
+		if (nhg->hash_threshold) {
 			NL_SET_ERR_MSG(extack,
-				       "Multipath group can not be a nexthop within a group");
+				       "Hash-threshold group can not be a nexthop within a group");
 			return false;
 		}
 		if (nhg->resilient) {
@@ -1151,7 +1151,7 @@  static bool ipv4_good_nh(const struct fib_nh *nh)
 	return !!(state & NUD_VALID);
 }
 
-static struct nexthop *nexthop_select_path_mp(struct nh_group *nhg, int hash)
+static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash)
 {
 	struct nexthop *rc = NULL;
 	int i;
@@ -1160,7 +1160,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->mpath.upper_bound))
+		if (hash > atomic_read(&nhge->hthr.upper_bound))
 			continue;
 
 		nhi = rcu_dereference(nhge->nh->nh_info);
@@ -1212,8 +1212,8 @@  struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
 		return nh;
 
 	nhg = rcu_dereference(nh->nh_grp);
-	if (nhg->mpath)
-		return nexthop_select_path_mp(nhg, hash);
+	if (nhg->hash_threshold)
+		return nexthop_select_path_hthr(nhg, hash);
 	else if (nhg->resilient)
 		return nexthop_select_path_res(nhg, hash);
 
@@ -1710,7 +1710,7 @@  static void replace_nexthop_grp_res(struct nh_group *oldg,
 	nh_res_table_upkeep(old_res_table, true, false);
 }
 
-static void nh_mp_group_rebalance(struct nh_group *nhg)
+static void nh_hthr_group_rebalance(struct nh_group *nhg)
 {
 	int total = 0;
 	int w = 0;
@@ -1725,7 +1725,7 @@  static void nh_mp_group_rebalance(struct nh_group *nhg)
 
 		w += nhge->weight;
 		upper_bound = DIV_ROUND_CLOSEST_ULL((u64)w << 31, total) - 1;
-		atomic_set(&nhge->mpath.upper_bound, upper_bound);
+		atomic_set(&nhge->hthr.upper_bound, upper_bound);
 	}
 }
 
@@ -1752,7 +1752,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->hash_threshold = nhg->hash_threshold;
 	newg->resilient = nhg->resilient;
 	newg->fdb_nh = nhg->fdb_nh;
 	newg->num_nh = nhg->num_nh;
@@ -1781,8 +1781,8 @@  static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
 		j++;
 	}
 
-	if (newg->mpath)
-		nh_mp_group_rebalance(newg);
+	if (newg->hash_threshold)
+		nh_hthr_group_rebalance(newg);
 	else if (newg->resilient)
 		replace_nexthop_grp_res(nhg, newg);
 
@@ -1794,7 +1794,7 @@  static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
 	/* Removal of a NH from a resilient group is notified through
 	 * bucket notifications.
 	 */
-	if (newg->mpath) {
+	if (newg->hash_threshold) {
 		err = call_nexthop_notifiers(net, NEXTHOP_EVENT_REPLACE, nhp,
 					     &extack);
 		if (err)
@@ -1928,12 +1928,12 @@  static int replace_nexthop_grp(struct net *net, struct nexthop *old,
 	oldg = rtnl_dereference(old->nh_grp);
 	newg = rtnl_dereference(new->nh_grp);
 
-	if (newg->mpath != oldg->mpath) {
+	if (newg->hash_threshold != oldg->hash_threshold) {
 		NL_SET_ERR_MSG(extack, "Can not replace a nexthop group with one of a different type.");
 		return -EINVAL;
 	}
 
-	if (newg->mpath) {
+	if (newg->hash_threshold) {
 		err = call_nexthop_notifiers(net, NEXTHOP_EVENT_REPLACE, new,
 					     extack);
 		if (err)
@@ -2063,7 +2063,7 @@  static int replace_nexthop_single_notify(struct net *net,
 	struct nh_group *nhg = rtnl_dereference(group_nh->nh_grp);
 	struct nh_res_table *res_table;
 
-	if (nhg->mpath) {
+	if (nhg->hash_threshold) {
 		return call_nexthop_notifiers(net, NEXTHOP_EVENT_REPLACE,
 					      group_nh, extack);
 	} else if (nhg->resilient) {
@@ -2328,8 +2328,8 @@  static int insert_nexthop(struct net *net, struct nexthop *new_nh,
 	rb_link_node_rcu(&new_nh->rb_node, parent, pp);
 	rb_insert_color(&new_nh->rb_node, root);
 
-	/* The initial insertion is a full notification for mpath as well
-	 * as resilient groups.
+	/* The initial insertion is a full notification for hash-threshold as
+	 * well as resilient groups.
 	 */
 	rc = call_nexthop_notifiers(net, NEXTHOP_EVENT_REPLACE, new_nh, extack);
 	if (rc)
@@ -2438,7 +2438,7 @@  static struct nexthop *nexthop_create_group(struct net *net,
 	}
 
 	if (cfg->nh_grp_type == NEXTHOP_GRP_TYPE_MPATH) {
-		nhg->mpath = 1;
+		nhg->hash_threshold = 1;
 		nhg->is_multipath = true;
 	} else if (cfg->nh_grp_type == NEXTHOP_GRP_TYPE_RES) {
 		struct nh_res_table *res_table;
@@ -2455,10 +2455,10 @@  static struct nexthop *nexthop_create_group(struct net *net,
 		nhg->is_multipath = true;
 	}
 
-	WARN_ON_ONCE(nhg->mpath + nhg->resilient != 1);
+	WARN_ON_ONCE(nhg->hash_threshold + nhg->resilient != 1);
 
-	if (nhg->mpath)
-		nh_mp_group_rebalance(nhg);
+	if (nhg->hash_threshold)
+		nh_hthr_group_rebalance(nhg);
 
 	if (cfg->nh_fdb)
 		nhg->fdb_nh = 1;