Skip to contentSkip to conversation

tap: reset vnet header size on open

PATCH Applied Michael S. Tsirkin 3 participants 3 messages Nov 13, 2012 – Nov 19, 2012 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tap: reset vnet header size on open

For tap, we currently assume the vnet header size is 10 (the default value) but that might not be the case if tap is persistent and has been used by qemu previously. To fix, set host header size in tap device on open.

---

This fixes the issue reported by Alexander Graf on the kvm forum. Alexander, could you confirm please?
Thanks,

 net/tap.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/tap.c +7 -0
index df89caa..1abfd44 100644
@@ -341,6 +341,13 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
     s->using_vnet_hdr = 0;
     s->has_ufo = tap_probe_has_ufo(s->fd);
     tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
+    /*
+     * Make sure host header length is set correctly in tap:
+     * it might have been modified by another instance of qemu.
+     */
+    if (tap_probe_vnet_hdr_len(s->fd, s->host_vnet_hdr_len)) {
+        tap_fd_set_vnet_hdr_len(s->fd, s->host_vnet_hdr_len);
+    }
     tap_read_poll(s, 1);
     s->vhost_net = NULL;
     return s;
Signature · 1 line
MST
#1 lore raw
Quoted 6 lines · Michael S. Tsirkin

For tap, we currently assume the vnet header size is 10 (the default value) but that might not be the case if tap is persistent and has been used by qemu previously. To fix, set host header size in tap device on open.

Quoted 8 lines

---

This fixes the issue reported by Alexander Graf on the kvm forum. Alexander, could you confirm please?
Thanks,

 net/tap.c | 7 +++++++
 1 file changed, 7 insertions(+)

Thanks, applied to the net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

Tested-by on v2 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin

For tap, we currently assume the vnet header size is 10 (the default value) but that might not be the case if tap is persistent and has been used by qemu previously. To fix, set host header size in tap device on open.

---

This fixes the issue reported by Alexander Graf on the kvm forum. Alexander, could you confirm please?

Yup, works for me :).

Alex

Quoted 25 lines

Thanks,

net/tap.c | 7 +++++++

1 file changed, 7 insertions(+)
net/tap.c +7 -0
index df89caa..1abfd44 100644
@@ -341,6 +341,13 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
    s->using_vnet_hdr = 0;
    s->has_ufo = tap_probe_has_ufo(s->fd);
    tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
+    /*
+     * Make sure host header length is set correctly in tap:
+     * it might have been modified by another instance of qemu.
+     */
+    if (tap_probe_vnet_hdr_len(s->fd, s->host_vnet_hdr_len)) {
+        tap_fd_set_vnet_hdr_len(s->fd, s->host_vnet_hdr_len);
+    }
    tap_read_poll(s, 1);
    s->vhost_net = NULL;
    return s;
Signature · 1 line
MST