From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jason Wang <jasowang@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, mst@redhat.com,
Eric Dumazet <edumazet@google.com>
Subject: Re: [net-next 2/5] tuntap: set transport header before passing it to kernel
Date: Tue, 26 Mar 2013 08:07:22 -0700 [thread overview]
Message-ID: <1364310442.1716.17.camel@edumazet-glaptop> (raw)
In-Reply-To: <1364278799-37285-3-git-send-email-jasowang@redhat.com>
On Tue, 2013-03-26 at 14:19 +0800, Jason Wang wrote:
> Currently, for the packets receives from tuntap, before doing header check,
> kernel just reset the transport header in netif_receive_skb() which pretends no
> l4 header. This is suboptimal for precise packet length estimation (introduced
> in 1def9238) which needs correct l4 header for gso packets.
>
> So this patch set the transport header to csum_start for partial checksum
> packets, otherwise it first try skb_flow_dissect(), if it fails, just reset the
> transport header.
>
> Cc: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> drivers/net/tun.c | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 95837c1..48cd73a 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -70,6 +70,7 @@
> #include <net/sock.h>
>
> #include <asm/uaccess.h>
> +#include <net/flow_keys.h>
>
> /* Uncomment to enable debugging */
> /* #define TUN_DEBUG 1 */
> @@ -1049,6 +1050,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> bool zerocopy = false;
> int err;
> u32 rxhash;
> + struct flow_keys keys;
>
> if (!(tun->flags & TUN_NO_PI)) {
> if ((len -= sizeof(pi)) > total_len)
> @@ -1203,6 +1205,14 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> }
>
> skb_reset_network_header(skb);
> +
> + if (skb->ip_summed == CHECKSUM_PARTIAL)
> + skb_set_transport_header(skb, skb_checksum_start_offset(skb));
> + else if (skb_flow_dissect(skb, &keys))
> + skb_set_transport_header(skb, keys.thoff);
> + else
> + skb_reset_transport_header(skb);
> +
> rxhash = skb_get_rxhash(skb);
> netif_rx_ni(skb);
>
Another call for a common helper.
next prev parent reply other threads:[~2013-03-26 15:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 6:19 [net-next 0/5] set transport header for untrusted packets Jason Wang
2013-03-26 6:19 ` [net-next 1/5] macvtap: set transport header before passing skb to lower device Jason Wang
2013-03-26 15:06 ` Eric Dumazet
2013-03-27 3:12 ` Jason Wang
2013-03-26 6:19 ` [net-next 2/5] tuntap: set transport header before passing it to kernel Jason Wang
2013-03-26 15:07 ` Eric Dumazet [this message]
2013-03-26 6:19 ` [net-next 3/5] packet: set transport header before doing xmit Jason Wang
2013-03-26 6:19 ` [net-next 4/5] netback: set transport header before passing it to kernel Jason Wang
2013-04-10 13:33 ` Ian Campbell
2013-04-11 6:37 ` Jason Wang
2013-03-26 6:19 ` [net-next 5/5] net_sched: better precise estimation on packet length for untrusted packets Jason Wang
2013-03-26 16:45 ` [net-next 0/5] set transport header " 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=1364310442.1716.17.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--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