netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH 4/8] ipv4: Add GRO infrastructure
Date: Fri, 12 Dec 2008 22:55:40 +0000	[thread overview]
Message-ID: <1229122540.3051.78.camel@achroite> (raw)
In-Reply-To: <E1LB0cy-0000rD-Pr@gondolin.me.apana.org.au>

On Fri, 2008-12-12 at 16:31 +1100, Herbert Xu wrote:
[...]
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 1aa2dc9..260f081 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -94,6 +94,7 @@
>  #include <linux/igmp.h>
>  #include <linux/inetdevice.h>
>  #include <linux/netdevice.h>
> +#include <net/checksum.h>
>  #include <net/ip.h>
>  #include <net/protocol.h>
>  #include <net/arp.h>
> @@ -1245,6 +1246,99 @@ out:
>  	return segs;
>  }
>  
> +static struct sk_buff **inet_gro_receive(struct sk_buff **head,
> +					 struct sk_buff *skb)
> +{
> +	struct net_protocol *ops;
> +	struct sk_buff **pp = NULL;
> +	struct sk_buff *p;
> +	struct iphdr *iph;
> +	int flush = 1;
> +	int proto;
> +	int id;
> +
> +	if (unlikely(!pskb_may_pull(skb, sizeof(*iph))))
> +		goto out;
> +
> +	iph = ip_hdr(skb);
> +	proto = iph->protocol & (MAX_INET_PROTOS - 1);
> +
> +	rcu_read_lock();
> +	ops = rcu_dereference(inet_protos[proto]);
> +	if (!ops || !ops->gro_receive)
> +		goto out_unlock;
> +
> +	if (iph->version != 4 || iph->ihl != 5)
> +		goto out_unlock;
> +
> +	if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
> +		goto out_unlock;

Don't we also need to check that skb->len >= iph->ihl * 4?

> +	flush = ntohs(iph->tot_len) != skb->len ||
> +		iph->frag_off != htons(IP_DF);
> +	id = ntohs(iph->id);
> +
> +	for (p = *head; p; p = p->next) {
> +		struct iphdr *iph2;
> +
> +		if (!NAPI_GRO_CB(p)->same_flow)
> +			continue;
> +
> +		iph2 = ip_hdr(p);
> +
> +		if (iph->protocol != iph2->protocol ||
> +		    memcmp(&iph->saddr, &iph2->saddr, 8)) {
> +			NAPI_GRO_CB(p)->same_flow = 0;
> +			continue;
> +		}
> +
> +		/* All fields must match except length and checksum. */
> +		NAPI_GRO_CB(p)->flush |=
> +			memcmp(&iph->frag_off, &iph2->frag_off, 4) ||

This covers frag_off, ttl and protocol.  But frag_off and protocol have
already been covered, and tos seems to have been missed.

> +			(u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) != id;
> +		NAPI_GRO_CB(p)->flush |= flush;
> +	}
> +
> +	NAPI_GRO_CB(skb)->flush |= flush;
> +	__skb_pull(skb, sizeof(*iph));
> +	skb_reset_transport_header(skb);
> +
> +	pp = ops->gro_receive(head, skb);
> +
> +out_unlock:
> +	rcu_read_unlock();
> +
> +out:
> +	NAPI_GRO_CB(skb)->flush |= flush;
> +
> +	return pp;
> +}
[...]

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2008-12-12 22:55 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-12  5:31 [0/8] net: Generic Receive Offload Herbert Xu
2008-12-12  5:31 ` [PATCH 1/8] net: Add frag_list support to skb_segment Herbert Xu
2008-12-12 19:46   ` Evgeniy Polyakov
2008-12-12 21:41     ` Herbert Xu
2008-12-13  2:38       ` Evgeniy Polyakov
2008-12-13  2:43         ` Herbert Xu
2008-12-13  3:11           ` Evgeniy Polyakov
2008-12-13  3:20             ` Herbert Xu
2008-12-12  5:31 ` [PATCH 2/8] net: Add frag_list support to GSO Herbert Xu
2008-12-12  5:31 ` [PATCH 3/8] net: Add Generic Receive Offload infrastructure Herbert Xu
2008-12-12 19:51   ` Evgeniy Polyakov
2008-12-12 21:45     ` Herbert Xu
2008-12-12 22:25   ` Ben Hutchings
2008-12-12 22:56     ` Herbert Xu
2008-12-12 23:11       ` Herbert Xu
2008-12-13  3:43         ` Herbert Xu
2008-12-13 14:03           ` Evgeniy Polyakov
2008-12-12  5:31 ` [PATCH 4/8] ipv4: Add GRO infrastructure Herbert Xu
2008-12-12 22:55   ` Ben Hutchings [this message]
2008-12-12 23:04     ` Herbert Xu
2008-12-12  5:31 ` [PATCH 5/8] net: Add skb_gro_receive Herbert Xu
2008-12-12  5:31 ` [PATCH 6/8] tcp: Add GRO support Herbert Xu
2008-12-12 19:56   ` Evgeniy Polyakov
2008-12-12 21:46     ` Herbert Xu
2008-12-13  2:40       ` Evgeniy Polyakov
2008-12-13  2:46         ` Herbert Xu
2008-12-13  3:10           ` Evgeniy Polyakov
2008-12-13  3:19             ` Herbert Xu
2008-12-12  5:31 ` [PATCH 7/8] ethtool: Add GGRO and SGRO ops Herbert Xu
2008-12-12 20:11   ` Ben Hutchings
2008-12-12 21:48     ` Herbert Xu
2008-12-12 22:35       ` Ben Hutchings
2008-12-12 22:49         ` Herbert Xu
2008-12-14 19:36           ` Waskiewicz Jr, Peter P
2008-12-14 21:09             ` Herbert Xu
2008-12-14 22:00               ` Waskiewicz Jr, Peter P
2008-12-15  3:40                 ` Herbert Xu
2008-12-12  5:31 ` [PATCH 8/8] e1000e: Add GRO support Herbert Xu
2008-12-13  1:34 ` [0/8] net: Generic Receive Offload Herbert Xu
2008-12-13  1:35   ` [PATCH 1/8] net: Add frag_list support to skb_segment Herbert Xu
2008-12-16  7:27     ` David Miller
2008-12-13  1:35   ` [PATCH 2/8] net: Add frag_list support to GSO Herbert Xu
2008-12-16  7:30     ` David Miller
2008-12-13  1:35   ` [PATCH 3/8] net: Add Generic Receive Offload infrastructure Herbert Xu
2008-12-15 23:29     ` Paul E. McKenney
2008-12-15 23:39       ` David Miller
2008-12-16  0:02         ` Paul E. McKenney
2008-12-16  2:04         ` Herbert Xu
2008-12-16 16:37           ` Paul E. McKenney
2008-12-16  7:40     ` David Miller
2008-12-13  1:35   ` [PATCH 4/8] ipv4: Add GRO infrastructure Herbert Xu
2008-12-16  7:41     ` David Miller
2008-12-13  1:35   ` [PATCH 5/8] net: Add skb_gro_receive Herbert Xu
2008-12-13  2:52     ` Herbert Xu
2008-12-16  7:42       ` David Miller
2008-12-13  1:35   ` [PATCH 6/8] tcp: Add GRO support Herbert Xu
2008-12-16  7:43     ` David Miller
2008-12-13  1:35   ` [PATCH 7/8] ethtool: Add GGRO and SGRO ops Herbert Xu
2008-12-16  7:44     ` David Miller
2008-12-13  1:35   ` [PATCH 8/8] e1000e: Add GRO support Herbert Xu
2008-12-16  7:46     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1229122540.3051.78.camel@achroite \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).