qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support
@ 2017-04-20  6:39 Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 1/6] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support Zhang Chen
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

If user use -device virtio-net-pci, virtio-net driver will add a header
to raw net packet that colo-proxy can't handle it. COLO-proxy just
focus on the packet payload, so we skip the virtio-net header to compare
the sent packet that primary guest's to secondary guest's.

Zhang Chen (6):
  net/filter-mirror.c: Add filter-mirror and filter-redirector vnet
    support.
  net/net.c: Add vnet header length to SocketReadState
  net/colo-compare.c: Make colo-compare support vnet_hdr_len
  net/socket.c: Add vnet packet support in net_socket_receive()
  net/colo.c: Add vnet packet parse feature in colo-proxy
  net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare

 include/net/net.h     |  4 +++-
 net/colo-compare.c    | 48 +++++++++++++++++++++++++++++++++++++++---------
 net/colo.c            |  9 +++++----
 net/colo.h            |  4 +++-
 net/filter-mirror.c   | 25 ++++++++++++++++++++-----
 net/filter-rewriter.c |  2 +-
 net/net.c             | 24 ++++++++++++++++++++++--
 net/socket.c          |  6 ++++++
 8 files changed, 99 insertions(+), 23 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH V2 1/6] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support.
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
@ 2017-04-20  6:39 ` Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 2/6] net/net.c: Add vnet header length to SocketReadState Zhang Chen
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

In this patch, we change the send packet format from
struct {int size; const uint8_t buf[];} to {int size; int vnet_hdr_len; const uint8_t buf[];}.
make other module(like colo-compare) know how to parse net packet correctly.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 net/filter-mirror.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/net/filter-mirror.c b/net/filter-mirror.c
index 72fa7c2..5b4d616 100644
--- a/net/filter-mirror.c
+++ b/net/filter-mirror.c
@@ -23,6 +23,7 @@
 #include "sysemu/char.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
+#include "hw/virtio/virtio-net.h"
 
 #define FILTER_MIRROR(obj) \
     OBJECT_CHECK(MirrorState, (obj), TYPE_FILTER_MIRROR)
@@ -43,12 +44,15 @@ typedef struct MirrorState {
     SocketReadState rs;
 } MirrorState;
 
-static int filter_mirror_send(CharBackend *chr_out,
+static int filter_mirror_send(MirrorState *s,
                               const struct iovec *iov,
                               int iovcnt)
 {
+    NetFilterState *nf = NETFILTER(s);
+    VirtIONet *n = qemu_get_nic_opaque(nf->netdev->peer);
     int ret = 0;
     ssize_t size = 0;
+    ssize_t vnet_hdr_len;
     uint32_t len = 0;
     char *buf;
 
@@ -58,14 +62,25 @@ static int filter_mirror_send(CharBackend *chr_out,
     }
 
     len = htonl(size);
-    ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)&len, sizeof(len));
+    ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
+    if (ret != sizeof(len)) {
+        goto err;
+    }
+
+    /*
+     * We send vnet header len make other module(like colo-compare)
+     * know how to parse net packet correctly.
+     */
+    vnet_hdr_len = n->guest_hdr_len;
+    len = htonl(vnet_hdr_len);
+    ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
     if (ret != sizeof(len)) {
         goto err;
     }
 
     buf = g_malloc(size);
     iov_to_buf(iov, iovcnt, 0, buf, size);
-    ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)buf, size);
+    ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
     g_free(buf);
     if (ret != size) {
         goto err;
@@ -141,7 +156,7 @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf,
     MirrorState *s = FILTER_MIRROR(nf);
     int ret;
 
-    ret = filter_mirror_send(&s->chr_out, iov, iovcnt);
+    ret = filter_mirror_send(s, iov, iovcnt);
     if (ret) {
         error_report("filter_mirror_send failed(%s)", strerror(-ret));
     }
@@ -164,7 +179,7 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,
     int ret;
 
     if (qemu_chr_fe_get_driver(&s->chr_out)) {
-        ret = filter_mirror_send(&s->chr_out, iov, iovcnt);
+        ret = filter_mirror_send(s, iov, iovcnt);
         if (ret) {
             error_report("filter_mirror_send failed(%s)", strerror(-ret));
         }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH V2 2/6] net/net.c: Add vnet header length to SocketReadState
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 1/6] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support Zhang Chen
@ 2017-04-20  6:39 ` Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 3/6] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

Address Jason Wang's comments add vnet header length to SocketReadState.
So we change net_fill_rstate() to read
struct  {int size; int vnet_hdr_len; const uint8_t buf[];}.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 include/net/net.h |  4 +++-
 net/net.c         | 24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/net/net.h b/include/net/net.h
index 99b28d5..1204fe5 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -111,9 +111,11 @@ typedef struct NICState {
 } NICState;
 
 struct SocketReadState {
-    int state; /* 0 = getting length, 1 = getting data */
+    /* 0 = getting length, 1 = getting vnet header length, 2 = getting data */
+    int state;
     uint32_t index;
     uint32_t packet_len;
+    uint32_t vnet_hdr_len;
     uint8_t buf[NET_BUFSIZE];
     SocketReadStateFinalize *finalize;
 };
diff --git a/net/net.c b/net/net.c
index 0ac3b9e..d467452 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1621,8 +1621,12 @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
     unsigned int l;
 
     while (size > 0) {
-        /* reassemble a packet from the network */
-        switch (rs->state) { /* 0 = getting length, 1 = getting data */
+        /* Reassemble a packet from the network.
+         * 0 = getting length.
+         * 1 = getting vnet header length.
+         * 2 = getting data.
+         */
+        switch (rs->state) {
         case 0:
             l = 4 - rs->index;
             if (l > size) {
@@ -1640,6 +1644,22 @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
             }
             break;
         case 1:
+            l = 4 - rs->index;
+            if (l > size) {
+                l = size;
+            }
+            memcpy(rs->buf + rs->index, buf, l);
+            buf += l;
+            size -= l;
+            rs->index += l;
+            if (rs->index == 4) {
+                /* got vnet header length */
+                rs->vnet_hdr_len = ntohl(*(uint32_t *)rs->buf);
+                rs->index = 0;
+                rs->state = 2;
+            }
+            break;
+        case 2:
             l = rs->packet_len - rs->index;
             if (l > size) {
                 l = size;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH V2 3/6] net/colo-compare.c: Make colo-compare support vnet_hdr_len
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 1/6] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 2/6] net/net.c: Add vnet header length to SocketReadState Zhang Chen
@ 2017-04-20  6:39 ` Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 4/6] net/socket.c: Add vnet packet support in net_socket_receive() Zhang Chen
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

COLO-compare can get vnet header length from filter,
Add vnet_hdr_len to struct packet and output packet with
the vnet_hdr_len.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 net/colo-compare.c    | 39 ++++++++++++++++++++++++++++++++-------
 net/colo.c            |  3 ++-
 net/colo.h            |  4 +++-
 net/filter-rewriter.c |  2 +-
 4 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index 54e6d40..b3e933c 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -99,7 +99,8 @@ enum {
 
 static int compare_chr_send(CharBackend *out,
                             const uint8_t *buf,
-                            uint32_t size);
+                            uint32_t size,
+                            uint32_t vnet_hdr_len);
 
 static gint seq_sorter(Packet *a, Packet *b, gpointer data)
 {
@@ -121,9 +122,13 @@ static int packet_enqueue(CompareState *s, int mode)
     Connection *conn;
 
     if (mode == PRIMARY_IN) {
-        pkt = packet_new(s->pri_rs.buf, s->pri_rs.packet_len);
+        pkt = packet_new(s->pri_rs.buf,
+                         s->pri_rs.packet_len,
+                         s->pri_rs.vnet_hdr_len);
     } else {
-        pkt = packet_new(s->sec_rs.buf, s->sec_rs.packet_len);
+        pkt = packet_new(s->sec_rs.buf,
+                         s->sec_rs.packet_len,
+                         s->sec_rs.vnet_hdr_len);
     }
 
     if (parse_packet_early(pkt)) {
@@ -436,7 +441,10 @@ static void colo_compare_connection(void *opaque, void *user_data)
         }
 
         if (result) {
-            ret = compare_chr_send(&s->chr_out, pkt->data, pkt->size);
+            ret = compare_chr_send(&s->chr_out,
+                                   pkt->data,
+                                   pkt->size,
+                                   pkt->vnet_hdr_len);
             if (ret < 0) {
                 error_report("colo_send_primary_packet failed");
             }
@@ -459,7 +467,8 @@ static void colo_compare_connection(void *opaque, void *user_data)
 
 static int compare_chr_send(CharBackend *out,
                             const uint8_t *buf,
-                            uint32_t size)
+                            uint32_t size,
+                            uint32_t vnet_hdr_len)
 {
     int ret = 0;
     uint32_t len = htonl(size);
@@ -473,6 +482,16 @@ static int compare_chr_send(CharBackend *out,
         goto err;
     }
 
+    /*
+     * We send vnet header len make other module(like colo-compare)
+     * know how to parse net packet correctly.
+     */
+    len = htonl(vnet_hdr_len);
+    ret = qemu_chr_fe_write_all(out, (uint8_t *)&len, sizeof(len));
+    if (ret != sizeof(len)) {
+        goto err;
+    }
+
     ret = qemu_chr_fe_write_all(out, (uint8_t *)buf, size);
     if (ret != size) {
         goto err;
@@ -616,7 +635,10 @@ static void compare_pri_rs_finalize(SocketReadState *pri_rs)
 
     if (packet_enqueue(s, PRIMARY_IN)) {
         trace_colo_compare_main("primary: unsupported packet in");
-        compare_chr_send(&s->chr_out, pri_rs->buf, pri_rs->packet_len);
+        compare_chr_send(&s->chr_out,
+                         pri_rs->buf,
+                         pri_rs->packet_len,
+                         pri_rs->vnet_hdr_len);
     } else {
         /* compare connection */
         g_queue_foreach(&s->conn_list, colo_compare_connection, s);
@@ -725,7 +747,10 @@ static void colo_flush_packets(void *opaque, void *user_data)
 
     while (!g_queue_is_empty(&conn->primary_list)) {
         pkt = g_queue_pop_head(&conn->primary_list);
-        compare_chr_send(&s->chr_out, pkt->data, pkt->size);
+        compare_chr_send(&s->chr_out,
+                         pkt->data,
+                         pkt->size,
+                         pkt->vnet_hdr_len);
         packet_destroy(pkt, NULL);
     }
     while (!g_queue_is_empty(&conn->secondary_list)) {
diff --git a/net/colo.c b/net/colo.c
index 8cc166b..180eaed 100644
--- a/net/colo.c
+++ b/net/colo.c
@@ -153,13 +153,14 @@ void connection_destroy(void *opaque)
     g_slice_free(Connection, conn);
 }
 
-Packet *packet_new(const void *data, int size)
+Packet *packet_new(const void *data, int size, int vnet_hdr_len)
 {
     Packet *pkt = g_slice_new(Packet);
 
     pkt->data = g_memdup(data, size);
     pkt->size = size;
     pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST);
+    pkt->vnet_hdr_len = vnet_hdr_len;
 
     return pkt;
 }
diff --git a/net/colo.h b/net/colo.h
index 7c524f3..caedb0d 100644
--- a/net/colo.h
+++ b/net/colo.h
@@ -43,6 +43,8 @@ typedef struct Packet {
     int size;
     /* Time of packet creation, in wall clock ms */
     int64_t creation_ms;
+    /* Get vnet_hdr_len from filter */
+    uint32_t vnet_hdr_len;
 } Packet;
 
 typedef struct ConnectionKey {
@@ -82,7 +84,7 @@ Connection *connection_get(GHashTable *connection_track_table,
                            ConnectionKey *key,
                            GQueue *conn_list);
 void connection_hashtable_reset(GHashTable *connection_track_table);
-Packet *packet_new(const void *data, int size);
+Packet *packet_new(const void *data, int size, int vnet_hdr_len);
 void packet_destroy(void *opaque, void *user_data);
 
 #endif /* QEMU_COLO_PROXY_H */
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index afa06e8..63256c7 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -158,7 +158,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
     char *buf = g_malloc0(size);
 
     iov_to_buf(iov, iovcnt, 0, buf, size);
-    pkt = packet_new(buf, size);
+    pkt = packet_new(buf, size, 0);
     g_free(buf);
 
     /*
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH V2 4/6] net/socket.c: Add vnet packet support in net_socket_receive()
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
                   ` (2 preceding siblings ...)
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 3/6] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
@ 2017-04-20  6:39 ` Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 5/6] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

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 --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,
         },
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH V2 5/6] net/colo.c: Add vnet packet parse feature in colo-proxy
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
                   ` (3 preceding siblings ...)
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 4/6] net/socket.c: Add vnet packet support in net_socket_receive() Zhang Chen
@ 2017-04-20  6:39 ` Zhang Chen
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 6/6] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare Zhang Chen
  2017-04-24  3:48 ` [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Jason Wang
  6 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

Make colo-compare and filter-rewriter can parse vnet packet.

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

diff --git a/net/colo.c b/net/colo.c
index 180eaed..28ce7c8 100644
--- a/net/colo.c
+++ b/net/colo.c
@@ -43,11 +43,11 @@ int parse_packet_early(Packet *pkt)
 {
     int network_length;
     static const uint8_t vlan[] = {0x81, 0x00};
-    uint8_t *data = pkt->data;
+    uint8_t *data = pkt->data + pkt->vnet_hdr_len;
     uint16_t l3_proto;
     ssize_t l2hdr_len = eth_get_l2_hdr_length(data);
 
-    if (pkt->size < ETH_HLEN) {
+    if (pkt->size < ETH_HLEN + pkt->vnet_hdr_len) {
         trace_colo_proxy_main("pkt->size < ETH_HLEN");
         return 1;
     }
@@ -73,7 +73,7 @@ int parse_packet_early(Packet *pkt)
     }
 
     network_length = pkt->ip->ip_hl * 4;
-    if (pkt->size < l2hdr_len + network_length) {
+    if (pkt->size < l2hdr_len + network_length + pkt->vnet_hdr_len) {
         trace_colo_proxy_main("pkt->size < network_header + network_length");
         return 1;
     }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH V2 6/6] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
                   ` (4 preceding siblings ...)
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 5/6] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
@ 2017-04-20  6:39 ` Zhang Chen
  2017-04-24  3:48 ` [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Jason Wang
  6 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-20  6:39 UTC (permalink / raw)
  To: qemu devel, Jason Wang
  Cc: Zhang Chen, zhanghailiang, eddie . dong, bian naimeng, Li Zhijian

COLO-Proxy just focus on packet payload, So we skip vnet header.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 net/colo-compare.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index b3e933c..1941ad9 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -187,6 +187,8 @@ static int packet_enqueue(CompareState *s, int mode)
  */
 static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
 {
+    int offset_all;
+
     if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
         char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
 
@@ -200,9 +202,12 @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
                                    sec_ip_src, sec_ip_dst);
     }
 
+    offset_all = ppkt->vnet_hdr_len + offset;
+
     if (ppkt->size == spkt->size) {
-        return memcmp(ppkt->data + offset, spkt->data + offset,
-                      spkt->size - offset);
+        return memcmp(ppkt->data + offset_all,
+                      spkt->data + offset_all,
+                      spkt->size - offset_all);
     } else {
         trace_colo_compare_main("Net packet size are not the same");
         return -1;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support
  2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
                   ` (5 preceding siblings ...)
  2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 6/6] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare Zhang Chen
@ 2017-04-24  3:48 ` Jason Wang
  2017-04-24  6:42   ` Zhang Chen
  2017-04-24 12:02   ` Zhang Chen
  6 siblings, 2 replies; 12+ messages in thread
From: Jason Wang @ 2017-04-24  3:48 UTC (permalink / raw)
  To: Zhang Chen, qemu devel
  Cc: zhanghailiang, eddie . dong, bian naimeng, Li Zhijian



On 2017年04月20日 14:39, Zhang Chen wrote:
> If user use -device virtio-net-pci, virtio-net driver will add a header
> to raw net packet that colo-proxy can't handle it. COLO-proxy just
> focus on the packet payload, so we skip the virtio-net header to compare
> the sent packet that primary guest's to secondary guest's.
>
> Zhang Chen (6):
>    net/filter-mirror.c: Add filter-mirror and filter-redirector vnet
>      support.
>    net/net.c: Add vnet header length to SocketReadState
>    net/colo-compare.c: Make colo-compare support vnet_hdr_len
>    net/socket.c: Add vnet packet support in net_socket_receive()
>    net/colo.c: Add vnet packet parse feature in colo-proxy
>    net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
>
>   include/net/net.h     |  4 +++-
>   net/colo-compare.c    | 48 +++++++++++++++++++++++++++++++++++++++---------
>   net/colo.c            |  9 +++++----
>   net/colo.h            |  4 +++-
>   net/filter-mirror.c   | 25 ++++++++++++++++++++-----
>   net/filter-rewriter.c |  2 +-
>   net/net.c             | 24 ++++++++++++++++++++++--
>   net/socket.c          |  6 ++++++
>   8 files changed, 99 insertions(+), 23 deletions(-)
>

A quick glance at the series and find two issues:

- We can't assume virtio-net is the only user for vnet header, you need 
query e.g NetClientState for a correct vnet header len.
- This series breaks qtest:

**
ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
(buffer == "TEST"): ("" == "TEST")
GTester: last random seed: R02S39dd06f7f52013798111df2e4eb602c5
**
ERROR:tests/e1000e-test.c:365:e1000e_receive_verify: assertion failed 
(le32_to_cpu(descr.wb.upper.status_error) & esta_dd == esta_dd): 
(0x00000000 == 0x00000001)
GTester: last random seed: R02S8c8200b8ec86358cb7addb5c6fe1303c
**
ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
(buffer == "TEST"): ("" == "TEST")
GTester: last random seed: R02S9be86025aa7ded4902bdf644c3964a6e
**
ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion failed: 
(g_get_monotonic_time() - start_time <= timeout_us)
GTester: last random seed: R02S30cac33d7a98fa56806ca59b35910ea5
**
ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion failed: 
(g_get_monotonic_time() - start_time <= timeout_us)
GTester: last random seed: R02S258359836760a723622abf56cf2e61e7
^C/home/devel/git/qemu/tests/Makefile.include:815: recipe for target 
'check-qtest-x86_64' failed
make: *** [check-qtest-x86_64] Interrupt

Please fix them.

Thanks

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support
  2017-04-24  3:48 ` [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Jason Wang
@ 2017-04-24  6:42   ` Zhang Chen
  2017-04-24 12:02   ` Zhang Chen
  1 sibling, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-24  6:42 UTC (permalink / raw)
  To: Jason Wang, qemu devel
  Cc: zhangchen.fnst, zhanghailiang, eddie . dong, bian naimeng,
	Li Zhijian



On 04/24/2017 11:48 AM, Jason Wang wrote:
>
>
> On 2017年04月20日 14:39, Zhang Chen wrote:
>> If user use -device virtio-net-pci, virtio-net driver will add a header
>> to raw net packet that colo-proxy can't handle it. COLO-proxy just
>> focus on the packet payload, so we skip the virtio-net header to compare
>> the sent packet that primary guest's to secondary guest's.
>>
>> Zhang Chen (6):
>>    net/filter-mirror.c: Add filter-mirror and filter-redirector vnet
>>      support.
>>    net/net.c: Add vnet header length to SocketReadState
>>    net/colo-compare.c: Make colo-compare support vnet_hdr_len
>>    net/socket.c: Add vnet packet support in net_socket_receive()
>>    net/colo.c: Add vnet packet parse feature in colo-proxy
>>    net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
>>
>>   include/net/net.h     |  4 +++-
>>   net/colo-compare.c    | 48 
>> +++++++++++++++++++++++++++++++++++++++---------
>>   net/colo.c            |  9 +++++----
>>   net/colo.h            |  4 +++-
>>   net/filter-mirror.c   | 25 ++++++++++++++++++++-----
>>   net/filter-rewriter.c |  2 +-
>>   net/net.c             | 24 ++++++++++++++++++++++--
>>   net/socket.c          |  6 ++++++
>>   8 files changed, 99 insertions(+), 23 deletions(-)
>>
>
> A quick glance at the series and find two issues:
>
> - We can't assume virtio-net is the only user for vnet header, you 
> need query e.g NetClientState for a correct vnet header len.

OK~~ I will fix it in next version.

> - This series breaks qtest:
>
> **
> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
> (buffer == "TEST"): ("" == "TEST")
> GTester: last random seed: R02S39dd06f7f52013798111df2e4eb602c5
> **
> ERROR:tests/e1000e-test.c:365:e1000e_receive_verify: assertion failed 
> (le32_to_cpu(descr.wb.upper.status_error) & esta_dd == esta_dd): 
> (0x00000000 == 0x00000001)
> GTester: last random seed: R02S8c8200b8ec86358cb7addb5c6fe1303c
> **
> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
> (buffer == "TEST"): ("" == "TEST")
> GTester: last random seed: R02S9be86025aa7ded4902bdf644c3964a6e
> **
> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
> failed: (g_get_monotonic_time() - start_time <= timeout_us)
> GTester: last random seed: R02S30cac33d7a98fa56806ca59b35910ea5
> **
> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
> failed: (g_get_monotonic_time() - start_time <= timeout_us)
> GTester: last random seed: R02S258359836760a723622abf56cf2e61e7
> ^C/home/devel/git/qemu/tests/Makefile.include:815: recipe for target 
> 'check-qtest-x86_64' failed
> make: *** [check-qtest-x86_64] Interrupt
>
> Please fix them.
>

Oh~~ I will fix thrm.

Thanks
Zhang Chen
> Thanks
>
>
> .
>

-- 
Thanks
Zhang Chen

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support
  2017-04-24  3:48 ` [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Jason Wang
  2017-04-24  6:42   ` Zhang Chen
@ 2017-04-24 12:02   ` Zhang Chen
  2017-04-25  3:54     ` Jason Wang
  1 sibling, 1 reply; 12+ messages in thread
From: Zhang Chen @ 2017-04-24 12:02 UTC (permalink / raw)
  To: Jason Wang, qemu devel
  Cc: zhangchen.fnst, zhanghailiang, eddie . dong, bian naimeng,
	Li Zhijian



On 04/24/2017 11:48 AM, Jason Wang wrote:
>
>
> On 2017年04月20日 14:39, Zhang Chen wrote:
>> If user use -device virtio-net-pci, virtio-net driver will add a header
>> to raw net packet that colo-proxy can't handle it. COLO-proxy just
>> focus on the packet payload, so we skip the virtio-net header to compare
>> the sent packet that primary guest's to secondary guest's.
>>
>> Zhang Chen (6):
>>    net/filter-mirror.c: Add filter-mirror and filter-redirector vnet
>>      support.
>>    net/net.c: Add vnet header length to SocketReadState
>>    net/colo-compare.c: Make colo-compare support vnet_hdr_len
>>    net/socket.c: Add vnet packet support in net_socket_receive()
>>    net/colo.c: Add vnet packet parse feature in colo-proxy
>>    net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
>>
>>   include/net/net.h     |  4 +++-
>>   net/colo-compare.c    | 48 
>> +++++++++++++++++++++++++++++++++++++++---------
>>   net/colo.c            |  9 +++++----
>>   net/colo.h            |  4 +++-
>>   net/filter-mirror.c   | 25 ++++++++++++++++++++-----
>>   net/filter-rewriter.c |  2 +-
>>   net/net.c             | 24 ++++++++++++++++++++++--
>>   net/socket.c          |  6 ++++++
>>   8 files changed, 99 insertions(+), 23 deletions(-)
>>
>
> A quick glance at the series and find two issues:
>
> - We can't assume virtio-net is the only user for vnet header, you 
> need query e.g NetClientState for a correct vnet header len.

I don't know whether I understand your means.
I found that I can't get vnet_hdr_len from NetClientState,

typedef struct NetClientInfo {
.....
     HasVnetHdr *has_vnet_hdr;
     HasVnetHdrLen *has_vnet_hdr_len;
     UsingVnetHdr *using_vnet_hdr;
     SetOffload *set_offload;
     SetVnetHdrLen *set_vnet_hdr_len;

.....
}NetClientInfo;

This struct haven't a function like get_vnet_hdr_len.
Should I add the get_vnet_hdr_len callback here and write new function 
in tap.c,tap-wen32.c and netmap.c ?

Thanks
Zhang Chen

> - This series breaks qtest:
>
> **
> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
> (buffer == "TEST"): ("" == "TEST")
> GTester: last random seed: R02S39dd06f7f52013798111df2e4eb602c5
> **
> ERROR:tests/e1000e-test.c:365:e1000e_receive_verify: assertion failed 
> (le32_to_cpu(descr.wb.upper.status_error) & esta_dd == esta_dd): 
> (0x00000000 == 0x00000001)
> GTester: last random seed: R02S8c8200b8ec86358cb7addb5c6fe1303c
> **
> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
> (buffer == "TEST"): ("" == "TEST")
> GTester: last random seed: R02S9be86025aa7ded4902bdf644c3964a6e
> **
> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
> failed: (g_get_monotonic_time() - start_time <= timeout_us)
> GTester: last random seed: R02S30cac33d7a98fa56806ca59b35910ea5
> **
> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
> failed: (g_get_monotonic_time() - start_time <= timeout_us)
> GTester: last random seed: R02S258359836760a723622abf56cf2e61e7
> ^C/home/devel/git/qemu/tests/Makefile.include:815: recipe for target 
> 'check-qtest-x86_64' failed
> make: *** [check-qtest-x86_64] Interrupt
>
> Please fix them.
>
> Thanks
>
>
> .
>

-- 
Thanks
Zhang Chen

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support
  2017-04-24 12:02   ` Zhang Chen
@ 2017-04-25  3:54     ` Jason Wang
  2017-04-25  6:17       ` Zhang Chen
  0 siblings, 1 reply; 12+ messages in thread
From: Jason Wang @ 2017-04-25  3:54 UTC (permalink / raw)
  To: Zhang Chen, qemu devel
  Cc: zhanghailiang, eddie . dong, bian naimeng, Li Zhijian



On 2017年04月24日 20:02, Zhang Chen wrote:
>
>
> On 04/24/2017 11:48 AM, Jason Wang wrote:
>>
>>
>> On 2017年04月20日 14:39, Zhang Chen wrote:
>>> If user use -device virtio-net-pci, virtio-net driver will add a header
>>> to raw net packet that colo-proxy can't handle it. COLO-proxy just
>>> focus on the packet payload, so we skip the virtio-net header to 
>>> compare
>>> the sent packet that primary guest's to secondary guest's.
>>>
>>> Zhang Chen (6):
>>>    net/filter-mirror.c: Add filter-mirror and filter-redirector vnet
>>>      support.
>>>    net/net.c: Add vnet header length to SocketReadState
>>>    net/colo-compare.c: Make colo-compare support vnet_hdr_len
>>>    net/socket.c: Add vnet packet support in net_socket_receive()
>>>    net/colo.c: Add vnet packet parse feature in colo-proxy
>>>    net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
>>>
>>>   include/net/net.h     |  4 +++-
>>>   net/colo-compare.c    | 48 
>>> +++++++++++++++++++++++++++++++++++++++---------
>>>   net/colo.c            |  9 +++++----
>>>   net/colo.h            |  4 +++-
>>>   net/filter-mirror.c   | 25 ++++++++++++++++++++-----
>>>   net/filter-rewriter.c |  2 +-
>>>   net/net.c             | 24 ++++++++++++++++++++++--
>>>   net/socket.c          |  6 ++++++
>>>   8 files changed, 99 insertions(+), 23 deletions(-)
>>>
>>
>> A quick glance at the series and find two issues:
>>
>> - We can't assume virtio-net is the only user for vnet header, you 
>> need query e.g NetClientState for a correct vnet header len.
>
> I don't know whether I understand your means.
> I found that I can't get vnet_hdr_len from NetClientState,
>
> typedef struct NetClientInfo {
> .....
>     HasVnetHdr *has_vnet_hdr;
>     HasVnetHdrLen *has_vnet_hdr_len;
>     UsingVnetHdr *using_vnet_hdr;
>     SetOffload *set_offload;
>     SetVnetHdrLen *set_vnet_hdr_len;
>
> .....
> }NetClientInfo;
>
> This struct haven't a function like get_vnet_hdr_len.
> Should I add the get_vnet_hdr_len callback here and write new function 
> in tap.c,tap-wen32.c and netmap.c ?
>
> Thanks
> Zhang Chen

Yes, you need add such callbacks I think.

Thanks

>
>> - This series breaks qtest:
>>
>> **
>> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
>> (buffer == "TEST"): ("" == "TEST")
>> GTester: last random seed: R02S39dd06f7f52013798111df2e4eb602c5
>> **
>> ERROR:tests/e1000e-test.c:365:e1000e_receive_verify: assertion failed 
>> (le32_to_cpu(descr.wb.upper.status_error) & esta_dd == esta_dd): 
>> (0x00000000 == 0x00000001)
>> GTester: last random seed: R02S8c8200b8ec86358cb7addb5c6fe1303c
>> **
>> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
>> (buffer == "TEST"): ("" == "TEST")
>> GTester: last random seed: R02S9be86025aa7ded4902bdf644c3964a6e
>> **
>> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
>> failed: (g_get_monotonic_time() - start_time <= timeout_us)
>> GTester: last random seed: R02S30cac33d7a98fa56806ca59b35910ea5
>> **
>> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
>> failed: (g_get_monotonic_time() - start_time <= timeout_us)
>> GTester: last random seed: R02S258359836760a723622abf56cf2e61e7
>> ^C/home/devel/git/qemu/tests/Makefile.include:815: recipe for target 
>> 'check-qtest-x86_64' failed
>> make: *** [check-qtest-x86_64] Interrupt
>>
>> Please fix them.
>>
>> Thanks
>>
>>
>> .
>>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support
  2017-04-25  3:54     ` Jason Wang
@ 2017-04-25  6:17       ` Zhang Chen
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang Chen @ 2017-04-25  6:17 UTC (permalink / raw)
  To: Jason Wang, qemu devel
  Cc: zhangchen.fnst, zhanghailiang, eddie . dong, bian naimeng,
	Li Zhijian



On 04/25/2017 11:54 AM, Jason Wang wrote:
>
>
> On 2017年04月24日 20:02, Zhang Chen wrote:
>>
>>
>> On 04/24/2017 11:48 AM, Jason Wang wrote:
>>>
>>>
>>> On 2017年04月20日 14:39, Zhang Chen wrote:
>>>> If user use -device virtio-net-pci, virtio-net driver will add a 
>>>> header
>>>> to raw net packet that colo-proxy can't handle it. COLO-proxy just
>>>> focus on the packet payload, so we skip the virtio-net header to 
>>>> compare
>>>> the sent packet that primary guest's to secondary guest's.
>>>>
>>>> Zhang Chen (6):
>>>>    net/filter-mirror.c: Add filter-mirror and filter-redirector vnet
>>>>      support.
>>>>    net/net.c: Add vnet header length to SocketReadState
>>>>    net/colo-compare.c: Make colo-compare support vnet_hdr_len
>>>>    net/socket.c: Add vnet packet support in net_socket_receive()
>>>>    net/colo.c: Add vnet packet parse feature in colo-proxy
>>>>    net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
>>>>
>>>>   include/net/net.h     |  4 +++-
>>>>   net/colo-compare.c    | 48 
>>>> +++++++++++++++++++++++++++++++++++++++---------
>>>>   net/colo.c            |  9 +++++----
>>>>   net/colo.h            |  4 +++-
>>>>   net/filter-mirror.c   | 25 ++++++++++++++++++++-----
>>>>   net/filter-rewriter.c |  2 +-
>>>>   net/net.c             | 24 ++++++++++++++++++++++--
>>>>   net/socket.c          |  6 ++++++
>>>>   8 files changed, 99 insertions(+), 23 deletions(-)
>>>>
>>>
>>> A quick glance at the series and find two issues:
>>>
>>> - We can't assume virtio-net is the only user for vnet header, you 
>>> need query e.g NetClientState for a correct vnet header len.
>>
>> I don't know whether I understand your means.
>> I found that I can't get vnet_hdr_len from NetClientState,
>>
>> typedef struct NetClientInfo {
>> .....
>>     HasVnetHdr *has_vnet_hdr;
>>     HasVnetHdrLen *has_vnet_hdr_len;
>>     UsingVnetHdr *using_vnet_hdr;
>>     SetOffload *set_offload;
>>     SetVnetHdrLen *set_vnet_hdr_len;
>>
>> .....
>> }NetClientInfo;
>>
>> This struct haven't a function like get_vnet_hdr_len.
>> Should I add the get_vnet_hdr_len callback here and write new 
>> function in tap.c,tap-wen32.c and netmap.c ?
>>
>> Thanks
>> Zhang Chen
>
> Yes, you need add such callbacks I think.
>

OK, I got your point~

Thanks
Zhang Chen

> Thanks
>
>>
>>> - This series breaks qtest:
>>>
>>> **
>>> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
>>> (buffer == "TEST"): ("" == "TEST")
>>> GTester: last random seed: R02S39dd06f7f52013798111df2e4eb602c5
>>> **
>>> ERROR:tests/e1000e-test.c:365:e1000e_receive_verify: assertion 
>>> failed (le32_to_cpu(descr.wb.upper.status_error) & esta_dd == 
>>> esta_dd): (0x00000000 == 0x00000001)
>>> GTester: last random seed: R02S8c8200b8ec86358cb7addb5c6fe1303c
>>> **
>>> ERROR:tests/e1000e-test.c:296:e1000e_send_verify: assertion failed 
>>> (buffer == "TEST"): ("" == "TEST")
>>> GTester: last random seed: R02S9be86025aa7ded4902bdf644c3964a6e
>>> **
>>> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
>>> failed: (g_get_monotonic_time() - start_time <= timeout_us)
>>> GTester: last random seed: R02S30cac33d7a98fa56806ca59b35910ea5
>>> **
>>> ERROR:tests/libqos/virtio.c:94:qvirtio_wait_queue_isr: assertion 
>>> failed: (g_get_monotonic_time() - start_time <= timeout_us)
>>> GTester: last random seed: R02S258359836760a723622abf56cf2e61e7
>>> ^C/home/devel/git/qemu/tests/Makefile.include:815: recipe for target 
>>> 'check-qtest-x86_64' failed
>>> make: *** [check-qtest-x86_64] Interrupt
>>>
>>> Please fix them.
>>>
>>> Thanks
>>>
>>>
>>> .
>>>
>>
>
>
>
> .
>

-- 
Thanks
Zhang Chen

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-04-25  6:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-20  6:39 [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Zhang Chen
2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 1/6] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support Zhang Chen
2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 2/6] net/net.c: Add vnet header length to SocketReadState Zhang Chen
2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 3/6] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 4/6] net/socket.c: Add vnet packet support in net_socket_receive() Zhang Chen
2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 5/6] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
2017-04-20  6:39 ` [Qemu-devel] [PATCH V2 6/6] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare Zhang Chen
2017-04-24  3:48 ` [Qemu-devel] [PATCH V2 0/6] Add COLO-proxy virtio-net support Jason Wang
2017-04-24  6:42   ` Zhang Chen
2017-04-24 12:02   ` Zhang Chen
2017-04-25  3:54     ` Jason Wang
2017-04-25  6:17       ` Zhang Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).