All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shan Wei <shanwei@cn.fujitsu.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Herbert Xu" <herbert@gondor.hengli.com.au>,
	netdev@vger.kernel.org,
	"Ben Hutchings" <bhutchings@solarflare.com>
Subject: Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG
Date: Thu, 05 May 2011 17:34:43 +0800	[thread overview]
Message-ID: <4DC26F33.8010700@cn.fujitsu.com> (raw)
In-Reply-To: <20110505084428.GB17647@redhat.com>

Michael S. Tsirkin wrote, at 05/05/2011 04:44 PM:
> On Thu, May 05, 2011 at 01:28:54AM +0200, Michał Mirosław wrote:
>> On Thu, May 05, 2011 at 08:34:15AM +1000, Herbert Xu wrote:
>>> On Wed, May 04, 2011 at 09:18:14PM +0300, Michael S. Tsirkin wrote:
>>>> BTW, I just noticed that net-next spits out
>>>> many of the following when I run any VMs:
>>>>
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Features changed: 0x401b4849 -> 0x40004040
>>>> device msttap0 entered promiscuous mode
>>>> br0: Dropping NETIF_F_GSO since no SG feature.
>>>> br0: port 1(msttap0) entering forwarding state
>>>> br0: port 1(msttap0) entering forwarding state
>>>> tap0: Features changed: 0x40004040 -> 0x40024849
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Features changed: 0x40024849 -> 0x40004040
>>>> br0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Features changed: 0x40004040 -> 0x401b4849
>>>> tap0: Dropping NETIF_F_SG since no checksum feature.
>>>> tap0: Dropping NETIF_F_GSO since no SG feature.
>>>> tap0: Features changed: 0x401b4849 -> 0x40004040
>>>> br0: Dropping NETIF_F_GSO since no SG feature.
>>>>
>>>> My problem is not primarily with warnings:
>>>>
>>>> will that linearize all packets and disable GSO
>>>> for tap and bridge? If yes it can't be good
>>>> for performance...
>>> I think so.  So the question is why is checksum off?
>>
>> Whatever application is creating the tap0 device is not calling
>> ioctl(TUNSETOFFLOAD) with TUN_F_CSUM set. This is userspace bug/feature
>> exposed by recent changes to netdev features handling.
>>
>> Best Regards,
>> Michał Mirosław
> 
> No, I think it's not a bug in userspace. Here is what it does:
> 
>     /* Check if our kernel supports TUNSETOFFLOAD */
>     if (ioctl(fd, TUNSETOFFLOAD, 0) != 0 && errno == EINVAL) {
>         return;
>     }
> 
>     if (csum) {
>         offload |= TUN_F_CSUM;
>         if (tso4)
>             offload |= TUN_F_TSO4;
>         if (tso6)
>             offload |= TUN_F_TSO6;
>         if ((tso4 || tso6) && ecn)
>             offload |= TUN_F_TSO_ECN;
>         if (ufo)
>             offload |= TUN_F_UFO;
>     }
> 
>     if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
>         offload &= ~TUN_F_UFO;
>         if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
>             fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
>                     strerror(errno));
>         }
>     }
> 
> The first call is just to check that ioctl works.
> When checking for ioctl in this way, userspace clears checksum.
> This will clear SG and thus GSO; later userspace enables checksum.
> checksum is on but SG is by now disabled so GSO gets cleared again too.
> 
> 
> It's also likely a problem that
> userspace can trigger warnings in log for what used to be
> a legal way to check for ioctl and/or disable checksum offloading,
> but that is more minor.

Maybe it's a kernel bug. Can you try following changes?

TUN_F_TSO4, TUN_F_TSO6, TUN_F_TSO_ECN, TUN_F_UFO these features are 
depend on NETIF_F_SG. If NETIF_F_SG is not set, these features are not be
enabled and  warnings are printed in netdev_fix_features().


diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 0636f70..eea92e0 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1178,7 +1178,7 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
        u32 features = 0;
 
        if (arg & TUN_F_CSUM) {
-               features |= NETIF_F_HW_CSUM;
+               features |= NETIF_F_HW_CSUM | NETIF_F_SG;
                arg &= ~TUN_F_CSUM;
 
                if (arg & (TUN_F_TSO4|TUN_F_TSO6)) {


-- 
Best Regards
-----
Shan Wei

  reply	other threads:[~2011-05-05  9:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04 18:18 tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG Michael S. Tsirkin
2011-05-04 22:34 ` Herbert Xu
2011-05-04 23:28   ` Michał Mirosław
2011-05-05  0:19     ` Herbert Xu
2011-05-05  8:44     ` Michael S. Tsirkin
2011-05-05  9:34       ` Shan Wei [this message]
2011-05-05 10:05         ` Herbert Xu
2011-05-16  7:32           ` Michael S. Tsirkin
2011-05-16  8:07             ` Herbert Xu
2011-05-16  8:18               ` Michael S. Tsirkin
2011-05-16  9:38                 ` Herbert Xu
2011-05-16  9:48                   ` Michael S. Tsirkin
2011-05-16 10:43                     ` Herbert Xu
2011-05-16 11:21                       ` Michael S. Tsirkin
2011-05-16 12:18                         ` Herbert Xu
2011-05-16 12:24                           ` Michał Mirosław
2011-05-16 22:46                             ` Herbert Xu
2011-05-16 23:06                               ` David Miller
2011-05-16 23:45                                 ` Herbert Xu
2011-05-17  5:18                                   ` Michael S. Tsirkin
2011-05-17  5:24                                     ` Herbert Xu
2011-05-17  5:48                                       ` Michael S. Tsirkin
2011-05-17  6:25                                         ` Herbert Xu
2011-05-17  8:08                               ` Michał Mirosław
2011-05-17  8:15                                 ` Michał Mirosław
2011-05-17  8:19                                 ` [PATCH] net: tuntap: Fix tun_net_fix_features() Michał Mirosław
2011-05-17 14:29                                   ` Michael S. Tsirkin
2011-05-17 14:46                                     ` Michał Mirosław
2011-05-17 14:54                                       ` Michael S. Tsirkin
2011-05-17 15:00                                         ` Michał Mirosław
2011-05-17 15:11                                           ` Michael S. Tsirkin
2011-06-01  9:25                                   ` Michael S. Tsirkin
2011-06-20 19:14                                   ` [RESENT PATCH] " Michał Mirosław
2011-06-20 19:25                                     ` Ben Hutchings
2011-06-20 19:44                                       ` Michał Mirosław
2011-05-16 10:53                     ` tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG Michał Mirosław
2011-05-16  8:28               ` Michael S. Tsirkin
2011-05-05 15:26 ` Michał Mirosław
2011-05-14  6:54   ` Shan Wei
2011-05-16  7:28   ` Michael S. Tsirkin

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=4DC26F33.8010700@cn.fujitsu.com \
    --to=shanwei@cn.fujitsu.com \
    --cc=bhutchings@solarflare.com \
    --cc=herbert@gondor.hengli.com.au \
    --cc=mirq-linux@rere.qmqm.pl \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.