diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2015-10-05 08:51:25 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-07 04:27:44 -0700 |
commit | 3ce58d84358c7b477811b5100152fad848f936fc (patch) | |
tree | be2bfdfeddad87ab8f9374e91063213982e24ffa /net/ipv4/fib_semantics.c | |
parent | fee6d4c777a125e56de9370db3b2bf359bf958d6 (diff) | |
download | lwn-3ce58d84358c7b477811b5100152fad848f936fc.tar.gz lwn-3ce58d84358c7b477811b5100152fad848f936fc.zip |
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>
Diffstat (limited to 'net/ipv4/fib_semantics.c')
-rw-r--r-- | net/ipv4/fib_semantics.c | 21 |
1 files changed, 21 insertions, 0 deletions
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) res->nh_sel = 0; } #endif + +void fib_select_path(struct net *net, struct fib_result *res, + struct flowi4 *fl4, int mp_hash) +{ +#ifdef CONFIG_IP_ROUTE_MULTIPATH + if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) { + if (mp_hash < 0) + mp_hash = fib_multipath_hash(fl4->saddr, fl4->daddr); + fib_select_multipath(res, mp_hash); + } + else +#endif + if (!res->prefixlen && + res->table->tb_num_default > 1 && + res->type == RTN_UNICAST && !fl4->flowi4_oif) + fib_select_default(fl4, res); + + if (!fl4->saddr) + fl4->saddr = FIB_RES_PREFSRC(net, *res); +} +EXPORT_SYMBOL_GPL(fib_select_path); |