net: Move virtio-net header length assertion
The virtio-net header length assertion should happen for any clients.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
diff --git a/net/net.c b/net/net.c
index bd51037..db09676 100644
--- a/net/net.c
+++ b/net/net.c
@@ -56,6 +56,7 @@
#include "net/filter.h"
#include "qapi/string-output-visitor.h"
#include "qapi/qobject-input-visitor.h"
+#include "standard-headers/linux/virtio_net.h"
/* Net bridge is currently not supported for W32. */
#if !defined(_WIN32)
@@ -550,6 +551,10 @@
return;
}
+ assert(len == sizeof(struct virtio_net_hdr_mrg_rxbuf) ||
+ len == sizeof(struct virtio_net_hdr) ||
+ len == sizeof(struct virtio_net_hdr_v1_hash));
+
nc->vnet_hdr_len = len;
nc->info->set_vnet_hdr_len(nc, len);
}
diff --git a/net/tap.c b/net/tap.c
index c848844..49edf6c 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -267,9 +267,6 @@
TAPState *s = DO_UPCAST(TAPState, nc, nc);
assert(nc->info->type == NET_CLIENT_DRIVER_TAP);
- assert(len == sizeof(struct virtio_net_hdr_mrg_rxbuf) ||
- len == sizeof(struct virtio_net_hdr) ||
- len == sizeof(struct virtio_net_hdr_v1_hash));
tap_fd_set_vnet_hdr_len(s->fd, len);
s->host_vnet_hdr_len = len;