aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2017-01-10 17:37:35 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-11 09:59:55 -0500
commit7a18c5b9fb31a999afc62b0e60978aa896fc89e9 (patch)
tree3f903f4e1515788b2d85c8c0ed1d4120fb01b8f7
parent73b351473547e543e9c8166dd67fd99c64c15b0b (diff)
net: ipv4: Fix multipath selection with vrf
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: 613d09b30f8b ("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>
-rw-r--r--drivers/net/vrf.c2
-rw-r--r--net/ipv4/fib_semantics.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 23dfb0eac098..0a067708aa39 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -263,7 +263,9 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
263 .flowi4_iif = LOOPBACK_IFINDEX, 263 .flowi4_iif = LOOPBACK_IFINDEX,
264 .flowi4_tos = RT_TOS(ip4h->tos), 264 .flowi4_tos = RT_TOS(ip4h->tos),
265 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_SKIP_NH_OIF, 265 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_SKIP_NH_OIF,
266 .flowi4_proto = ip4h->protocol,
266 .daddr = ip4h->daddr, 267 .daddr = ip4h->daddr,
268 .saddr = ip4h->saddr,
267 }; 269 };
268 struct net *net = dev_net(vrf_dev); 270 struct net *net = dev_net(vrf_dev);
269 struct rtable *rt; 271 struct rtable *rt;
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 7a5b4c7d9a87..eba1546b5031 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1618,8 +1618,13 @@ void fib_select_multipath(struct fib_result *res, int hash)
1618void fib_select_path(struct net *net, struct fib_result *res, 1618void fib_select_path(struct net *net, struct fib_result *res,
1619 struct flowi4 *fl4, int mp_hash) 1619 struct flowi4 *fl4, int mp_hash)
1620{ 1620{
1621 bool oif_check;
1622
1623 oif_check = (fl4->flowi4_oif == 0 ||
1624 fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF);
1625
1621#ifdef CONFIG_IP_ROUTE_MULTIPATH 1626#ifdef CONFIG_IP_ROUTE_MULTIPATH
1622 if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) { 1627 if (res->fi->fib_nhs > 1 && oif_check) {
1623 if (mp_hash < 0) 1628 if (mp_hash < 0)
1624 mp_hash = get_hash_from_flowi4(fl4) >> 1; 1629 mp_hash = get_hash_from_flowi4(fl4) >> 1;
1625 1630
@@ -1629,7 +1634,7 @@ void fib_select_path(struct net *net, struct fib_result *res,
1629#endif 1634#endif
1630 if (!res->prefixlen && 1635 if (!res->prefixlen &&
1631 res->table->tb_num_default > 1 && 1636 res->table->tb_num_default > 1 &&
1632 res->type == RTN_UNICAST && !fl4->flowi4_oif) 1637 res->type == RTN_UNICAST && oif_check)
1633 fib_select_default(fl4, res); 1638 fib_select_default(fl4, res);
1634 1639
1635 if (!fl4->saddr) 1640 if (!fl4->saddr)