From patchwork Thu May 5 09:34:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shan Wei X-Patchwork-Id: 94214 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 19BD8B6FDA for ; Thu, 5 May 2011 19:42:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753354Ab1EEJmq (ORCPT ); Thu, 5 May 2011 05:42:46 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:56305 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752545Ab1EEJmp convert rfc822-to-8bit (ORCPT ); Thu, 5 May 2011 05:42:45 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 01986170151; Thu, 5 May 2011 17:42:44 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p459gh6G001075; Thu, 5 May 2011 17:42:43 +0800 Received: from [10.167.225.31] ([10.167.225.31]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011050517385298-205882 ; Thu, 5 May 2011 17:38:52 +0800 Message-ID: <4DC26F33.8010700@cn.fujitsu.com> Date: Thu, 05 May 2011 17:34:43 +0800 From: Shan Wei User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13pre) Gecko/20101113 Shredder/3.1.7pre MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Herbert Xu , netdev@vger.kernel.org, Ben Hutchings Subject: Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG References: <20110504181813.GA17547@redhat.com> <20110504223415.GA14819@gondor.apana.org.au> <20110504232854.GA11687@rere.qmqm.pl> <20110505084428.GB17647@redhat.com> In-Reply-To: <20110505084428.GB17647@redhat.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-05-05 17:38:53, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-05-05 17:43:04 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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)) {