lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue,  9 Jun 2020 21:49:48 -0600
From:   David Ahern <dsahern@...nel.org>
To:     netdev@...r.kernel.org
Cc:     davem@...emloft.net, kuba@...nel.org, assogba.emery@...il.com,
        dsahern@...il.com, David Ahern <dsahern@...nel.org>
Subject: [PATCH RFC net-next 3/8] nexthop: Refactor nexthop_for_each_fib6_nh

Refactor nexthop_for_each_fib6_nh moving standalone and group processing
into helpers. Prepatory patch for adding active-backup group.

Signed-off-by: David Ahern <dsahern@...nel.org>
---
 net/ipv4/nexthop.c | 48 +++++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 7d0a170821f3..940f46a7d533 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -588,34 +588,52 @@ struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
 }
 EXPORT_SYMBOL_GPL(nexthop_select_path);
 
+static int nexthop_fib6_nh_cb(struct nexthop *nh,
+			      int (*cb)(struct fib6_nh *nh, void *arg),
+			      void *arg)
+{
+	struct nh_info *nhi;
+
+	nhi = rcu_dereference_rtnl(nh->nh_info);
+
+	return cb(&nhi->fib6_nh, arg);
+}
+
+static int nexthop_fib6_nhg_cb(struct nh_group *nhg,
+			       int (*cb)(struct fib6_nh *nh, void *arg),
+			       void *arg)
+{
+	int err;
+	int i;
+
+	for (i = 0; i < nhg->num_nh; i++) {
+		struct nh_grp_entry *nhge = &nhg->nh_entries[i];
+		struct nexthop *nh = nhge->nh;
+
+		err = nexthop_fib6_nh_cb(nh, cb, arg);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
 int nexthop_for_each_fib6_nh(struct nexthop *nh,
 			     int (*cb)(struct fib6_nh *nh, void *arg),
 			     void *arg)
 {
-	struct nh_info *nhi;
 	int err;
 
 	if (nh->is_group) {
 		struct nh_group *nhg;
-		int i;
 
 		nhg = rcu_dereference_rtnl(nh->nh_grp);
-		for (i = 0; i < nhg->num_nh; i++) {
-			struct nh_grp_entry *nhge = &nhg->nh_entries[i];
-
-			nhi = rcu_dereference_rtnl(nhge->nh->nh_info);
-			err = cb(&nhi->fib6_nh, arg);
-			if (err)
-				return err;
-		}
+		err = nexthop_fib6_nhg_cb(nhg, cb, arg);
 	} else {
-		nhi = rcu_dereference_rtnl(nh->nh_info);
-		err = cb(&nhi->fib6_nh, arg);
-		if (err)
-			return err;
+		err = nexthop_fib6_nh_cb(nh, cb, arg);
 	}
 
-	return 0;
+	return err;
 }
 EXPORT_SYMBOL_GPL(nexthop_for_each_fib6_nh);
 
-- 
2.21.1 (Apple Git-122.3)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ