aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-10-05 11:51:25 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-07 07:27:44 -0400
commit3ce58d84358c7b477811b5100152fad848f936fc (patch)
treebe2bfdfeddad87ab8f9374e91063213982e24ffa
parentfee6d4c777a125e56de9370db3b2bf359bf958d6 (diff)
net: Refactor path selection in __ip_route_output_key_hash
VRF device needs the same path selection following lookup to set source address. Rather than duplicating code, move existing code into a function that is exported to modules. Code move only; no functional change. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ip_fib.h2
-rw-r--r--net/ipv4/fib_semantics.c21
-rw-r--r--net/ipv4/route.c16
3 files changed, 24 insertions, 15 deletions
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 7a51fd8d99e4..ac5c6e80586a 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -329,6 +329,8 @@ static inline int fib_multipath_hash(__be32 saddr, __be32 daddr)
329} 329}
330 330
331void fib_select_multipath(struct fib_result *res, int hash); 331void fib_select_multipath(struct fib_result *res, int hash);
332void fib_select_path(struct net *net, struct fib_result *res,
333 struct flowi4 *fl4, int mp_hash);
332 334
333/* Exported by fib_trie.c */ 335/* Exported by fib_trie.c */
334void fib_trie_init(void); 336void fib_trie_init(void);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 7bd698c3bd3a..af77298c8b4f 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1557,3 +1557,24 @@ void fib_select_multipath(struct fib_result *res, int hash)
1557 res->nh_sel = 0; 1557 res->nh_sel = 0;
1558} 1558}
1559#endif 1559#endif
1560
1561void fib_select_path(struct net *net, struct fib_result *res,
1562 struct flowi4 *fl4, int mp_hash)
1563{
1564#ifdef CONFIG_IP_ROUTE_MULTIPATH
1565 if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) {
1566 if (mp_hash < 0)
1567 mp_hash = fib_multipath_hash(fl4->saddr, fl4->daddr);
1568 fib_select_multipath(res, mp_hash);
1569 }
1570 else
1571#endif
1572 if (!res->prefixlen &&
1573 res->table->tb_num_default > 1 &&
1574 res->type == RTN_UNICAST && !fl4->flowi4_oif)
1575 fib_select_default(fl4, res);
1576
1577 if (!fl4->saddr)
1578 fl4->saddr = FIB_RES_PREFSRC(net, *res);
1579}
1580EXPORT_SYMBOL_GPL(fib_select_path);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 54297d3a0559..54e6f456a760 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2238,21 +2238,7 @@ struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
2238 goto make_route; 2238 goto make_route;
2239 } 2239 }
2240 2240
2241#ifdef CONFIG_IP_ROUTE_MULTIPATH 2241 fib_select_path(net, &res, fl4, mp_hash);
2242 if (res.fi->fib_nhs > 1 && fl4->flowi4_oif == 0) {
2243 if (mp_hash < 0)
2244 mp_hash = fib_multipath_hash(fl4->saddr, fl4->daddr);
2245 fib_select_multipath(&res, mp_hash);
2246 }
2247 else
2248#endif
2249 if (!res.prefixlen &&
2250 res.table->tb_num_default > 1 &&
2251 res.type == RTN_UNICAST && !fl4->flowi4_oif)
2252 fib_select_default(fl4, &res);
2253
2254 if (!fl4->saddr)
2255 fl4->saddr = FIB_RES_PREFSRC(net, res);
2256 2242
2257 dev_out = FIB_RES_DEV(res); 2243 dev_out = FIB_RES_DEV(res);
2258 fl4->flowi4_oif = dev_out->ifindex; 2244 fl4->flowi4_oif = dev_out->ifindex;