netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/7] ipv4: Make fib_select_multipath() not depend upon fib_result.
@ 2012-07-28  4:18 David Miller
  0 siblings, 0 replies; only message in thread
From: David Miller @ 2012-07-28  4:18 UTC (permalink / raw)
  To: alexander.duyck; +Cc: eric.dumazet, netdev


Pass the arguments and return the result explicitly.

Signed-off-by: David S. Miller <davem@davemloft.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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-28  4:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-28  4:18 [PATCH 6/7] ipv4: Make fib_select_multipath() not depend upon fib_result David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).