Skip to content

Commit c177d49

Browse files
David Aherngregkh
authored andcommitted
net: ipv4: Fix multipath selection with vrf
[ Upstream commit 7a18c5b9fb31a999afc62b0e60978aa896fc89e9 ] 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: 613d09b ("net: Use VRF device index for lookups on TX") Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 67b2197 commit c177d49

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/net/vrf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
301301
.flowi4_tos = RT_TOS(ip4h->tos),
302302
.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC |
303303
FLOWI_FLAG_SKIP_NH_OIF,
304+
.flowi4_proto = ip4h->protocol,
304305
.daddr = ip4h->daddr,
306+
.saddr = ip4h->saddr,
305307
};
306308

307309
if (vrf_send_v4_prep(skb, &fl4, vrf_dev))

net/ipv4/fib_semantics.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,13 @@ void fib_select_multipath(struct fib_result *res, int hash)
15881588
void fib_select_path(struct net *net, struct fib_result *res,
15891589
struct flowi4 *fl4, int mp_hash)
15901590
{
1591+
bool oif_check;
1592+
1593+
oif_check = (fl4->flowi4_oif == 0 ||
1594+
fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF);
1595+
15911596
#ifdef CONFIG_IP_ROUTE_MULTIPATH
1592-
if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) {
1597+
if (res->fi->fib_nhs > 1 && oif_check) {
15931598
if (mp_hash < 0)
15941599
mp_hash = get_hash_from_flowi4(fl4) >> 1;
15951600

@@ -1599,7 +1604,7 @@ void fib_select_path(struct net *net, struct fib_result *res,
15991604
#endif
16001605
if (!res->prefixlen &&
16011606
res->table->tb_num_default > 1 &&
1602-
res->type == RTN_UNICAST && !fl4->flowi4_oif)
1607+
res->type == RTN_UNICAST && oif_check)
16031608
fib_select_default(fl4, res);
16041609

16051610
if (!fl4->saddr)

0 commit comments

Comments
 (0)