Skip to content

Commit

Permalink
Pull a transport header only if one is present
Browse files Browse the repository at this point in the history
When packets arrive from a vm/fabric, we try to pull all data till
the first 8 bytes of a transport header into the first buffer so
that linear access to data is possible (keys to flow is what we
look for in the transport header). We do this operation
without checking whether the packet is a fragment or not and such
an unconditional attempt at pull can result in pull failures for
fragments whose data length is less that 8.

Hence, pull only for packets that have a valid transport header and
that has a trapsort protocol we recognize.

Change-Id: Iaf8ec480bef045c774630a7c0cc9afbc867a6062
Closes-BUG: #1460218
  • Loading branch information
anandhk-juniper committed Jun 3, 2015
1 parent c312539 commit 3b71933
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions linux/vr_host_interface.c
Expand Up @@ -941,6 +941,7 @@ static int
linux_pull_outer_headers(struct sk_buff *skb)
{
struct vlan_hdr *vhdr;
bool thdr = false, pull = false;
uint16_t proto, offset, ip_proto = 0;
struct iphdr *iph = NULL;
struct ipv6hdr *ip6h = NULL;
Expand Down Expand Up @@ -969,8 +970,9 @@ linux_pull_outer_headers(struct sk_buff *skb)
if (!pskb_may_pull(skb, offset))
goto pull_fail;
iph = ip_hdr(skb);
if (linux_ip_proto_pull(iph) &&
vr_ip_transport_header_valid((struct vr_ip *)iph)) {
thdr = vr_ip_transport_header_valid((struct vr_ip *)iph);
pull = linux_ip_proto_pull(iph);
if (pull && thdr) {
ip_proto = iph->protocol;
}
} else if (proto == htons(ETH_P_IPV6)) {
Expand All @@ -981,8 +983,9 @@ linux_pull_outer_headers(struct sk_buff *skb)
goto pull_fail;

ip6h = ipv6_hdr(skb);

if (linux_ipv6_proto_pull(ip6h)) {
thdr = true;
pull = linux_ipv6_proto_pull(ip6h);
if (pull) {
ip_proto = ip6h->nexthdr;
}
} else if (proto == htons(ETH_P_ARP)) {
Expand All @@ -991,7 +994,7 @@ linux_pull_outer_headers(struct sk_buff *skb)
goto pull_fail;
}

if (iph || ip6h) {
if (thdr && pull && (iph || ip6h)) {
/*
* this covers both regular port number offsets that come in
* the first 4 bytes and the icmp header
Expand Down

0 comments on commit 3b71933

Please sign in to comment.