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-6-dsahern@kernel.org>
Date:   Tue,  9 Jun 2020 21:49:50 -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 5/8] nexthop: Move nexthop_uses_dev to nexthop.c

nexthop_uses_dev 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 | 25 +------------------------
 net/ipv4/nexthop.c    | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index e95800798aa5..271d2cb92954 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -266,30 +266,7 @@ struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh,
 					     const struct flowi4 *flp,
 					     int *nhsel);
 
-static inline bool nexthop_uses_dev(const struct nexthop *nh,
-				    const struct net_device *dev)
-{
-	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 (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev))
-				return true;
-		}
-	} else {
-		nhi = rcu_dereference(nh->nh_info);
-		if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev))
-			return true;
-	}
-
-	return false;
-}
+bool nexthop_uses_dev(const struct nexthop *nh, const struct net_device *dev);
 
 static inline unsigned int fib_info_num_path(const struct fib_info *fi)
 {
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index c58ecc86b7a1..0020ea2ecc9f 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -638,6 +638,41 @@ struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh,
 	return nhc_lookup_single(nh, fib_flags, flp, nhsel);
 }
 
+static bool nh_uses_dev_single(const struct nexthop *nh,
+			       const struct net_device *dev)
+{
+	const struct nh_info *nhi;
+
+	nhi = rcu_dereference(nh->nh_info);
+	return nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev);
+}
+
+static bool nh_uses_dev_mpath(const struct nh_group *nhg,
+			      const struct net_device *dev)
+{
+	int i;
+
+	for (i = 0; i < nhg->num_nh; i++) {
+		struct nexthop *nhe = nhg->nh_entries[i].nh;
+
+		if (nh_uses_dev_single(nhe, dev))
+			return true;
+	}
+
+	return false;
+}
+
+bool nexthop_uses_dev(const struct nexthop *nh, const struct net_device *dev)
+{
+	if (nh->is_group) {
+		const struct nh_group *nhg = rcu_dereference(nh->nh_grp);
+
+		return nh_uses_dev_mpath(nhg, dev);
+	}
+
+	return nh_uses_dev_single(nh, dev);
+}
+
 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