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] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200610034953.28861-5-dsahern@kernel.org>
Date:   Tue,  9 Jun 2020 21:49:49 -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 4/8] nexthop: Move nexthop_get_nhc_lookup to nexthop.c

nexthop_get_nhc_lookup is long enough for an inline and the
a-b checks are going to make it worse. Move to nexthop.c and
in the process refactor so that mpath code reuses single nh
lookup. Prepatory patch for adding active-backup group.

Signed-off-by: David Ahern <dsahern@...nel.org>
---
 include/net/nexthop.h | 29 +------------------------
 net/ipv4/nexthop.c    | 50 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index e5122ba78efe..e95800798aa5 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -261,37 +261,10 @@ struct fib_nh_common *nexthop_fib_nhc(struct nexthop *nh, int nhsel)
 }
 
 /* called from fib_table_lookup with rcu_lock */
-static inline
 struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh,
 					     int fib_flags,
 					     const struct flowi4 *flp,
-					     int *nhsel)
-{
-	struct nh_info *nhi;
-
-	if (nh->is_group) {
-		struct nh_group *nhg = rcu_dereference(nh->nh_grp);
-		int i;
-
-		for (i = 0; i < nhg->num_nh; i++) {
-			struct nexthop *nhe = nhg->nh_entries[i].nh;
-
-			nhi = rcu_dereference(nhe->nh_info);
-			if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) {
-				*nhsel = i;
-				return &nhi->fib_nhc;
-			}
-		}
-	} else {
-		nhi = rcu_dereference(nh->nh_info);
-		if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) {
-			*nhsel = 0;
-			return &nhi->fib_nhc;
-		}
-	}
-
-	return NULL;
-}
+					     int *nhsel);
 
 static inline bool nexthop_uses_dev(const struct nexthop *nh,
 				    const struct net_device *dev)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 940f46a7d533..c58ecc86b7a1 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -588,6 +588,56 @@ struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
 }
 EXPORT_SYMBOL_GPL(nexthop_select_path);
 
+static struct fib_nh_common *nhc_lookup_single(const struct nexthop *nh,
+					       int fib_flags,
+					       const struct flowi4 *flp,
+					       int *nhsel)
+{
+	struct nh_info *nhi;
+
+	nhi = rcu_dereference(nh->nh_info);
+	if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) {
+		*nhsel = 0;
+		return &nhi->fib_nhc;
+	}
+	return NULL;
+}
+
+static struct fib_nh_common *nhc_lookup_mpath(const struct nh_group *nhg,
+					      int fib_flags,
+					      const struct flowi4 *flp,
+					      int *nhsel)
+{
+	struct fib_nh_common *nhc;
+	int i;
+
+	for (i = 0; i < nhg->num_nh; i++) {
+		struct nexthop *nhe = nhg->nh_entries[i].nh;
+
+		nhc = nhc_lookup_single(nhe, fib_flags, flp, nhsel);
+		if (nhc) {
+			*nhsel = i;
+			return nhc;
+		}
+	}
+
+	return NULL;
+}
+
+struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh,
+					     int fib_flags,
+					     const struct flowi4 *flp,
+					     int *nhsel)
+{
+	if (nh->is_group) {
+		const struct nh_group *nhg = rcu_dereference(nh->nh_grp);
+
+		return nhc_lookup_mpath(nhg, fib_flags, flp, nhsel);
+	}
+
+	return nhc_lookup_single(nh, fib_flags, flp, nhsel);
+}
+
 static int nexthop_fib6_nh_cb(struct nexthop *nh,
 			      int (*cb)(struct fib6_nh *nh, void *arg),
 			      void *arg)
-- 
2.21.1 (Apple Git-122.3)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ