From: Peter Kosyh <hidden> Date: 2019-07-18 09:42:50
vrf_process_v4_outbound() and vrf_process_v6_outbound() do routing
using ip/ipv6 addresses, but don't make sure the header is available in
skb->data[] (skb_headlen() is less then header size).
The situation may occures while forwarding from MPLS layer to vrf, for
example.
So, this patch adds pskb_may_pull() calls in is_ip_tx_frame(), just before
call to vrf_process_... functions.
Signed-off-by: Peter Kosyh <redacted>
---
drivers/net/vrf.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
From: David Ahern <hidden> Date: 2019-07-18 14:02:50
your subject line needs a proper Subject - a one-line summary of the
change starting with 'vrf:'. See examples from 'git log drivers/net/vrf.c'
On 7/18/19 3:41 AM, Peter Kosyh wrote:
vrf_process_v4_outbound() and vrf_process_v6_outbound() do routing
using ip/ipv6 addresses, but don't make sure the header is available in
skb->data[] (skb_headlen() is less then header size).
The situation may occures while forwarding from MPLS layer to vrf, for
example.
so the use case is a label pop with the nexthop as the VRF device?
quoted hunk
So, this patch adds pskb_may_pull() calls in is_ip_tx_frame(), just before
call to vrf_process_... functions.
Signed-off-by: Peter Kosyh <redacted>
---
drivers/net/vrf.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
From: Peter Kosyh <hidden> Date: 2019-07-19 08:12:17
vrf_process_v4_outbound() and vrf_process_v6_outbound() do routing
using ip/ipv6 addresses, but don't make sure the header is available
in skb->data[] (skb_headlen() is less then header size).
Case:
1) igb driver from intel.
2) Packet size is greater then 255.
3) MPLS forwards to VRF device.
So, patch adds pskb_may_pull() calls in vrf_process_v4/v6_outbound()
functions.
Signed-off-by: Peter Kosyh <redacted>
---
drivers/net/vrf.c | 58 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 35 insertions(+), 23 deletions(-)
@@ -165,23 +165,29 @@ static int vrf_ip6_local_out(struct net *net, struct sock *sk,staticnetdev_tx_tvrf_process_v6_outbound(structsk_buff*skb,structnet_device*dev){-conststructipv6hdr*iph=ipv6_hdr(skb);+conststructipv6hdr*iph;structnet*net=dev_net(skb->dev);-structflowi6fl6={-/* needed to match OIF rule */-.flowi6_oif=dev->ifindex,-.flowi6_iif=LOOPBACK_IFINDEX,-.daddr=iph->daddr,-.saddr=iph->saddr,-.flowlabel=ip6_flowinfo(iph),-.flowi6_mark=skb->mark,-.flowi6_proto=iph->nexthdr,-.flowi6_flags=FLOWI_FLAG_SKIP_NH_OIF,-};+structflowi6fl6;intret=NET_XMIT_DROP;structdst_entry*dst;structdst_entry*dst_null=&net->ipv6.ip6_null_entry->dst;+if(!pskb_may_pull(skb,ETH_HLEN+sizeof(structipv6hdr)))+gotoerr;++iph=ipv6_hdr(skb);++memset(&fl6,0,sizeof(fl6));+/* needed to match OIF rule */+fl6.flowi6_oif=dev->ifindex;+fl6.flowi6_iif=LOOPBACK_IFINDEX;+fl6.daddr=iph->daddr;+fl6.saddr=iph->saddr;+fl6.flowlabel=ip6_flowinfo(iph);+fl6.flowi6_mark=skb->mark;+fl6.flowi6_proto=iph->nexthdr;+fl6.flowi6_flags=FLOWI_FLAG_SKIP_NH_OIF;+dst=ip6_route_output(net,NULL,&fl6);if(dst==dst_null)gotoerr;
@@ -237,21 +243,27 @@ static int vrf_ip_local_out(struct net *net, struct sock *sk,staticnetdev_tx_tvrf_process_v4_outbound(structsk_buff*skb,structnet_device*vrf_dev){-structiphdr*ip4h=ip_hdr(skb);+structiphdr*ip4h;intret=NET_XMIT_DROP;-structflowi4fl4={-/* needed to match OIF rule */-.flowi4_oif=vrf_dev->ifindex,-.flowi4_iif=LOOPBACK_IFINDEX,-.flowi4_tos=RT_TOS(ip4h->tos),-.flowi4_flags=FLOWI_FLAG_ANYSRC|FLOWI_FLAG_SKIP_NH_OIF,-.flowi4_proto=ip4h->protocol,-.daddr=ip4h->daddr,-.saddr=ip4h->saddr,-};+structflowi4fl4;structnet*net=dev_net(vrf_dev);structrtable*rt;+if(!pskb_may_pull(skb,ETH_HLEN+sizeof(structiphdr)))+gotoerr;++ip4h=ip_hdr(skb);++memset(&fl4,0,sizeof(fl4));+/* needed to match OIF rule */+fl4.flowi4_oif=vrf_dev->ifindex;+fl4.flowi4_iif=LOOPBACK_IFINDEX;+fl4.flowi4_tos=RT_TOS(ip4h->tos);+fl4.flowi4_flags=FLOWI_FLAG_ANYSRC|FLOWI_FLAG_SKIP_NH_OIF;+fl4.flowi4_proto=ip4h->protocol;+fl4.daddr=ip4h->daddr;+fl4.saddr=ip4h->saddr;+rt=ip_route_output_flow(net,&fl4,NULL);if(IS_ERR(rt))gotoerr;
From: David Ahern <hidden> Date: 2019-07-19 19:17:52
On 7/19/19 2:11 AM, Peter Kosyh wrote:
vrf_process_v4_outbound() and vrf_process_v6_outbound() do routing
using ip/ipv6 addresses, but don't make sure the header is available
in skb->data[] (skb_headlen() is less then header size).
Case:
1) igb driver from intel.
2) Packet size is greater then 255.
3) MPLS forwards to VRF device.
So, patch adds pskb_may_pull() calls in vrf_process_v4/v6_outbound()
functions.
Signed-off-by: Peter Kosyh <redacted>
---
drivers/net/vrf.c | 58 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 35 insertions(+), 23 deletions(-)
vrf_process_v4_outbound() and vrf_process_v6_outbound() do routing
using ip/ipv6 addresses, but don't make sure the header is available
in skb->data[] (skb_headlen() is less then header size).
Case:
1) igb driver from intel.
2) Packet size is greater then 255.
3) MPLS forwards to VRF device.
So, patch adds pskb_may_pull() calls in vrf_process_v4/v6_outbound()
functions.
Signed-off-by: Peter Kosyh <redacted>