Commit c177d491 authored by David Ahern's avatar David Ahern Committed by Greg Kroah-Hartman

net: ipv4: Fix multipath selection with vrf

[ Upstream commit 7a18c5b9 ]

fib_select_path does not call fib_select_multipath if oif is set in the
flow struct. For VRF use cases oif is always set, so multipath route
selection is bypassed. Use the FLOWI_FLAG_SKIP_NH_OIF to skip the oif
check similar to what is done in fib_table_lookup.

Add saddr and proto to the flow struct for the fib lookup done by the
VRF driver to better match hash computation for a flow.

Fixes: 613d09b3 ("net: Use VRF device index for lookups on TX")
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 67b21973
...@@ -301,7 +301,9 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb, ...@@ -301,7 +301,9 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
.flowi4_tos = RT_TOS(ip4h->tos), .flowi4_tos = RT_TOS(ip4h->tos),
.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC | .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC |
FLOWI_FLAG_SKIP_NH_OIF, FLOWI_FLAG_SKIP_NH_OIF,
.flowi4_proto = ip4h->protocol,
.daddr = ip4h->daddr, .daddr = ip4h->daddr,
.saddr = ip4h->saddr,
}; };
if (vrf_send_v4_prep(skb, &fl4, vrf_dev)) if (vrf_send_v4_prep(skb, &fl4, vrf_dev))
......
...@@ -1588,8 +1588,13 @@ void fib_select_multipath(struct fib_result *res, int hash) ...@@ -1588,8 +1588,13 @@ void fib_select_multipath(struct fib_result *res, int hash)
void fib_select_path(struct net *net, struct fib_result *res, void fib_select_path(struct net *net, struct fib_result *res,
struct flowi4 *fl4, int mp_hash) struct flowi4 *fl4, int mp_hash)
{ {
bool oif_check;
oif_check = (fl4->flowi4_oif == 0 ||
fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF);
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) { if (res->fi->fib_nhs > 1 && oif_check) {
if (mp_hash < 0) if (mp_hash < 0)
mp_hash = get_hash_from_flowi4(fl4) >> 1; mp_hash = get_hash_from_flowi4(fl4) >> 1;
...@@ -1599,7 +1604,7 @@ void fib_select_path(struct net *net, struct fib_result *res, ...@@ -1599,7 +1604,7 @@ void fib_select_path(struct net *net, struct fib_result *res,
#endif #endif
if (!res->prefixlen && if (!res->prefixlen &&
res->table->tb_num_default > 1 && res->table->tb_num_default > 1 &&
res->type == RTN_UNICAST && !fl4->flowi4_oif) res->type == RTN_UNICAST && oif_check)
fib_select_default(fl4, res); fib_select_default(fl4, res);
if (!fl4->saddr) if (!fl4->saddr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment