diff mbox

[V2,4/6] net/socket.c: Add vnet packet support in net_socket_receive()

Message ID 1492670346-18004-5-git-send-email-zhangchen.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang Chen April 20, 2017, 6:39 a.m. UTC
Because of net_socket_send() add vnet header length argument,
Avoid conflict with net_socket_send().

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 net/socket.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/net/socket.c b/net/socket.c
index fe3547b..1f1f3d2 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -33,6 +33,7 @@ 
 #include "qemu/sockets.h"
 #include "qemu/iov.h"
 #include "qemu/main-loop.h"
+#include "hw/virtio/virtio-net.h"
 
 typedef struct NetSocketState {
     NetClientState nc;
@@ -81,12 +82,17 @@  static void net_socket_writable(void *opaque)
 static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 {
     NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
+    VirtIONet *n = qemu_get_nic_opaque(nc->peer);
     uint32_t len = htonl(size);
+    uint32_t vnet_hdr_len = htonl(n->guest_hdr_len);
     struct iovec iov[] = {
         {
             .iov_base = &len,
             .iov_len  = sizeof(len),
         }, {
+            .iov_base = &vnet_hdr_len,
+            .iov_len  = sizeof(vnet_hdr_len),
+        }, {
             .iov_base = (void *)buf,
             .iov_len  = size,
         },