Skip to content

Commit d6f64d7

Browse files
Mark Tomlinsondavem330
authored andcommitted
net: VRF: Pass original iif to ip_route_input()
The function ip_rcv_finish() calls l3mdev_ip_rcv(). On any VRF except the global VRF, this replaces skb->dev with the VRF master interface. When calling ip_route_input_noref() from here, the checks for forwarding look at this master device instead of the initial ingress interface. This will allow packets to be routed which normally would be dropped. For example, an interface that is not assigned an IP address should drop packets, but because the checking is against the master device, the packet will be forwarded. The fix here is to still call l3mdev_ip_rcv(), but remember the initial net_device. This is passed to the other functions within ip_rcv_finish, so they still see the original interface. Signed-off-by: Mark Tomlinson <[email protected]> Acked-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7106a06 commit d6f64d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv4/ip_input.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
312312
{
313313
const struct iphdr *iph = ip_hdr(skb);
314314
struct rtable *rt;
315+
struct net_device *dev = skb->dev;
315316

316317
/* if ingress device is enslaved to an L3 master device pass the
317318
* skb to its handler for processing
@@ -341,7 +342,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
341342
*/
342343
if (!skb_valid_dst(skb)) {
343344
int err = ip_route_input_noref(skb, iph->daddr, iph->saddr,
344-
iph->tos, skb->dev);
345+
iph->tos, dev);
345346
if (unlikely(err)) {
346347
if (err == -EXDEV)
347348
__NET_INC_STATS(net, LINUX_MIB_IPRPFILTER);
@@ -370,7 +371,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
370371
__IP_UPD_PO_STATS(net, IPSTATS_MIB_INBCAST, skb->len);
371372
} else if (skb->pkt_type == PACKET_BROADCAST ||
372373
skb->pkt_type == PACKET_MULTICAST) {
373-
struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
374+
struct in_device *in_dev = __in_dev_get_rcu(dev);
374375

375376
/* RFC 1122 3.3.6:
376377
*

0 commit comments

Comments
 (0)