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>] [day] [month] [year] [list]
Date:	Fri, 27 Jul 2012 21:18:38 -0700 (PDT)
From:	David Miller <davem@...emloft.net>
To:	alexander.duyck@...il.com
Cc:	eric.dumazet@...il.com, netdev@...r.kernel.org
Subject: [PATCH 6/7] ipv4: Make fib_select_multipath() not depend upon
 fib_result.


Pass the arguments and return the result explicitly.

Signed-off-by: David S. Miller <davem@...emloft.net>
---
 include/net/ip_fib.h     |    2 +-
 net/ipv4/fib_semantics.c |   15 +++++++--------
 net/ipv4/route.c         |    4 ++--
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 8a57513..66f5365 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -287,7 +287,7 @@ extern int fib_sync_down_dev(struct net_device *dev, int force);
 extern int fib_sync_down_addr(struct net *net, __be32 local);
 extern void fib_update_nh_saddrs(struct net_device *dev);
 extern int fib_sync_up(struct net_device *dev);
-extern void fib_select_multipath(struct fib_result *res);
+extern struct fib_nh *fib_select_multipath(struct fib_nh *res_nh);
 
 /* Exported by fib_trie.c */
 extern void fib_trie_init(void);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 4c7b55c..f83bef3 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1254,9 +1254,9 @@ int fib_sync_up(struct net_device *dev)
  * The algorithm is suboptimal, but it provides really
  * fair weighted route distribution.
  */
-void fib_select_multipath(struct fib_result *res)
+struct fib_nh *fib_select_multipath(struct fib_nh *res_nh)
 {
-	struct fib_info *fi = res->nh->nh_parent;
+	struct fib_info *fi = res_nh->nh_parent;
 	int w;
 
 	spin_lock_bh(&fib_multipath_lock);
@@ -1272,8 +1272,7 @@ void fib_select_multipath(struct fib_result *res)
 		if (power <= 0) {
 			spin_unlock_bh(&fib_multipath_lock);
 			/* Race condition: route has just become dead. */
-			res->nh = &fi->fib_nh[0];
-			return;
+			return &fi->fib_nh[0];
 		}
 	}
 
@@ -1291,15 +1290,15 @@ void fib_select_multipath(struct fib_result *res)
 			if (w <= 0) {
 				nexthop_nh->nh_power--;
 				fi->fib_power--;
-				res->nh = &fi->fib_nh[nhsel];
 				spin_unlock_bh(&fib_multipath_lock);
-				return;
+				return &fi->fib_nh[nhsel];
 			}
 		}
 	} endfor_nexthops(fi);
 
-	/* Race condition: route has just become dead. */
-	res->nh = &fi->fib_nh[0];
 	spin_unlock_bh(&fib_multipath_lock);
+
+	/* Race condition: route has just become dead. */
+	return &fi->fib_nh[0];
 }
 #endif
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9a247ff..6b54323 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1461,7 +1461,7 @@ static int ip_mkroute_input(struct sk_buff *skb,
 {
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	if (res->nh->nh_parent->fib_nhs > 1)
-		fib_select_multipath(res);
+		res->nh = fib_select_multipath(res->nh);
 #endif
 
 	/* create a routing cache entry */
@@ -1964,7 +1964,7 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	if (res.nh->nh_parent->fib_nhs > 1 && fl4->flowi4_oif == 0)
-		fib_select_multipath(&res);
+		res.nh = fib_select_multipath(res.nh);
 	else
 #endif
 	if (!res.nh->nh_parent->fib_prefixlen &&
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ