Skip to content

Commit cd2fbe1

Browse files
David Aherndavem330
authored andcommitted
net: Use VRF device index for lookups on RX
On ingress use index of VRF master device for route lookups if real device is enslaved. Rules are expected to be installed for the VRF device to direct lookups to a specific table. Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4e3c899 commit cd2fbe1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

net/ipv4/fib_frontend.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <net/ip_fib.h>
4646
#include <net/rtnetlink.h>
4747
#include <net/xfrm.h>
48+
#include <net/vrf.h>
4849

4950
#ifndef CONFIG_IP_MULTIPLE_TABLES
5051

@@ -309,7 +310,9 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
309310
bool dev_match;
310311

311312
fl4.flowi4_oif = 0;
312-
fl4.flowi4_iif = oif ? : LOOPBACK_IFINDEX;
313+
fl4.flowi4_iif = vrf_master_ifindex_rcu(dev);
314+
if (!fl4.flowi4_iif)
315+
fl4.flowi4_iif = oif ? : LOOPBACK_IFINDEX;
313316
fl4.daddr = src;
314317
fl4.saddr = dst;
315318
fl4.flowi4_tos = tos;
@@ -339,6 +342,9 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
339342
if (nh->nh_dev == dev) {
340343
dev_match = true;
341344
break;
345+
} else if (vrf_master_ifindex_rcu(nh->nh_dev) == dev->ifindex) {
346+
dev_match = true;
347+
break;
342348
}
343349
}
344350
#else

net/ipv4/route.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#endif
113113
#include <net/secure_seq.h>
114114
#include <net/ip_tunnels.h>
115+
#include <net/vrf.h>
115116

116117
#define RT_FL_TOS(oldflp4) \
117118
((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))
@@ -1726,7 +1727,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
17261727
* Now we are ready to route packet.
17271728
*/
17281729
fl4.flowi4_oif = 0;
1729-
fl4.flowi4_iif = dev->ifindex;
1730+
fl4.flowi4_iif = vrf_master_ifindex_rcu(dev) ? : dev->ifindex;
17301731
fl4.flowi4_mark = skb->mark;
17311732
fl4.flowi4_tos = tos;
17321733
fl4.flowi4_scope = RT_SCOPE_UNIVERSE;

0 commit comments

Comments
 (0)