From: Mark Tomlinson <hidden> Date: 2016-09-12 01:46:32
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.
Please note that while this patch fixes my issue, I am not entirely sure
why the skb->dev is changed to the master device, so I am not sure this
is the right fix.
Signed-off-by: Mark Tomlinson <redacted>
---
net/ipv4/ip_input.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -312,6 +312,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb){conststructiphdr*iph=ip_hdr(skb);structrtable*rt;+structnet_device*dev=skb->dev;/* if ingress device is enslaved to an L3 master device pass the*skbtoitshandlerforprocessing
@@ -341,7 +342,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)*/if(!skb_valid_dst(skb)){interr=ip_route_input_noref(skb,iph->daddr,iph->saddr,-iph->tos,skb->dev);+iph->tos,dev);if(unlikely(err)){if(err==-EXDEV)__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)__IP_UPD_PO_STATS(net,IPSTATS_MIB_INBCAST,skb->len);}elseif(skb->pkt_type==PACKET_BROADCAST||skb->pkt_type==PACKET_MULTICAST){-structin_device*in_dev=__in_dev_get_rcu(skb->dev);+structin_device*in_dev=__in_dev_get_rcu(dev);/* RFC 1122 3.3.6:*
From: David Ahern <hidden> Date: 2016-09-12 14:48:12
On 9/11/16 7:45 PM, Mark Tomlinson wrote:
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.
Please note that while this patch fixes my issue, I am not entirely sure
why the skb->dev is changed to the master device, so I am not sure this
is the right fix.
It is done for socket lookups. VRF can handle global sockets with connected sockets bound to the VRF domain (VRF device index) or sockets bound to the VRF device which requires inet_iif / skb_iif to be the VRF device.
With the changes to l3mdev to look at enslaved devices as well as master devices this change might be fine, but need to confirm.
Please cc me on VRF related patches or questions. I only scan netdev as time allows.
From: David Ahern <hidden> Date: 2016-09-14 19:29:49
On 9/11/16 7:45 PM, Mark Tomlinson wrote:
Please note that while this patch fixes my issue, I am not entirely sure
why the skb->dev is changed to the master device, so I am not sure this
is the right fix.
Can you send a v2 dropping the above paragraph from the commit log.
From: Mark Tomlinson <hidden> Date: 2016-09-14 23:40:25
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 <redacted>
Acked-by: David Ahern <redacted>
---
net/ipv4/ip_input.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -312,6 +312,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb){conststructiphdr*iph=ip_hdr(skb);structrtable*rt;+structnet_device*dev=skb->dev;/* if ingress device is enslaved to an L3 master device pass the*skbtoitshandlerforprocessing
@@ -341,7 +342,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)*/if(!skb_valid_dst(skb)){interr=ip_route_input_noref(skb,iph->daddr,iph->saddr,-iph->tos,skb->dev);+iph->tos,dev);if(unlikely(err)){if(err==-EXDEV)__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)__IP_UPD_PO_STATS(net,IPSTATS_MIB_INBCAST,skb->len);}elseif(skb->pkt_type==PACKET_BROADCAST||skb->pkt_type==PACKET_MULTICAST){-structin_device*in_dev=__in_dev_get_rcu(skb->dev);+structin_device*in_dev=__in_dev_get_rcu(dev);/* RFC 1122 3.3.6:*
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 <redacted>
Acked-by: David Ahern <redacted>