Skip to content

Commit 63b11e7

Browse files
Brenden Blancodavem330
authored andcommitted
ipvlan: read direct ifindex instead of iflink
In the ipv4 outbound path of an ipvlan device in l3 mode, the ifindex is being grabbed from dev_get_iflink. This works for the physical device case, since as the documentation of that function notes: "Physical interfaces have the same 'ifindex' and 'iflink' values.". However, if the master device is a veth, and the pairs are in separate net namespaces, the route lookup will fail with -ENODEV due to outer veth pair being in a separate namespace from the ipvlan master/routing namespace. ns0 | ns1 | ns2 veth0a--|--veth0b--|--ipvl0 In ipvlan_process_v4_outbound(), a packet sent from ipvl0 in the above configuration will pass fl.flowi4_oif == veth0a to ip_route_output_flow(), but *net == ns1. Notice also that ipv6 processing is not using iflink. Since there is a discrepancy in usage, fixup both v4 and v6 case to use local dev variable. Tested this with l3 ipvlan on top of veth, as well as with single physical interface in the top namespace. Signed-off-by: Brenden Blanco <bblanco@plumgrid.com> Reviewed-by: Jiri Benc <jbenc@redhat.com> Acked-by: Mahesh Bandewar <maheshb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dbf650b commit 63b11e7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
348348
struct rtable *rt;
349349
int err, ret = NET_XMIT_DROP;
350350
struct flowi4 fl4 = {
351-
.flowi4_oif = dev_get_iflink(dev),
351+
.flowi4_oif = dev->ifindex,
352352
.flowi4_tos = RT_TOS(ip4h->tos),
353353
.flowi4_flags = FLOWI_FLAG_ANYSRC,
354354
.daddr = ip4h->daddr,
@@ -386,7 +386,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
386386
struct dst_entry *dst;
387387
int err, ret = NET_XMIT_DROP;
388388
struct flowi6 fl6 = {
389-
.flowi6_iif = skb->dev->ifindex,
389+
.flowi6_iif = dev->ifindex,
390390
.daddr = ip6h->daddr,
391391
.saddr = ip6h->saddr,
392392
.flowi6_flags = FLOWI_FLAG_ANYSRC,

0 commit comments

Comments
 (0)