From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NCtWi-0007Ts-Mb for qemu-devel@nongnu.org; Tue, 24 Nov 2009 06:25:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NCtWd-0007Pe-HL for qemu-devel@nongnu.org; Tue, 24 Nov 2009 06:25:43 -0500 Received: from [199.232.76.173] (port=44035 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCtWd-0007PE-0o for qemu-devel@nongnu.org; Tue, 24 Nov 2009 06:25:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45614) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NCtWb-0000sc-Vi for qemu-devel@nongnu.org; Tue, 24 Nov 2009 06:25:38 -0500 Subject: Re: [Qemu-devel] Re: [PATCH] Fix TAP networking on host kernels without IFF_VNET_HDR support From: Mark McLoughlin In-Reply-To: References: <1259053593-15362-1-git-send-email-Pierre.Riteau@irisa.fr> <1259058521.8935.21.camel@blaa> Content-Type: text/plain; charset="UTF-8" Date: Tue, 24 Nov 2009 11:22:52 +0000 Message-Id: <1259061772.8935.29.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Reply-To: Mark McLoughlin List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pierre Riteau Cc: qemu-devel@nongnu.org On Tue, 2009-11-24 at 12:17 +0100, Pierre Riteau wrote: > On 24 nov. 2009, at 11:28, Mark McLoughlin wrote: > > > On Tue, 2009-11-24 at 10:06 +0100, Pierre Riteau wrote: > >> vnet_hdr is initialized at 1 by default. We need to reset it to 0 if > >> the kernel doesn't support IFF_VNET_HDR. > >> > >> Signed-off-by: Pierre Riteau > > > > Thanks Pierre, I see why this is needed now > > > > Acked-by: Mark McLoughlin > > > > Cheers, > > Mark. > > > Thanks for your rapid answer! > > BTW, every time I run qemu I see this error message: > > TUNSETOFFLOAD ioctl() failed: Invalid argument > > It is caused by the piece of code at the end of net/tap-linux.c: > > 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)); > } > } > > Isn't there a way to detect whether the kernel supports the > TUNSETOFFLOAD ioctl at all? The kernel will set errno to EINVAL if TUNSETOFFLOAD isn't supported, so we could just ignore that case: if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { offload &= ~TUN_F_UFO; if (ioctl(fd, TUNSETOFFLOAD, offload) != 0 && errno != EINVAL) { fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", strerror(errno)); } } The only concern is that we'll also miss out on an error message if EINVAL is set for another reason. Currently, the only other reason if we pass a offload flag not supported by the kernel, but that should never happen. Feel free to send a patch with that change and I'll ack it Thanks, Mark.