Patchwork net: initialize vnet_hdr in net_tap_init()

login
register
mail settings
Submitter Mark McLoughlin
Date Nov. 24, 2009, 10:05 a.m.
Message ID <1259057104.8935.18.camel@blaa>
Download mbox | patch
Permalink /patch/39197/
State New
Headers show

Comments

Mark McLoughlin - Nov. 24, 2009, 10:05 a.m.
Hi Pierre,

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.

Thanks for the patch, but I'd prefer us to make sure we catch all cases.

Does this work for you?

Thanks,
Mark.

From: Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH] net: initialize vnet_hdr in net_tap_init()

Don't assume that all tap_open() implementations will set it to
zero if VNET_HDR support isn't found.

Fixes tap networking on host kernels lacking IFF_VNET_HDR support.

Reported-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 net/tap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Pierre Riteau - Nov. 24, 2009, 10:24 a.m.
On 24 nov. 2009, at 11:05, Mark McLoughlin wrote:

> Hi Pierre,
> 
> 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.
> 
> Thanks for the patch, but I'd prefer us to make sure we catch all cases.
> 
> Does this work for you?
> 
> Thanks,
> Mark.

No it doesn't fix the problem, since vnet_hdr is then changed to 1 in net_tap_init by this line, just before calling tap_open:

    *vnet_hdr = qemu_opt_get_bool(opts, "vnet_hdr", 1);

I run qemu like this: sudo qemu -m 1024 -hda /mnt/hda.img -net nic,macaddr=DE:AD:BE:EF:69:25 -net tap,script=/home/priteau/qemu-ifup -boot c -vnc 0:0

Patch

diff --git a/net/tap.c b/net/tap.c
index d34feec..7fb9e16 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -378,7 +378,7 @@  static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
 int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
 {
     TAPState *s;
-    int fd, vnet_hdr;
+    int fd, vnet_hdr = 0;
 
     if (qemu_opt_get(opts, "fd")) {
         if (qemu_opt_get(opts, "ifname") ||