1 | The following changes since commit 6632f6ff96f0537fc34cdc00c760656fc62e23c5: | 1 | The following changes since commit 2e02083438962d26ef9dcc7100f3b378104183db: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/famz/tags/block-and-testing-pull-request' into staging (2017-07-17 11:46:36 +0100) | 3 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2017-11-17 19:08:07 +0000) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the git repository at: |
6 | 6 | ||
7 | https://github.com/jasowang/qemu.git tags/net-pull-request | 7 | https://github.com/jasowang/qemu.git tags/net-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 189ae6bb5ce1f5a322f8691d00fe942ba43dd601: | 9 | for you to fetch changes up to c527e0afcd7d719abc3a5ca5e4c8ac2fe48b999f: |
10 | 10 | ||
11 | virtio-net: fix offload ctrl endian (2017-07-17 20:13:56 +0800) | 11 | hw/net/vmxnet3: Fix code to work on big endian hosts, too (2017-11-20 11:08:00 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | 14 | ||
15 | - fix virtio-net ctrl offload endian | 15 | ---------------------------------------------------------------- |
16 | - vnet header support for variou COLO netfilters and compare thread | 16 | Ed Swierk (1): |
17 | net: Transmit zero UDP checksum as 0xFFFF | ||
17 | 18 | ||
18 | ---------------------------------------------------------------- | ||
19 | Jason Wang (1): | 19 | Jason Wang (1): |
20 | virtio-net: fix offload ctrl endian | 20 | Revert "Add new PCI ID for i82559a" |
21 | 21 | ||
22 | Michal Privoznik (1): | 22 | Mao Zhongyi (1): |
23 | virtion-net: Prefer is_power_of_2() | 23 | colo-compare: fix the dangerous assignment |
24 | 24 | ||
25 | Zhang Chen (12): | 25 | Stefan Weil (1): |
26 | net: Add vnet_hdr_len arguments in NetClientState | 26 | MAINTAINERS: Add missing entry for eepro100 emulation |
27 | net/net.c: Add vnet_hdr support in SocketReadState | ||
28 | net/filter-mirror.c: Introduce parameter for filter_send() | ||
29 | net/filter-mirror.c: Make filter mirror support vnet support. | ||
30 | net/filter-mirror.c: Add new option to enable vnet support for filter-redirector | ||
31 | net/colo.c: Make vnet_hdr_len as packet property | ||
32 | net/colo-compare.c: Introduce parameter for compare_chr_send() | ||
33 | net/colo-compare.c: Make colo-compare support vnet_hdr_len | ||
34 | net/colo.c: Add vnet packet parse feature in colo-proxy | ||
35 | net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare | ||
36 | net/filter-rewriter.c: Make filter-rewriter support vnet_hdr_len | ||
37 | docs/colo-proxy.txt: Update colo-proxy usage of net driver with vnet_header | ||
38 | 27 | ||
39 | docs/colo-proxy.txt | 26 ++++++++++++++++ | 28 | Thomas Huth (2): |
40 | hw/net/virtio-net.c | 4 ++- | 29 | hw/net/eepro100: Fix endianness problem on big endian hosts |
41 | include/net/net.h | 10 ++++-- | 30 | hw/net/vmxnet3: Fix code to work on big endian hosts, too |
42 | net/colo-compare.c | 84 ++++++++++++++++++++++++++++++++++++++++++--------- | 31 | |
43 | net/colo.c | 9 +++--- | 32 | MAINTAINERS | 5 ++ |
44 | net/colo.h | 4 ++- | 33 | hw/net/e1000.c | 2 +- |
45 | net/filter-mirror.c | 75 +++++++++++++++++++++++++++++++++++++++++---- | 34 | hw/net/eepro100.c | 17 +--- |
46 | net/filter-rewriter.c | 37 ++++++++++++++++++++++- | 35 | hw/net/net_rx_pkt.c | 2 +- |
47 | net/net.c | 37 ++++++++++++++++++++--- | 36 | hw/net/net_tx_pkt.c | 2 +- |
48 | net/socket.c | 8 ++--- | 37 | hw/net/vmware_utils.h | 6 ++ |
49 | qemu-options.hx | 19 ++++++------ | 38 | hw/net/vmxnet3.c | 49 ++++++++--- |
50 | 11 files changed, 265 insertions(+), 48 deletions(-) | 39 | hw/net/vmxnet3.h | 230 ++++++++++++++++++++++++++++++------------------- |
40 | include/hw/compat.h | 4 - | ||
41 | include/hw/pci/pci.h | 1 - | ||
42 | include/net/checksum.h | 6 ++ | ||
43 | net/colo-compare.c | 2 +- | ||
44 | qemu-options.hx | 2 +- | ||
45 | 13 files changed, 201 insertions(+), 127 deletions(-) | ||
51 | 46 | ||
52 | 47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | Add vnet_hdr_len arguments in NetClientState | ||
4 | that make other module get real vnet_hdr_len easily. | ||
5 | |||
6 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
8 | --- | ||
9 | include/net/net.h | 1 + | ||
10 | net/net.c | 1 + | ||
11 | 2 files changed, 2 insertions(+) | ||
12 | |||
13 | diff --git a/include/net/net.h b/include/net/net.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/net/net.h | ||
16 | +++ b/include/net/net.h | ||
17 | @@ -XXX,XX +XXX,XX @@ struct NetClientState { | ||
18 | unsigned int queue_index; | ||
19 | unsigned rxfilter_notify_enabled:1; | ||
20 | int vring_enable; | ||
21 | + int vnet_hdr_len; | ||
22 | QTAILQ_HEAD(NetFilterHead, NetFilterState) filters; | ||
23 | }; | ||
24 | |||
25 | diff --git a/net/net.c b/net/net.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/net/net.c | ||
28 | +++ b/net/net.c | ||
29 | @@ -XXX,XX +XXX,XX @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len) | ||
30 | return; | ||
31 | } | ||
32 | |||
33 | + nc->vnet_hdr_len = len; | ||
34 | nc->info->set_vnet_hdr_len(nc, len); | ||
35 | } | ||
36 | |||
37 | -- | ||
38 | 2.7.4 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | We add a flag to decide whether net_fill_rstate() need read | ||
4 | the vnet_hdr_len or not. | ||
5 | |||
6 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
7 | Suggested-by: Jason Wang <jasowang@redhat.com> | ||
8 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
9 | --- | ||
10 | include/net/net.h | 9 +++++++-- | ||
11 | net/colo-compare.c | 4 ++-- | ||
12 | net/filter-mirror.c | 2 +- | ||
13 | net/net.c | 36 ++++++++++++++++++++++++++++++++---- | ||
14 | net/socket.c | 8 ++++---- | ||
15 | 5 files changed, 46 insertions(+), 13 deletions(-) | ||
16 | |||
17 | diff --git a/include/net/net.h b/include/net/net.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/net/net.h | ||
20 | +++ b/include/net/net.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct NICState { | ||
22 | } NICState; | ||
23 | |||
24 | struct SocketReadState { | ||
25 | - int state; /* 0 = getting length, 1 = getting data */ | ||
26 | + /* 0 = getting length, 1 = getting vnet header length, 2 = getting data */ | ||
27 | + int state; | ||
28 | + /* This flag decide whether to read the vnet_hdr_len field */ | ||
29 | + bool vnet_hdr; | ||
30 | uint32_t index; | ||
31 | uint32_t packet_len; | ||
32 | + uint32_t vnet_hdr_len; | ||
33 | uint8_t buf[NET_BUFSIZE]; | ||
34 | SocketReadStateFinalize *finalize; | ||
35 | }; | ||
36 | @@ -XXX,XX +XXX,XX @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, | ||
37 | void print_net_client(Monitor *mon, NetClientState *nc); | ||
38 | void hmp_info_network(Monitor *mon, const QDict *qdict); | ||
39 | void net_socket_rs_init(SocketReadState *rs, | ||
40 | - SocketReadStateFinalize *finalize); | ||
41 | + SocketReadStateFinalize *finalize, | ||
42 | + bool vnet_hdr); | ||
43 | |||
44 | /* NIC info */ | ||
45 | |||
46 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/net/colo-compare.c | ||
49 | +++ b/net/colo-compare.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | - net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize); | ||
55 | - net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize); | ||
56 | + net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, false); | ||
57 | + net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, false); | ||
58 | |||
59 | g_queue_init(&s->conn_list); | ||
60 | |||
61 | diff --git a/net/filter-mirror.c b/net/filter-mirror.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/net/filter-mirror.c | ||
64 | +++ b/net/filter-mirror.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp) | ||
66 | } | ||
67 | } | ||
68 | |||
69 | - net_socket_rs_init(&s->rs, redirector_rs_finalize); | ||
70 | + net_socket_rs_init(&s->rs, redirector_rs_finalize, false); | ||
71 | |||
72 | if (s->indev) { | ||
73 | chr = qemu_chr_find(s->indev); | ||
74 | diff --git a/net/net.c b/net/net.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/net/net.c | ||
77 | +++ b/net/net.c | ||
78 | @@ -XXX,XX +XXX,XX @@ QemuOptsList qemu_net_opts = { | ||
79 | }; | ||
80 | |||
81 | void net_socket_rs_init(SocketReadState *rs, | ||
82 | - SocketReadStateFinalize *finalize) | ||
83 | + SocketReadStateFinalize *finalize, | ||
84 | + bool vnet_hdr) | ||
85 | { | ||
86 | rs->state = 0; | ||
87 | + rs->vnet_hdr = vnet_hdr; | ||
88 | rs->index = 0; | ||
89 | rs->packet_len = 0; | ||
90 | + rs->vnet_hdr_len = 0; | ||
91 | memset(rs->buf, 0, sizeof(rs->buf)); | ||
92 | rs->finalize = finalize; | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size) | ||
95 | unsigned int l; | ||
96 | |||
97 | while (size > 0) { | ||
98 | - /* reassemble a packet from the network */ | ||
99 | - switch (rs->state) { /* 0 = getting length, 1 = getting data */ | ||
100 | + /* Reassemble a packet from the network. | ||
101 | + * 0 = getting length. | ||
102 | + * 1 = getting vnet header length. | ||
103 | + * 2 = getting data. | ||
104 | + */ | ||
105 | + switch (rs->state) { | ||
106 | case 0: | ||
107 | l = 4 - rs->index; | ||
108 | if (l > size) { | ||
109 | @@ -XXX,XX +XXX,XX @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size) | ||
110 | /* got length */ | ||
111 | rs->packet_len = ntohl(*(uint32_t *)rs->buf); | ||
112 | rs->index = 0; | ||
113 | - rs->state = 1; | ||
114 | + if (rs->vnet_hdr) { | ||
115 | + rs->state = 1; | ||
116 | + } else { | ||
117 | + rs->state = 2; | ||
118 | + rs->vnet_hdr_len = 0; | ||
119 | + } | ||
120 | } | ||
121 | break; | ||
122 | case 1: | ||
123 | + l = 4 - rs->index; | ||
124 | + if (l > size) { | ||
125 | + l = size; | ||
126 | + } | ||
127 | + memcpy(rs->buf + rs->index, buf, l); | ||
128 | + buf += l; | ||
129 | + size -= l; | ||
130 | + rs->index += l; | ||
131 | + if (rs->index == 4) { | ||
132 | + /* got vnet header length */ | ||
133 | + rs->vnet_hdr_len = ntohl(*(uint32_t *)rs->buf); | ||
134 | + rs->index = 0; | ||
135 | + rs->state = 2; | ||
136 | + } | ||
137 | + break; | ||
138 | + case 2: | ||
139 | l = rs->packet_len - rs->index; | ||
140 | if (l > size) { | ||
141 | l = size; | ||
142 | diff --git a/net/socket.c b/net/socket.c | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/net/socket.c | ||
145 | +++ b/net/socket.c | ||
146 | @@ -XXX,XX +XXX,XX @@ static void net_socket_send(void *opaque) | ||
147 | closesocket(s->fd); | ||
148 | |||
149 | s->fd = -1; | ||
150 | - net_socket_rs_init(&s->rs, net_socket_rs_finalize); | ||
151 | + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); | ||
152 | s->nc.link_down = true; | ||
153 | memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); | ||
154 | |||
155 | @@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, | ||
156 | s->fd = fd; | ||
157 | s->listen_fd = -1; | ||
158 | s->send_fn = net_socket_send_dgram; | ||
159 | - net_socket_rs_init(&s->rs, net_socket_rs_finalize); | ||
160 | + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); | ||
161 | net_socket_read_poll(s, true); | ||
162 | |||
163 | /* mcast: save bound address as dst */ | ||
164 | @@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer, | ||
165 | |||
166 | s->fd = fd; | ||
167 | s->listen_fd = -1; | ||
168 | - net_socket_rs_init(&s->rs, net_socket_rs_finalize); | ||
169 | + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); | ||
170 | |||
171 | /* Disable Nagle algorithm on TCP sockets to reduce latency */ | ||
172 | socket_set_nodelay(fd); | ||
173 | @@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer, | ||
174 | s->fd = -1; | ||
175 | s->listen_fd = fd; | ||
176 | s->nc.link_down = true; | ||
177 | - net_socket_rs_init(&s->rs, net_socket_rs_finalize); | ||
178 | + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); | ||
179 | |||
180 | qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s); | ||
181 | return 0; | ||
182 | -- | ||
183 | 2.7.4 | ||
184 | |||
185 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | This patch change the filter_send() parameter from CharBackend to MirrorState, | ||
4 | we can get more information like vnet_hdr(We use it to support packet with vnet_header). | ||
5 | |||
6 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
8 | --- | ||
9 | net/filter-mirror.c | 10 +++++----- | ||
10 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
11 | |||
12 | diff --git a/net/filter-mirror.c b/net/filter-mirror.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/net/filter-mirror.c | ||
15 | +++ b/net/filter-mirror.c | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef struct MirrorState { | ||
17 | SocketReadState rs; | ||
18 | } MirrorState; | ||
19 | |||
20 | -static int filter_send(CharBackend *chr_out, | ||
21 | +static int filter_send(MirrorState *s, | ||
22 | const struct iovec *iov, | ||
23 | int iovcnt) | ||
24 | { | ||
25 | @@ -XXX,XX +XXX,XX @@ static int filter_send(CharBackend *chr_out, | ||
26 | } | ||
27 | |||
28 | len = htonl(size); | ||
29 | - ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)&len, sizeof(len)); | ||
30 | + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len)); | ||
31 | if (ret != sizeof(len)) { | ||
32 | goto err; | ||
33 | } | ||
34 | |||
35 | buf = g_malloc(size); | ||
36 | iov_to_buf(iov, iovcnt, 0, buf, size); | ||
37 | - ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)buf, size); | ||
38 | + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); | ||
39 | g_free(buf); | ||
40 | if (ret != size) { | ||
41 | goto err; | ||
42 | @@ -XXX,XX +XXX,XX @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf, | ||
43 | MirrorState *s = FILTER_MIRROR(nf); | ||
44 | int ret; | ||
45 | |||
46 | - ret = filter_send(&s->chr_out, iov, iovcnt); | ||
47 | + ret = filter_send(s, iov, iovcnt); | ||
48 | if (ret) { | ||
49 | error_report("filter mirror send failed(%s)", strerror(-ret)); | ||
50 | } | ||
51 | @@ -XXX,XX +XXX,XX @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf, | ||
52 | int ret; | ||
53 | |||
54 | if (qemu_chr_fe_backend_connected(&s->chr_out)) { | ||
55 | - ret = filter_send(&s->chr_out, iov, iovcnt); | ||
56 | + ret = filter_send(s, iov, iovcnt); | ||
57 | if (ret) { | ||
58 | error_report("filter redirector send failed(%s)", strerror(-ret)); | ||
59 | } | ||
60 | -- | ||
61 | 2.7.4 | ||
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> |
---|---|---|---|
2 | 2 | ||
3 | COLO-Proxy just focus on packet payload, so we skip vnet header. | 3 | Cc: Peter Maydell <peter.maydell@linaro.org> |
4 | 4 | Cc: Jason Wang <jasowang@redhat.com> | |
5 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 5 | Cc: Zhang Chen <zhangckid@gmail.com> |
6 | Cc: Li Zhijian <lizhijian@cn.fujitsu.com> | ||
7 | Cc: Paolo Bonzini <pbonzini@redhat.com> | ||
8 | Fixes: 8ec14402029d783720f4312ed8a925548e1dad61 | ||
9 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reported-by: Paolo Bonzini <pbonzini@redhat.com> | ||
11 | Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
12 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
6 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 13 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
7 | --- | 14 | --- |
8 | net/colo-compare.c | 8 ++++++-- | 15 | net/colo-compare.c | 2 +- |
9 | 1 file changed, 6 insertions(+), 2 deletions(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 17 | ||
11 | diff --git a/net/colo-compare.c b/net/colo-compare.c | 18 | diff --git a/net/colo-compare.c b/net/colo-compare.c |
12 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/net/colo-compare.c | 20 | --- a/net/colo-compare.c |
14 | +++ b/net/colo-compare.c | 21 | +++ b/net/colo-compare.c |
15 | @@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset) | 22 | @@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode, Connection **con) |
16 | sec_ip_src, sec_ip_dst); | 23 | "drop packet"); |
24 | } | ||
17 | } | 25 | } |
18 | 26 | - con = &conn; | |
19 | + offset = ppkt->vnet_hdr_len + offset; | 27 | + *con = conn; |
20 | + | 28 | |
21 | if (ppkt->size == spkt->size) { | 29 | return 0; |
22 | - return memcmp(ppkt->data + offset, spkt->data + offset, | 30 | } |
23 | + return memcmp(ppkt->data + offset, | ||
24 | + spkt->data + offset, | ||
25 | spkt->size - offset); | ||
26 | } else { | ||
27 | trace_colo_compare_main("Net packet size are not the same"); | ||
28 | @@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) | ||
29 | */ | ||
30 | if (ptcp->th_off > 5) { | ||
31 | ptrdiff_t tcp_offset; | ||
32 | + | ||
33 | tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data | ||
34 | - + (ptcp->th_off * 4); | ||
35 | + + (ptcp->th_off * 4) - ppkt->vnet_hdr_len; | ||
36 | res = colo_packet_compare_common(ppkt, spkt, tcp_offset); | ||
37 | } else if (ptcp->th_sum == stcp->th_sum) { | ||
38 | res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN); | ||
39 | -- | 31 | -- |
40 | 2.7.4 | 32 | 2.7.4 |
41 | 33 | ||
42 | 34 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | This reverts commit 5e89dc01133f8f5e621f6b66b356c6f37d31dafb since: |
---|---|---|---|
2 | 2 | ||
3 | We add the vnet_hdr_support option for filter-redirector, default is disabled. | 3 | - we should use ID in the spec instead the one used by OEM |
4 | If you use virtio-net-pci net driver or other driver needs vnet_hdr, please enable it. | 4 | - in the future, we should allow changing id through either property |
5 | Because colo-compare or other modules needs the vnet_hdr_len to parse | 5 | or EEPROM file. |
6 | packet, we add this new option send the len to others. | ||
7 | You can use it for example: | ||
8 | -object filter-redirector,id=r0,netdev=hn0,queue=tx,outdev=red0,vnet_hdr_support | ||
9 | 6 | ||
10 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 7 | Cc: Stefan Weil <sw@weilnetz.de> |
8 | Cc: Michael Nawrocki <michael.nawrocki@gtri.gatech.edu> | ||
9 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
11 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 12 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 13 | --- |
13 | net/filter-mirror.c | 23 +++++++++++++++++++++++ | 14 | hw/net/eepro100.c | 13 ------------- |
14 | qemu-options.hx | 6 +++--- | 15 | include/hw/compat.h | 4 ---- |
15 | 2 files changed, 26 insertions(+), 3 deletions(-) | 16 | include/hw/pci/pci.h | 1 - |
17 | qemu-options.hx | 2 +- | ||
18 | 4 files changed, 1 insertion(+), 19 deletions(-) | ||
16 | 19 | ||
17 | diff --git a/net/filter-mirror.c b/net/filter-mirror.c | 20 | diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/net/filter-mirror.c | 22 | --- a/hw/net/eepro100.c |
20 | +++ b/net/filter-mirror.c | 23 | +++ b/hw/net/eepro100.c |
21 | @@ -XXX,XX +XXX,XX @@ static void filter_redirector_set_outdev(Object *obj, | 24 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
22 | s->outdev = g_strdup(value); | 25 | const char *name; |
23 | } | 26 | const char *desc; |
24 | 27 | uint16_t device_id; | |
25 | +static bool filter_redirector_get_vnet_hdr(Object *obj, Error **errp) | 28 | - uint16_t alt_device_id; |
26 | +{ | 29 | uint8_t revision; |
27 | + MirrorState *s = FILTER_REDIRECTOR(obj); | 30 | uint16_t subsystem_vendor_id; |
28 | + | 31 | uint16_t subsystem_id; |
29 | + return s->vnet_hdr; | 32 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
30 | +} | 33 | /* Quasi static device properties (no need to save them). */ |
31 | + | 34 | uint16_t stats_size; |
32 | +static void filter_redirector_set_vnet_hdr(Object *obj, | 35 | bool has_extended_tcb_support; |
33 | + bool value, | 36 | - bool use_alt_device_id; |
34 | + Error **errp) | 37 | } EEPRO100State; |
35 | +{ | 38 | |
36 | + MirrorState *s = FILTER_REDIRECTOR(obj); | 39 | /* Word indices in EEPROM. */ |
37 | + | 40 | @@ -XXX,XX +XXX,XX @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) |
38 | + s->vnet_hdr = value; | 41 | |
39 | +} | 42 | TRACE(OTHER, logout("\n")); |
40 | + | 43 | |
41 | static void filter_mirror_init(Object *obj) | 44 | - /* By default, the i82559a adapter uses the legacy PCI ID (for the |
42 | { | 45 | - * i82557). This allows the PCI ID to be changed to the alternate |
43 | MirrorState *s = FILTER_MIRROR(obj); | 46 | - * i82559 ID if needed. |
44 | @@ -XXX,XX +XXX,XX @@ static void filter_mirror_init(Object *obj) | 47 | - */ |
45 | 48 | - if (s->use_alt_device_id && strcmp(info->name, "i82559a") == 0) { | |
46 | static void filter_redirector_init(Object *obj) | 49 | - pci_config_set_device_id(s->dev.config, info->alt_device_id); |
47 | { | 50 | - } |
48 | + MirrorState *s = FILTER_REDIRECTOR(obj); | 51 | - |
49 | + | 52 | s->device = info->device; |
50 | object_property_add_str(obj, "indev", filter_redirector_get_indev, | 53 | |
51 | filter_redirector_set_indev, NULL); | 54 | e100_pci_reset(s, &local_err); |
52 | object_property_add_str(obj, "outdev", filter_redirector_get_outdev, | 55 | @@ -XXX,XX +XXX,XX @@ static E100PCIDeviceInfo e100_devices[] = { |
53 | filter_redirector_set_outdev, NULL); | 56 | .desc = "Intel i82559A Ethernet", |
54 | + | 57 | .device = i82559A, |
55 | + s->vnet_hdr = false; | 58 | .device_id = PCI_DEVICE_ID_INTEL_82557, |
56 | + object_property_add_bool(obj, "vnet_hdr_support", | 59 | - .alt_device_id = PCI_DEVICE_ID_INTEL_82559, |
57 | + filter_redirector_get_vnet_hdr, | 60 | .revision = 0x06, |
58 | + filter_redirector_set_vnet_hdr, NULL); | 61 | .stats_size = 80, |
59 | } | 62 | .has_extended_tcb_support = true, |
60 | 63 | @@ -XXX,XX +XXX,XX @@ static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s) | |
61 | static void filter_mirror_fini(Object *obj) | 64 | |
65 | static Property e100_properties[] = { | ||
66 | DEFINE_NIC_PROPERTIES(EEPRO100State, conf), | ||
67 | - DEFINE_PROP_BOOL("x-use-alt-device-id", EEPRO100State, use_alt_device_id, | ||
68 | - true), | ||
69 | DEFINE_PROP_END_OF_LIST(), | ||
70 | }; | ||
71 | |||
72 | diff --git a/include/hw/compat.h b/include/hw/compat.h | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/include/hw/compat.h | ||
75 | +++ b/include/hw/compat.h | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | .driver = "virtio-tablet-device",\ | ||
78 | .property = "wheel-axis",\ | ||
79 | .value = "false",\ | ||
80 | - },{\ | ||
81 | - .driver = "i82559a",\ | ||
82 | - .property = "x-use-alt-device-id",\ | ||
83 | - .value = "false",\ | ||
84 | }, | ||
85 | |||
86 | #define HW_COMPAT_2_9 \ | ||
87 | diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/include/hw/pci/pci.h | ||
90 | +++ b/include/hw/pci/pci.h | ||
91 | @@ -XXX,XX +XXX,XX @@ extern bool pci_available; | ||
92 | /* Intel (0x8086) */ | ||
93 | #define PCI_DEVICE_ID_INTEL_82551IT 0x1209 | ||
94 | #define PCI_DEVICE_ID_INTEL_82557 0x1229 | ||
95 | -#define PCI_DEVICE_ID_INTEL_82559 0x1030 | ||
96 | #define PCI_DEVICE_ID_INTEL_82801IR 0x2922 | ||
97 | |||
98 | /* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */ | ||
62 | diff --git a/qemu-options.hx b/qemu-options.hx | 99 | diff --git a/qemu-options.hx b/qemu-options.hx |
63 | index XXXXXXX..XXXXXXX 100644 | 100 | index XXXXXXX..XXXXXXX 100644 |
64 | --- a/qemu-options.hx | 101 | --- a/qemu-options.hx |
65 | +++ b/qemu-options.hx | 102 | +++ b/qemu-options.hx |
66 | @@ -XXX,XX +XXX,XX @@ queue @var{all|rx|tx} is an option that can be applied to any netfilter. | 103 | @@ -XXX,XX +XXX,XX @@ that the card should have; this option currently only affects virtio cards; set |
67 | 104 | @var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single | |
68 | filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{chardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror packet with vnet_hdr_len. | 105 | NIC is created. QEMU can emulate several different models of network card. |
69 | 106 | Valid values for @var{type} are | |
70 | -@item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid}, | 107 | -@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559a}, @code{i82559er}, |
71 | -outdev=@var{chardevid}[,queue=@var{all|rx|tx}] | 108 | +@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er}, |
72 | +@item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support] | 109 | @code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, |
73 | 110 | @code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. | |
74 | filter-redirector on netdev @var{netdevid},redirect filter's net packet to chardev | 111 | Not all devices are supported on all targets. Use @code{-net nic,model=help} |
75 | -@var{chardevid},and redirect indev's packet to filter. | ||
76 | +@var{chardevid},and redirect indev's packet to filter.if it has the vnet_hdr_support flag, | ||
77 | +filter-redirector will redirect packet with vnet_hdr_len. | ||
78 | Create a filter-redirector we need to differ outdev id from indev id, id can not | ||
79 | be the same. we can just use indev or outdev, but at least one of indev or outdev | ||
80 | need to be specified. | ||
81 | -- | 112 | -- |
82 | 2.7.4 | 113 | 2.7.4 |
83 | 114 | ||
84 | 115 | diff view generated by jsdifflib |
1 | Spec said offloads should be le64, so use virtio_ldq_p() to guarantee | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | valid endian. | ||
3 | 2 | ||
4 | Fixes: 644c98587d4c ("virtio-net: dynamic network offloads configuration") | 3 | Since commit 1865e288a823c764cd4344d ("Fix eepro100 simple transmission |
5 | Cc: qemu-stable@nongnu.org | 4 | mode"), the test/pxe-test is broken for the eepro100 device on big |
6 | Cc: Dmitry Fleytman <dfleytma@redhat.com> | 5 | endian hosts. However, it seems like that commit did not introduce the |
6 | problem, but just uncovered it: The EEPRO100State->tx.tbd_array_addr and | ||
7 | EEPRO100State->tx.tcb_bytes fields are already in host byte order, since | ||
8 | they have already been byte-swapped in the read_cb() function. | ||
9 | Thus byte-swapping them in tx_command() again results in the wrong | ||
10 | endianness. Removing the byte-swapping here fixes the pxe-test. | ||
11 | |||
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 13 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
8 | --- | 14 | --- |
9 | hw/net/virtio-net.c | 2 ++ | 15 | hw/net/eepro100.c | 4 ++-- |
10 | 1 file changed, 2 insertions(+) | 16 | 1 file changed, 2 insertions(+), 2 deletions(-) |
11 | 17 | ||
12 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | 18 | diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c |
13 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/net/virtio-net.c | 20 | --- a/hw/net/eepro100.c |
15 | +++ b/hw/net/virtio-net.c | 21 | +++ b/hw/net/eepro100.c |
16 | @@ -XXX,XX +XXX,XX @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd, | 22 | @@ -XXX,XX +XXX,XX @@ static void read_cb(EEPRO100State *s) |
17 | if (cmd == VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) { | 23 | |
18 | uint64_t supported_offloads; | 24 | static void tx_command(EEPRO100State *s) |
19 | 25 | { | |
20 | + offloads = virtio_ldq_p(vdev, &offloads); | 26 | - uint32_t tbd_array = le32_to_cpu(s->tx.tbd_array_addr); |
21 | + | 27 | - uint16_t tcb_bytes = (le16_to_cpu(s->tx.tcb_bytes) & 0x3fff); |
22 | if (!n->has_vnet_hdr) { | 28 | + uint32_t tbd_array = s->tx.tbd_array_addr; |
23 | return VIRTIO_NET_ERR; | 29 | + uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff; |
24 | } | 30 | /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */ |
31 | uint8_t buf[2600]; | ||
32 | uint16_t size = 0; | ||
25 | -- | 33 | -- |
26 | 2.7.4 | 34 | 2.7.4 |
27 | 35 | ||
28 | 36 | diff view generated by jsdifflib |
1 | From: Michal Privoznik <mprivozn@redhat.com> | 1 | From: Stefan Weil <sw@weilnetz.de> |
---|---|---|---|
2 | 2 | ||
3 | We have a function that checks if given number is power of two. | 3 | Signed-off-by: Stefan Weil <sw@weilnetz.de> |
4 | We should prefer it instead of expanding the check on our own. | ||
5 | |||
6 | Signed-off-by: Michal Privoznik <mprivozn@redhat.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 4 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
8 | --- | 5 | --- |
9 | hw/net/virtio-net.c | 2 +- | 6 | MAINTAINERS | 5 +++++ |
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | 7 | 1 file changed, 5 insertions(+) |
11 | 8 | ||
12 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | 9 | diff --git a/MAINTAINERS b/MAINTAINERS |
13 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/net/virtio-net.c | 11 | --- a/MAINTAINERS |
15 | +++ b/hw/net/virtio-net.c | 12 | +++ b/MAINTAINERS |
16 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) | 13 | @@ -XXX,XX +XXX,XX @@ M: Dmitry Fleytman <dmitry@daynix.com> |
17 | */ | 14 | S: Maintained |
18 | if (n->net_conf.rx_queue_size < VIRTIO_NET_RX_QUEUE_MIN_SIZE || | 15 | F: hw/net/e1000e* |
19 | n->net_conf.rx_queue_size > VIRTQUEUE_MAX_SIZE || | 16 | |
20 | - (n->net_conf.rx_queue_size & (n->net_conf.rx_queue_size - 1))) { | 17 | +eepro100 |
21 | + !is_power_of_2(n->net_conf.rx_queue_size)) { | 18 | +M: Stefan Weil <sw@weilnetz.de> |
22 | error_setg(errp, "Invalid rx_queue_size (= %" PRIu16 "), " | 19 | +S: Maintained |
23 | "must be a power of 2 between %d and %d.", | 20 | +F: hw/net/eepro100.c |
24 | n->net_conf.rx_queue_size, VIRTIO_NET_RX_QUEUE_MIN_SIZE, | 21 | + |
22 | Generic Loader | ||
23 | M: Alistair Francis <alistair.francis@xilinx.com> | ||
24 | S: Maintained | ||
25 | -- | 25 | -- |
26 | 2.7.4 | 26 | 2.7.4 |
27 | 27 | ||
28 | 28 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | From: Ed Swierk <eswierk@skyportsystems.com> |
---|---|---|---|
2 | 2 | ||
3 | We add the vnet_hdr_support option for filter-mirror, default is disabled. | 3 | The checksum algorithm used by IPv4, TCP and UDP allows a zero value |
4 | If you use virtio-net-pci or other driver needs vnet_hdr, please enable it. | 4 | to be represented by either 0x0000 and 0xFFFF. But per RFC 768, a zero |
5 | You can use it for example: | 5 | UDP checksum must be transmitted as 0xFFFF because 0x0000 is a special |
6 | -object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0,vnet_hdr_support | 6 | value meaning no checksum. |
7 | 7 | ||
8 | If it has vnet_hdr_support flag, we will change the sending packet format from | 8 | Substitute 0xFFFF whenever a checksum is computed as zero when |
9 | struct {int size; const uint8_t buf[];} to {int size; int vnet_hdr_len; const uint8_t buf[];}. | 9 | modifying a UDP datagram header. Doing this on IPv4 and TCP checksums |
10 | make other module(like colo-compare) know how to parse net packet correctly. | 10 | is unnecessary but legal. Add a wrapper for net_checksum_finish() that |
11 | makes the substitution. | ||
11 | 12 | ||
12 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 13 | (We can't just change net_checksum_finish(), as that function is also |
14 | used by receivers to verify checksums, and in that case the expected | ||
15 | value is always 0x0000.) | ||
16 | |||
17 | Signed-off-by: Ed Swierk <eswierk@skyportsystems.com> | ||
13 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 18 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
14 | --- | 19 | --- |
15 | net/filter-mirror.c | 42 +++++++++++++++++++++++++++++++++++++++++- | 20 | hw/net/e1000.c | 2 +- |
16 | qemu-options.hx | 5 ++--- | 21 | hw/net/net_rx_pkt.c | 2 +- |
17 | 2 files changed, 43 insertions(+), 4 deletions(-) | 22 | hw/net/net_tx_pkt.c | 2 +- |
23 | hw/net/vmxnet3.c | 3 ++- | ||
24 | include/net/checksum.h | 6 ++++++ | ||
25 | 5 files changed, 11 insertions(+), 4 deletions(-) | ||
18 | 26 | ||
19 | diff --git a/net/filter-mirror.c b/net/filter-mirror.c | 27 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c |
20 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/net/filter-mirror.c | 29 | --- a/hw/net/e1000.c |
22 | +++ b/net/filter-mirror.c | 30 | +++ b/hw/net/e1000.c |
23 | @@ -XXX,XX +XXX,XX @@ typedef struct MirrorState { | 31 | @@ -XXX,XX +XXX,XX @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse) |
24 | CharBackend chr_in; | 32 | n = cse + 1; |
25 | CharBackend chr_out; | 33 | if (sloc < n-1) { |
26 | SocketReadState rs; | 34 | sum = net_checksum_add(n-css, data+css); |
27 | + bool vnet_hdr; | 35 | - stw_be_p(data + sloc, net_checksum_finish(sum)); |
28 | } MirrorState; | 36 | + stw_be_p(data + sloc, net_checksum_finish_nozero(sum)); |
29 | |||
30 | static int filter_send(MirrorState *s, | ||
31 | const struct iovec *iov, | ||
32 | int iovcnt) | ||
33 | { | ||
34 | + NetFilterState *nf = NETFILTER(s); | ||
35 | int ret = 0; | ||
36 | ssize_t size = 0; | ||
37 | uint32_t len = 0; | ||
38 | @@ -XXX,XX +XXX,XX @@ static int filter_send(MirrorState *s, | ||
39 | goto err; | ||
40 | } | ||
41 | |||
42 | + if (s->vnet_hdr) { | ||
43 | + /* | ||
44 | + * If vnet_hdr = on, we send vnet header len to make other | ||
45 | + * module(like colo-compare) know how to parse net | ||
46 | + * packet correctly. | ||
47 | + */ | ||
48 | + ssize_t vnet_hdr_len; | ||
49 | + | ||
50 | + vnet_hdr_len = nf->netdev->vnet_hdr_len; | ||
51 | + | ||
52 | + len = htonl(vnet_hdr_len); | ||
53 | + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len)); | ||
54 | + if (ret != sizeof(len)) { | ||
55 | + goto err; | ||
56 | + } | ||
57 | + } | ||
58 | + | ||
59 | buf = g_malloc(size); | ||
60 | iov_to_buf(iov, iovcnt, 0, buf, size); | ||
61 | ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); | ||
62 | @@ -XXX,XX +XXX,XX @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp) | ||
63 | } | ||
64 | } | ||
65 | |||
66 | - net_socket_rs_init(&s->rs, redirector_rs_finalize, false); | ||
67 | + net_socket_rs_init(&s->rs, redirector_rs_finalize, s->vnet_hdr); | ||
68 | |||
69 | if (s->indev) { | ||
70 | chr = qemu_chr_find(s->indev); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void filter_mirror_set_outdev(Object *obj, | ||
72 | } | 37 | } |
73 | } | 38 | } |
74 | 39 | ||
75 | +static bool filter_mirror_get_vnet_hdr(Object *obj, Error **errp) | 40 | diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c |
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/net/net_rx_pkt.c | ||
43 | +++ b/hw/net/net_rx_pkt.c | ||
44 | @@ -XXX,XX +XXX,XX @@ _net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) | ||
45 | cntr += net_checksum_add_iov(pkt->vec, pkt->vec_len, | ||
46 | pkt->l4hdr_off, csl, cso); | ||
47 | |||
48 | - csum = net_checksum_finish(cntr); | ||
49 | + csum = net_checksum_finish_nozero(cntr); | ||
50 | |||
51 | trace_net_rx_pkt_l4_csum_calc_csum(pkt->l4hdr_off, csl, cntr, csum); | ||
52 | |||
53 | diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/net/net_tx_pkt.c | ||
56 | +++ b/hw/net/net_tx_pkt.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) | ||
58 | net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl, cso); | ||
59 | |||
60 | /* Put the checksum obtained into the packet */ | ||
61 | - csum = cpu_to_be16(net_checksum_finish(csum_cntr)); | ||
62 | + csum = cpu_to_be16(net_checksum_finish_nozero(csum_cntr)); | ||
63 | iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); | ||
64 | } | ||
65 | |||
66 | diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/net/vmxnet3.c | ||
69 | +++ b/hw/net/vmxnet3.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt, | ||
71 | data = (uint8_t *)pkt_data + vhdr->csum_start; | ||
72 | len = pkt_len - vhdr->csum_start; | ||
73 | /* Put the checksum obtained into the packet */ | ||
74 | - stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len)); | ||
75 | + stw_be_p(data + vhdr->csum_offset, | ||
76 | + net_checksum_finish_nozero(net_checksum_add(len, data))); | ||
77 | |||
78 | vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM; | ||
79 | vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID; | ||
80 | diff --git a/include/net/checksum.h b/include/net/checksum.h | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/include/net/checksum.h | ||
83 | +++ b/include/net/checksum.h | ||
84 | @@ -XXX,XX +XXX,XX @@ net_checksum_add(int len, uint8_t *buf) | ||
85 | } | ||
86 | |||
87 | static inline uint16_t | ||
88 | +net_checksum_finish_nozero(uint32_t sum) | ||
76 | +{ | 89 | +{ |
77 | + MirrorState *s = FILTER_MIRROR(obj); | 90 | + return net_checksum_finish(sum) ?: 0xFFFF; |
78 | + | ||
79 | + return s->vnet_hdr; | ||
80 | +} | 91 | +} |
81 | + | 92 | + |
82 | +static void filter_mirror_set_vnet_hdr(Object *obj, bool value, Error **errp) | 93 | +static inline uint16_t |
83 | +{ | 94 | net_raw_checksum(uint8_t *data, int length) |
84 | + MirrorState *s = FILTER_MIRROR(obj); | ||
85 | + | ||
86 | + s->vnet_hdr = value; | ||
87 | +} | ||
88 | + | ||
89 | static char *filter_redirector_get_outdev(Object *obj, Error **errp) | ||
90 | { | 95 | { |
91 | MirrorState *s = FILTER_REDIRECTOR(obj); | 96 | return net_checksum_finish(net_checksum_add(length, data)); |
92 | @@ -XXX,XX +XXX,XX @@ static void filter_redirector_set_outdev(Object *obj, | ||
93 | |||
94 | static void filter_mirror_init(Object *obj) | ||
95 | { | ||
96 | + MirrorState *s = FILTER_MIRROR(obj); | ||
97 | + | ||
98 | object_property_add_str(obj, "outdev", filter_mirror_get_outdev, | ||
99 | filter_mirror_set_outdev, NULL); | ||
100 | + | ||
101 | + s->vnet_hdr = false; | ||
102 | + object_property_add_bool(obj, "vnet_hdr_support", | ||
103 | + filter_mirror_get_vnet_hdr, | ||
104 | + filter_mirror_set_vnet_hdr, NULL); | ||
105 | } | ||
106 | |||
107 | static void filter_redirector_init(Object *obj) | ||
108 | diff --git a/qemu-options.hx b/qemu-options.hx | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/qemu-options.hx | ||
111 | +++ b/qemu-options.hx | ||
112 | @@ -XXX,XX +XXX,XX @@ queue @var{all|rx|tx} is an option that can be applied to any netfilter. | ||
113 | @option{tx}: the filter is attached to the transmit queue of the netdev, | ||
114 | where it will receive packets sent by the netdev. | ||
115 | |||
116 | -@item -object filter-mirror,id=@var{id},netdev=@var{netdevid},outdev=@var{chardevid}[,queue=@var{all|rx|tx}] | ||
117 | +@item -object filter-mirror,id=@var{id},netdev=@var{netdevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support] | ||
118 | |||
119 | -filter-mirror on netdev @var{netdevid},mirror net packet to chardev | ||
120 | -@var{chardevid} | ||
121 | +filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{chardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror packet with vnet_hdr_len. | ||
122 | |||
123 | @item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid}, | ||
124 | outdev=@var{chardevid}[,queue=@var{all|rx|tx}] | ||
125 | -- | 97 | -- |
126 | 2.7.4 | 98 | 2.7.4 |
127 | 99 | ||
128 | 100 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | We can use this property flush and send packet with vnet_hdr_len. | ||
4 | |||
5 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
6 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
7 | --- | ||
8 | net/colo-compare.c | 8 ++++++-- | ||
9 | net/colo.c | 3 ++- | ||
10 | net/colo.h | 4 +++- | ||
11 | net/filter-rewriter.c | 2 +- | ||
12 | 4 files changed, 12 insertions(+), 5 deletions(-) | ||
13 | |||
14 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/net/colo-compare.c | ||
17 | +++ b/net/colo-compare.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode) | ||
19 | Connection *conn; | ||
20 | |||
21 | if (mode == PRIMARY_IN) { | ||
22 | - pkt = packet_new(s->pri_rs.buf, s->pri_rs.packet_len); | ||
23 | + pkt = packet_new(s->pri_rs.buf, | ||
24 | + s->pri_rs.packet_len, | ||
25 | + s->pri_rs.vnet_hdr_len); | ||
26 | } else { | ||
27 | - pkt = packet_new(s->sec_rs.buf, s->sec_rs.packet_len); | ||
28 | + pkt = packet_new(s->sec_rs.buf, | ||
29 | + s->sec_rs.packet_len, | ||
30 | + s->sec_rs.vnet_hdr_len); | ||
31 | } | ||
32 | |||
33 | if (parse_packet_early(pkt)) { | ||
34 | diff --git a/net/colo.c b/net/colo.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/net/colo.c | ||
37 | +++ b/net/colo.c | ||
38 | @@ -XXX,XX +XXX,XX @@ void connection_destroy(void *opaque) | ||
39 | g_slice_free(Connection, conn); | ||
40 | } | ||
41 | |||
42 | -Packet *packet_new(const void *data, int size) | ||
43 | +Packet *packet_new(const void *data, int size, int vnet_hdr_len) | ||
44 | { | ||
45 | Packet *pkt = g_slice_new(Packet); | ||
46 | |||
47 | pkt->data = g_memdup(data, size); | ||
48 | pkt->size = size; | ||
49 | pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST); | ||
50 | + pkt->vnet_hdr_len = vnet_hdr_len; | ||
51 | |||
52 | return pkt; | ||
53 | } | ||
54 | diff --git a/net/colo.h b/net/colo.h | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/net/colo.h | ||
57 | +++ b/net/colo.h | ||
58 | @@ -XXX,XX +XXX,XX @@ typedef struct Packet { | ||
59 | int size; | ||
60 | /* Time of packet creation, in wall clock ms */ | ||
61 | int64_t creation_ms; | ||
62 | + /* Get vnet_hdr_len from filter */ | ||
63 | + uint32_t vnet_hdr_len; | ||
64 | } Packet; | ||
65 | |||
66 | typedef struct ConnectionKey { | ||
67 | @@ -XXX,XX +XXX,XX @@ Connection *connection_get(GHashTable *connection_track_table, | ||
68 | ConnectionKey *key, | ||
69 | GQueue *conn_list); | ||
70 | void connection_hashtable_reset(GHashTable *connection_track_table); | ||
71 | -Packet *packet_new(const void *data, int size); | ||
72 | +Packet *packet_new(const void *data, int size, int vnet_hdr_len); | ||
73 | void packet_destroy(void *opaque, void *user_data); | ||
74 | |||
75 | #endif /* QEMU_COLO_PROXY_H */ | ||
76 | diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/net/filter-rewriter.c | ||
79 | +++ b/net/filter-rewriter.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf, | ||
81 | char *buf = g_malloc0(size); | ||
82 | |||
83 | iov_to_buf(iov, iovcnt, 0, buf, size); | ||
84 | - pkt = packet_new(buf, size); | ||
85 | + pkt = packet_new(buf, size, 0); | ||
86 | g_free(buf); | ||
87 | |||
88 | /* | ||
89 | -- | ||
90 | 2.7.4 | ||
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | This patch change the compare_chr_send() parameter from CharBackend to CompareState, | ||
4 | we can get more information like vnet_hdr(We use it to support packet with vnet_header). | ||
5 | |||
6 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
8 | --- | ||
9 | net/colo-compare.c | 14 +++++++------- | ||
10 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
11 | |||
12 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/net/colo-compare.c | ||
15 | +++ b/net/colo-compare.c | ||
16 | @@ -XXX,XX +XXX,XX @@ enum { | ||
17 | SECONDARY_IN, | ||
18 | }; | ||
19 | |||
20 | -static int compare_chr_send(CharBackend *out, | ||
21 | +static int compare_chr_send(CompareState *s, | ||
22 | const uint8_t *buf, | ||
23 | uint32_t size); | ||
24 | |||
25 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data) | ||
26 | } | ||
27 | |||
28 | if (result) { | ||
29 | - ret = compare_chr_send(&s->chr_out, pkt->data, pkt->size); | ||
30 | + ret = compare_chr_send(s, pkt->data, pkt->size); | ||
31 | if (ret < 0) { | ||
32 | error_report("colo_send_primary_packet failed"); | ||
33 | } | ||
34 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data) | ||
35 | } | ||
36 | } | ||
37 | |||
38 | -static int compare_chr_send(CharBackend *out, | ||
39 | +static int compare_chr_send(CompareState *s, | ||
40 | const uint8_t *buf, | ||
41 | uint32_t size) | ||
42 | { | ||
43 | @@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CharBackend *out, | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | - ret = qemu_chr_fe_write_all(out, (uint8_t *)&len, sizeof(len)); | ||
48 | + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len)); | ||
49 | if (ret != sizeof(len)) { | ||
50 | goto err; | ||
51 | } | ||
52 | |||
53 | - ret = qemu_chr_fe_write_all(out, (uint8_t *)buf, size); | ||
54 | + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); | ||
55 | if (ret != size) { | ||
56 | goto err; | ||
57 | } | ||
58 | @@ -XXX,XX +XXX,XX @@ static void compare_pri_rs_finalize(SocketReadState *pri_rs) | ||
59 | |||
60 | if (packet_enqueue(s, PRIMARY_IN)) { | ||
61 | trace_colo_compare_main("primary: unsupported packet in"); | ||
62 | - compare_chr_send(&s->chr_out, pri_rs->buf, pri_rs->packet_len); | ||
63 | + compare_chr_send(s, pri_rs->buf, pri_rs->packet_len); | ||
64 | } else { | ||
65 | /* compare connection */ | ||
66 | g_queue_foreach(&s->conn_list, colo_compare_connection, s); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data) | ||
68 | |||
69 | while (!g_queue_is_empty(&conn->primary_list)) { | ||
70 | pkt = g_queue_pop_head(&conn->primary_list); | ||
71 | - compare_chr_send(&s->chr_out, pkt->data, pkt->size); | ||
72 | + compare_chr_send(s, pkt->data, pkt->size); | ||
73 | packet_destroy(pkt, NULL); | ||
74 | } | ||
75 | while (!g_queue_is_empty(&conn->secondary_list)) { | ||
76 | -- | ||
77 | 2.7.4 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | We add the vnet_hdr_support option for colo-compare, default is disabled. | ||
4 | If you use virtio-net-pci or other driver needs vnet_hdr, please enable it. | ||
5 | You can use it for example: | ||
6 | -object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,vnet_hdr_support | ||
7 | |||
8 | COLO-compare can get vnet header length from filter, | ||
9 | Add vnet_hdr_len to struct packet and output packet with | ||
10 | the vnet_hdr_len. | ||
11 | |||
12 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
13 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
14 | --- | ||
15 | net/colo-compare.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++------- | ||
16 | qemu-options.hx | 4 ++-- | ||
17 | 2 files changed, 55 insertions(+), 9 deletions(-) | ||
18 | |||
19 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/net/colo-compare.c | ||
22 | +++ b/net/colo-compare.c | ||
23 | @@ -XXX,XX +XXX,XX @@ typedef struct CompareState { | ||
24 | CharBackend chr_out; | ||
25 | SocketReadState pri_rs; | ||
26 | SocketReadState sec_rs; | ||
27 | + bool vnet_hdr; | ||
28 | |||
29 | /* connection list: the connections belonged to this NIC could be found | ||
30 | * in this list. | ||
31 | @@ -XXX,XX +XXX,XX @@ enum { | ||
32 | |||
33 | static int compare_chr_send(CompareState *s, | ||
34 | const uint8_t *buf, | ||
35 | - uint32_t size); | ||
36 | + uint32_t size, | ||
37 | + uint32_t vnet_hdr_len); | ||
38 | |||
39 | static gint seq_sorter(Packet *a, Packet *b, gpointer data) | ||
40 | { | ||
41 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data) | ||
42 | } | ||
43 | |||
44 | if (result) { | ||
45 | - ret = compare_chr_send(s, pkt->data, pkt->size); | ||
46 | + ret = compare_chr_send(s, | ||
47 | + pkt->data, | ||
48 | + pkt->size, | ||
49 | + pkt->vnet_hdr_len); | ||
50 | if (ret < 0) { | ||
51 | error_report("colo_send_primary_packet failed"); | ||
52 | } | ||
53 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data) | ||
54 | |||
55 | static int compare_chr_send(CompareState *s, | ||
56 | const uint8_t *buf, | ||
57 | - uint32_t size) | ||
58 | + uint32_t size, | ||
59 | + uint32_t vnet_hdr_len) | ||
60 | { | ||
61 | int ret = 0; | ||
62 | uint32_t len = htonl(size); | ||
63 | @@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CompareState *s, | ||
64 | goto err; | ||
65 | } | ||
66 | |||
67 | + if (s->vnet_hdr) { | ||
68 | + /* | ||
69 | + * We send vnet header len make other module(like filter-redirector) | ||
70 | + * know how to parse net packet correctly. | ||
71 | + */ | ||
72 | + len = htonl(vnet_hdr_len); | ||
73 | + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len)); | ||
74 | + if (ret != sizeof(len)) { | ||
75 | + goto err; | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); | ||
80 | if (ret != size) { | ||
81 | goto err; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void compare_set_outdev(Object *obj, const char *value, Error **errp) | ||
83 | s->outdev = g_strdup(value); | ||
84 | } | ||
85 | |||
86 | +static bool compare_get_vnet_hdr(Object *obj, Error **errp) | ||
87 | +{ | ||
88 | + CompareState *s = COLO_COMPARE(obj); | ||
89 | + | ||
90 | + return s->vnet_hdr; | ||
91 | +} | ||
92 | + | ||
93 | +static void compare_set_vnet_hdr(Object *obj, | ||
94 | + bool value, | ||
95 | + Error **errp) | ||
96 | +{ | ||
97 | + CompareState *s = COLO_COMPARE(obj); | ||
98 | + | ||
99 | + s->vnet_hdr = value; | ||
100 | +} | ||
101 | + | ||
102 | static void compare_pri_rs_finalize(SocketReadState *pri_rs) | ||
103 | { | ||
104 | CompareState *s = container_of(pri_rs, CompareState, pri_rs); | ||
105 | |||
106 | if (packet_enqueue(s, PRIMARY_IN)) { | ||
107 | trace_colo_compare_main("primary: unsupported packet in"); | ||
108 | - compare_chr_send(s, pri_rs->buf, pri_rs->packet_len); | ||
109 | + compare_chr_send(s, | ||
110 | + pri_rs->buf, | ||
111 | + pri_rs->packet_len, | ||
112 | + pri_rs->vnet_hdr_len); | ||
113 | } else { | ||
114 | /* compare connection */ | ||
115 | g_queue_foreach(&s->conn_list, colo_compare_connection, s); | ||
116 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) | ||
117 | return; | ||
118 | } | ||
119 | |||
120 | - net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, false); | ||
121 | - net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, false); | ||
122 | + net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, s->vnet_hdr); | ||
123 | + net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, s->vnet_hdr); | ||
124 | |||
125 | g_queue_init(&s->conn_list); | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data) | ||
128 | |||
129 | while (!g_queue_is_empty(&conn->primary_list)) { | ||
130 | pkt = g_queue_pop_head(&conn->primary_list); | ||
131 | - compare_chr_send(s, pkt->data, pkt->size); | ||
132 | + compare_chr_send(s, | ||
133 | + pkt->data, | ||
134 | + pkt->size, | ||
135 | + pkt->vnet_hdr_len); | ||
136 | packet_destroy(pkt, NULL); | ||
137 | } | ||
138 | while (!g_queue_is_empty(&conn->secondary_list)) { | ||
139 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_class_init(ObjectClass *oc, void *data) | ||
140 | |||
141 | static void colo_compare_init(Object *obj) | ||
142 | { | ||
143 | + CompareState *s = COLO_COMPARE(obj); | ||
144 | + | ||
145 | object_property_add_str(obj, "primary_in", | ||
146 | compare_get_pri_indev, compare_set_pri_indev, | ||
147 | NULL); | ||
148 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj) | ||
149 | object_property_add_str(obj, "outdev", | ||
150 | compare_get_outdev, compare_set_outdev, | ||
151 | NULL); | ||
152 | + | ||
153 | + s->vnet_hdr = false; | ||
154 | + object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr, | ||
155 | + compare_set_vnet_hdr, NULL); | ||
156 | } | ||
157 | |||
158 | static void colo_compare_finalize(Object *obj) | ||
159 | diff --git a/qemu-options.hx b/qemu-options.hx | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/qemu-options.hx | ||
162 | +++ b/qemu-options.hx | ||
163 | @@ -XXX,XX +XXX,XX @@ Dump the network traffic on netdev @var{dev} to the file specified by | ||
164 | The file format is libpcap, so it can be analyzed with tools such as tcpdump | ||
165 | or Wireshark. | ||
166 | |||
167 | -@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid}, | ||
168 | -outdev=@var{chardevid} | ||
169 | +@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid}[,vnet_hdr_support] | ||
170 | |||
171 | Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@var{chardevid}, than compare primary packet with | ||
172 | secondary packet. If the packets are same, we will output primary | ||
173 | packet to outdev@var{chardevid}, else we will notify colo-frame | ||
174 | do checkpoint and send primary packet to outdev@var{chardevid}. | ||
175 | +if it has the vnet_hdr_support flag, colo compare will send/recv packet with vnet_hdr_len. | ||
176 | |||
177 | we must use it with the help of filter-mirror and filter-redirector. | ||
178 | |||
179 | -- | ||
180 | 2.7.4 | ||
181 | |||
182 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | Make colo-compare and filter-rewriter can parse vnet packet. | ||
4 | |||
5 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
6 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
7 | --- | ||
8 | net/colo.c | 6 +++--- | ||
9 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/net/colo.c b/net/colo.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/net/colo.c | ||
14 | +++ b/net/colo.c | ||
15 | @@ -XXX,XX +XXX,XX @@ int parse_packet_early(Packet *pkt) | ||
16 | { | ||
17 | int network_length; | ||
18 | static const uint8_t vlan[] = {0x81, 0x00}; | ||
19 | - uint8_t *data = pkt->data; | ||
20 | + uint8_t *data = pkt->data + pkt->vnet_hdr_len; | ||
21 | uint16_t l3_proto; | ||
22 | ssize_t l2hdr_len = eth_get_l2_hdr_length(data); | ||
23 | |||
24 | - if (pkt->size < ETH_HLEN) { | ||
25 | + if (pkt->size < ETH_HLEN + pkt->vnet_hdr_len) { | ||
26 | trace_colo_proxy_main("pkt->size < ETH_HLEN"); | ||
27 | return 1; | ||
28 | } | ||
29 | @@ -XXX,XX +XXX,XX @@ int parse_packet_early(Packet *pkt) | ||
30 | } | ||
31 | |||
32 | network_length = pkt->ip->ip_hl * 4; | ||
33 | - if (pkt->size < l2hdr_len + network_length) { | ||
34 | + if (pkt->size < l2hdr_len + network_length + pkt->vnet_hdr_len) { | ||
35 | trace_colo_proxy_main("pkt->size < network_header + network_length"); | ||
36 | return 1; | ||
37 | } | ||
38 | -- | ||
39 | 2.7.4 | ||
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | We add the vnet_hdr_support option for filter-rewriter, default is disabled. | 3 | Since commit ab06ec43577177a442e8 we test the vmxnet3 device in the |
4 | If you use virtio-net-pci or other driver needs vnet_hdr, please enable it. | 4 | pxe-tester, too (when running "make check SPEED=slow"). This now |
5 | You can use it for example: | 5 | revealed that the code is not working there if the host is a big |
6 | -object filter-rewriter,id=rew0,netdev=hn0,queue=all,vnet_hdr_support | 6 | endian machine (for example ppc64 or s390x) - "make check SPEED=slow" |
7 | is now failing on such hosts. | ||
7 | 8 | ||
8 | We get the vnet_hdr_len from NetClientState that make us | 9 | The vmxnet3 code lacks endianness conversions in a couple of places. |
9 | parse net packet correctly. | 10 | Interestingly, the bitfields in the structs in vmxnet3.h already tried to |
11 | take care of the *bit* endianness of the C compilers - but the code missed | ||
12 | to change the *byte* endianness when reading or writing the corresponding | ||
13 | structs. So the bitfields are now wrapped into unions which allow to change | ||
14 | the byte endianness during runtime with the non-bitfield member of the union. | ||
15 | With these changes, "make check SPEED=slow" now properly works on big endian | ||
16 | hosts, too. | ||
10 | 17 | ||
11 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 18 | Reported-by: David Gibson <dgibson@redhat.com> |
19 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Reviewed-by: David Gibson <dgibson@redhat.com> | ||
21 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
12 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 22 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
13 | --- | 23 | --- |
14 | net/filter-rewriter.c | 37 ++++++++++++++++++++++++++++++++++++- | 24 | hw/net/vmware_utils.h | 6 ++ |
15 | qemu-options.hx | 4 ++-- | 25 | hw/net/vmxnet3.c | 46 +++++++--- |
16 | 2 files changed, 38 insertions(+), 3 deletions(-) | 26 | hw/net/vmxnet3.h | 230 ++++++++++++++++++++++++++++++-------------------- |
27 | 3 files changed, 181 insertions(+), 101 deletions(-) | ||
17 | 28 | ||
18 | diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c | 29 | diff --git a/hw/net/vmware_utils.h b/hw/net/vmware_utils.h |
19 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/net/filter-rewriter.c | 31 | --- a/hw/net/vmware_utils.h |
21 | +++ b/net/filter-rewriter.c | 32 | +++ b/hw/net/vmware_utils.h |
22 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ vmw_shmem_ld16(PCIDevice *d, hwaddr addr) |
23 | #include "qemu-common.h" | 34 | { |
24 | #include "qapi/error.h" | 35 | uint16_t res; |
25 | #include "qapi/qmp/qerror.h" | 36 | pci_dma_read(d, addr, &res, 2); |
26 | +#include "qemu/error-report.h" | 37 | + res = le16_to_cpu(res); |
27 | #include "qapi-visit.h" | 38 | VMW_SHPRN("SHMEM load16: %" PRIx64 " (value 0x%X)", addr, res); |
28 | #include "qom/object.h" | 39 | return res; |
29 | #include "qemu/main-loop.h" | 40 | } |
30 | @@ -XXX,XX +XXX,XX @@ typedef struct RewriterState { | 41 | @@ -XXX,XX +XXX,XX @@ static inline void |
31 | NetQueue *incoming_queue; | 42 | vmw_shmem_st16(PCIDevice *d, hwaddr addr, uint16_t value) |
32 | /* hashtable to save connection */ | 43 | { |
33 | GHashTable *connection_track_table; | 44 | VMW_SHPRN("SHMEM store16: %" PRIx64 " (value 0x%X)", addr, value); |
34 | + bool vnet_hdr; | 45 | + value = cpu_to_le16(value); |
35 | } RewriterState; | 46 | pci_dma_write(d, addr, &value, 2); |
36 | 47 | } | |
37 | static void filter_rewriter_flush(NetFilterState *nf) | 48 | |
38 | @@ -XXX,XX +XXX,XX @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf, | 49 | @@ -XXX,XX +XXX,XX @@ vmw_shmem_ld32(PCIDevice *d, hwaddr addr) |
39 | ConnectionKey key; | 50 | { |
40 | Packet *pkt; | 51 | uint32_t res; |
41 | ssize_t size = iov_size(iov, iovcnt); | 52 | pci_dma_read(d, addr, &res, 4); |
42 | + ssize_t vnet_hdr_len = 0; | 53 | + res = le32_to_cpu(res); |
43 | char *buf = g_malloc0(size); | 54 | VMW_SHPRN("SHMEM load32: %" PRIx64 " (value 0x%X)", addr, res); |
44 | 55 | return res; | |
45 | iov_to_buf(iov, iovcnt, 0, buf, size); | 56 | } |
46 | - pkt = packet_new(buf, size, 0); | 57 | @@ -XXX,XX +XXX,XX @@ static inline void |
47 | + | 58 | vmw_shmem_st32(PCIDevice *d, hwaddr addr, uint32_t value) |
48 | + if (s->vnet_hdr) { | 59 | { |
49 | + vnet_hdr_len = nf->netdev->vnet_hdr_len; | 60 | VMW_SHPRN("SHMEM store32: %" PRIx64 " (value 0x%X)", addr, value); |
50 | + } | 61 | + value = cpu_to_le32(value); |
51 | + | 62 | pci_dma_write(d, addr, &value, 4); |
52 | + pkt = packet_new(buf, size, vnet_hdr_len); | 63 | } |
53 | g_free(buf); | 64 | |
54 | 65 | @@ -XXX,XX +XXX,XX @@ vmw_shmem_ld64(PCIDevice *d, hwaddr addr) | |
55 | /* | 66 | { |
56 | @@ -XXX,XX +XXX,XX @@ static void colo_rewriter_setup(NetFilterState *nf, Error **errp) | 67 | uint64_t res; |
57 | s->incoming_queue = qemu_new_net_queue(qemu_netfilter_pass_to_next, nf); | 68 | pci_dma_read(d, addr, &res, 8); |
58 | } | 69 | + res = le64_to_cpu(res); |
59 | 70 | VMW_SHPRN("SHMEM load64: %" PRIx64 " (value %" PRIx64 ")", addr, res); | |
60 | +static bool filter_rewriter_get_vnet_hdr(Object *obj, Error **errp) | 71 | return res; |
72 | } | ||
73 | @@ -XXX,XX +XXX,XX @@ static inline void | ||
74 | vmw_shmem_st64(PCIDevice *d, hwaddr addr, uint64_t value) | ||
75 | { | ||
76 | VMW_SHPRN("SHMEM store64: %" PRIx64 " (value %" PRIx64 ")", addr, value); | ||
77 | + value = cpu_to_le64(value); | ||
78 | pci_dma_write(d, addr, &value, 8); | ||
79 | } | ||
80 | |||
81 | diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/net/vmxnet3.c | ||
84 | +++ b/hw/net/vmxnet3.c | ||
85 | @@ -XXX,XX +XXX,XX @@ vmxnet3_dump_tx_descr(struct Vmxnet3_TxDesc *descr) | ||
86 | "addr %" PRIx64 ", len: %d, gen: %d, rsvd: %d, " | ||
87 | "dtype: %d, ext1: %d, msscof: %d, hlen: %d, om: %d, " | ||
88 | "eop: %d, cq: %d, ext2: %d, ti: %d, tci: %d", | ||
89 | - le64_to_cpu(descr->addr), descr->len, descr->gen, descr->rsvd, | ||
90 | + descr->addr, descr->len, descr->gen, descr->rsvd, | ||
91 | descr->dtype, descr->ext1, descr->msscof, descr->hlen, descr->om, | ||
92 | descr->eop, descr->cq, descr->ext2, descr->ti, descr->tci); | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ vmxnet3_dump_rx_descr(struct Vmxnet3_RxDesc *descr) | ||
95 | { | ||
96 | VMW_PKPRN("RX DESCR: addr %" PRIx64 ", len: %d, gen: %d, rsvd: %d, " | ||
97 | "dtype: %d, ext1: %d, btype: %d", | ||
98 | - le64_to_cpu(descr->addr), descr->len, descr->gen, | ||
99 | + descr->addr, descr->len, descr->gen, | ||
100 | descr->rsvd, descr->dtype, descr->ext1, descr->btype); | ||
101 | } | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ static void vmxnet3_complete_packet(VMXNET3State *s, int qidx, uint32_t tx_ridx) | ||
104 | memset(&txcq_descr, 0, sizeof(txcq_descr)); | ||
105 | txcq_descr.txdIdx = tx_ridx; | ||
106 | txcq_descr.gen = vmxnet3_ring_curr_gen(&s->txq_descr[qidx].comp_ring); | ||
107 | - | ||
108 | + txcq_descr.val1 = cpu_to_le32(txcq_descr.val1); | ||
109 | + txcq_descr.val2 = cpu_to_le32(txcq_descr.val2); | ||
110 | vmxnet3_ring_write_curr_cell(d, &s->txq_descr[qidx].comp_ring, &txcq_descr); | ||
111 | |||
112 | /* Flush changes in TX descriptor before changing the counter value */ | ||
113 | @@ -XXX,XX +XXX,XX @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s, | ||
114 | } | ||
115 | } | ||
116 | |||
117 | +static inline void | ||
118 | +vmxnet3_ring_read_curr_txdesc(PCIDevice *pcidev, Vmxnet3Ring *ring, | ||
119 | + struct Vmxnet3_TxDesc *txd) | ||
61 | +{ | 120 | +{ |
62 | + RewriterState *s = FILTER_COLO_REWRITER(obj); | 121 | + vmxnet3_ring_read_curr_cell(pcidev, ring, txd); |
63 | + | 122 | + txd->addr = le64_to_cpu(txd->addr); |
64 | + return s->vnet_hdr; | 123 | + txd->val1 = le32_to_cpu(txd->val1); |
124 | + txd->val2 = le32_to_cpu(txd->val2); | ||
65 | +} | 125 | +} |
66 | + | 126 | + |
67 | +static void filter_rewriter_set_vnet_hdr(Object *obj, | 127 | static inline bool |
68 | + bool value, | 128 | vmxnet3_pop_next_tx_descr(VMXNET3State *s, |
69 | + Error **errp) | 129 | int qidx, |
130 | @@ -XXX,XX +XXX,XX @@ vmxnet3_pop_next_tx_descr(VMXNET3State *s, | ||
131 | Vmxnet3Ring *ring = &s->txq_descr[qidx].tx_ring; | ||
132 | PCIDevice *d = PCI_DEVICE(s); | ||
133 | |||
134 | - vmxnet3_ring_read_curr_cell(d, ring, txd); | ||
135 | + vmxnet3_ring_read_curr_txdesc(d, ring, txd); | ||
136 | if (txd->gen == vmxnet3_ring_curr_gen(ring)) { | ||
137 | /* Only read after generation field verification */ | ||
138 | smp_rmb(); | ||
139 | /* Re-read to be sure we got the latest version */ | ||
140 | - vmxnet3_ring_read_curr_cell(d, ring, txd); | ||
141 | + vmxnet3_ring_read_curr_txdesc(d, ring, txd); | ||
142 | VMXNET3_RING_DUMP(VMW_RIPRN, "TX", qidx, ring); | ||
143 | *descr_idx = vmxnet3_ring_curr_cell_idx(ring); | ||
144 | vmxnet3_inc_tx_consumption_counter(s, qidx); | ||
145 | @@ -XXX,XX +XXX,XX @@ static void vmxnet3_process_tx_queue(VMXNET3State *s, int qidx) | ||
146 | |||
147 | if (!s->skip_current_tx_pkt) { | ||
148 | data_len = (txd.len > 0) ? txd.len : VMXNET3_MAX_TX_BUF_SIZE; | ||
149 | - data_pa = le64_to_cpu(txd.addr); | ||
150 | + data_pa = txd.addr; | ||
151 | |||
152 | if (!net_tx_pkt_add_raw_fragment(s->tx_pkt, | ||
153 | data_pa, | ||
154 | @@ -XXX,XX +XXX,XX @@ vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx, | ||
155 | Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx]; | ||
156 | *didx = vmxnet3_ring_curr_cell_idx(ring); | ||
157 | vmxnet3_ring_read_curr_cell(d, ring, dbuf); | ||
158 | + dbuf->addr = le64_to_cpu(dbuf->addr); | ||
159 | + dbuf->val1 = le32_to_cpu(dbuf->val1); | ||
160 | + dbuf->ext1 = le32_to_cpu(dbuf->ext1); | ||
161 | } | ||
162 | |||
163 | static inline uint8_t | ||
164 | @@ -XXX,XX +XXX,XX @@ vmxnet3_pop_rxc_descr(VMXNET3State *s, int qidx, uint32_t *descr_gen) | ||
165 | |||
166 | pci_dma_read(PCI_DEVICE(s), | ||
167 | daddr, &rxcd, sizeof(struct Vmxnet3_RxCompDesc)); | ||
168 | + rxcd.val1 = le32_to_cpu(rxcd.val1); | ||
169 | + rxcd.val2 = le32_to_cpu(rxcd.val2); | ||
170 | + rxcd.val3 = le32_to_cpu(rxcd.val3); | ||
171 | ring_gen = vmxnet3_ring_curr_gen(&s->rxq_descr[qidx].comp_ring); | ||
172 | |||
173 | if (rxcd.gen != ring_gen) { | ||
174 | @@ -XXX,XX +XXX,XX @@ vmxnet3_pci_dma_writev(PCIDevice *pci_dev, | ||
175 | } | ||
176 | } | ||
177 | |||
178 | +static void | ||
179 | +vmxnet3_pci_dma_write_rxcd(PCIDevice *pcidev, dma_addr_t pa, | ||
180 | + struct Vmxnet3_RxCompDesc *rxcd) | ||
70 | +{ | 181 | +{ |
71 | + RewriterState *s = FILTER_COLO_REWRITER(obj); | 182 | + rxcd->val1 = cpu_to_le32(rxcd->val1); |
72 | + | 183 | + rxcd->val2 = cpu_to_le32(rxcd->val2); |
73 | + s->vnet_hdr = value; | 184 | + rxcd->val3 = cpu_to_le32(rxcd->val3); |
185 | + pci_dma_write(pcidev, pa, rxcd, sizeof(*rxcd)); | ||
74 | +} | 186 | +} |
75 | + | 187 | + |
76 | +static void filter_rewriter_init(Object *obj) | 188 | static bool |
77 | +{ | 189 | vmxnet3_indicate_packet(VMXNET3State *s) |
78 | + RewriterState *s = FILTER_COLO_REWRITER(obj); | 190 | { |
79 | + | 191 | @@ -XXX,XX +XXX,XX @@ vmxnet3_indicate_packet(VMXNET3State *s) |
80 | + s->vnet_hdr = false; | 192 | } |
81 | + object_property_add_bool(obj, "vnet_hdr_support", | 193 | |
82 | + filter_rewriter_get_vnet_hdr, | 194 | chunk_size = MIN(bytes_left, rxd.len); |
83 | + filter_rewriter_set_vnet_hdr, NULL); | 195 | - vmxnet3_pci_dma_writev(d, data, bytes_copied, |
84 | +} | 196 | - le64_to_cpu(rxd.addr), chunk_size); |
85 | + | 197 | + vmxnet3_pci_dma_writev(d, data, bytes_copied, rxd.addr, chunk_size); |
86 | static void colo_rewriter_class_init(ObjectClass *oc, void *data) | 198 | bytes_copied += chunk_size; |
87 | { | 199 | bytes_left -= chunk_size; |
88 | NetFilterClass *nfc = NETFILTER_CLASS(oc); | 200 | |
89 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo colo_rewriter_info = { | 201 | vmxnet3_dump_rx_descr(&rxd); |
90 | .name = TYPE_FILTER_REWRITER, | 202 | |
91 | .parent = TYPE_NETFILTER, | 203 | if (ready_rxcd_pa != 0) { |
92 | .class_init = colo_rewriter_class_init, | 204 | - pci_dma_write(d, ready_rxcd_pa, &rxcd, sizeof(rxcd)); |
93 | + .instance_init = filter_rewriter_init, | 205 | + vmxnet3_pci_dma_write_rxcd(d, ready_rxcd_pa, &rxcd); |
94 | .instance_size = sizeof(RewriterState), | 206 | } |
207 | |||
208 | memset(&rxcd, 0, sizeof(struct Vmxnet3_RxCompDesc)); | ||
209 | @@ -XXX,XX +XXX,XX @@ vmxnet3_indicate_packet(VMXNET3State *s) | ||
210 | rxcd.eop = 1; | ||
211 | rxcd.err = (bytes_left != 0); | ||
212 | |||
213 | - pci_dma_write(d, ready_rxcd_pa, &rxcd, sizeof(rxcd)); | ||
214 | + vmxnet3_pci_dma_write_rxcd(d, ready_rxcd_pa, &rxcd); | ||
215 | |||
216 | /* Flush RX descriptor changes */ | ||
217 | smp_wmb(); | ||
218 | diff --git a/hw/net/vmxnet3.h b/hw/net/vmxnet3.h | ||
219 | index XXXXXXX..XXXXXXX 100644 | ||
220 | --- a/hw/net/vmxnet3.h | ||
221 | +++ b/hw/net/vmxnet3.h | ||
222 | @@ -XXX,XX +XXX,XX @@ enum { | ||
223 | struct Vmxnet3_TxDesc { | ||
224 | __le64 addr; | ||
225 | |||
226 | + union { | ||
227 | + struct { | ||
228 | #ifdef __BIG_ENDIAN_BITFIELD | ||
229 | - u32 msscof:14; /* MSS, checksum offset, flags */ | ||
230 | - u32 ext1:1; | ||
231 | - u32 dtype:1; /* descriptor type */ | ||
232 | - u32 rsvd:1; | ||
233 | - u32 gen:1; /* generation bit */ | ||
234 | - u32 len:14; | ||
235 | + u32 msscof:14; /* MSS, checksum offset, flags */ | ||
236 | + u32 ext1:1; | ||
237 | + u32 dtype:1; /* descriptor type */ | ||
238 | + u32 rsvd:1; | ||
239 | + u32 gen:1; /* generation bit */ | ||
240 | + u32 len:14; | ||
241 | #else | ||
242 | - u32 len:14; | ||
243 | - u32 gen:1; /* generation bit */ | ||
244 | - u32 rsvd:1; | ||
245 | - u32 dtype:1; /* descriptor type */ | ||
246 | - u32 ext1:1; | ||
247 | - u32 msscof:14; /* MSS, checksum offset, flags */ | ||
248 | + u32 len:14; | ||
249 | + u32 gen:1; /* generation bit */ | ||
250 | + u32 rsvd:1; | ||
251 | + u32 dtype:1; /* descriptor type */ | ||
252 | + u32 ext1:1; | ||
253 | + u32 msscof:14; /* MSS, checksum offset, flags */ | ||
254 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
255 | - | ||
256 | + }; | ||
257 | + u32 val1; | ||
258 | + }; | ||
259 | + | ||
260 | + union { | ||
261 | + struct { | ||
262 | #ifdef __BIG_ENDIAN_BITFIELD | ||
263 | - u32 tci:16; /* Tag to Insert */ | ||
264 | - u32 ti:1; /* VLAN Tag Insertion */ | ||
265 | - u32 ext2:1; | ||
266 | - u32 cq:1; /* completion request */ | ||
267 | - u32 eop:1; /* End Of Packet */ | ||
268 | - u32 om:2; /* offload mode */ | ||
269 | - u32 hlen:10; /* header len */ | ||
270 | + u32 tci:16; /* Tag to Insert */ | ||
271 | + u32 ti:1; /* VLAN Tag Insertion */ | ||
272 | + u32 ext2:1; | ||
273 | + u32 cq:1; /* completion request */ | ||
274 | + u32 eop:1; /* End Of Packet */ | ||
275 | + u32 om:2; /* offload mode */ | ||
276 | + u32 hlen:10; /* header len */ | ||
277 | #else | ||
278 | - u32 hlen:10; /* header len */ | ||
279 | - u32 om:2; /* offload mode */ | ||
280 | - u32 eop:1; /* End Of Packet */ | ||
281 | - u32 cq:1; /* completion request */ | ||
282 | - u32 ext2:1; | ||
283 | - u32 ti:1; /* VLAN Tag Insertion */ | ||
284 | - u32 tci:16; /* Tag to Insert */ | ||
285 | + u32 hlen:10; /* header len */ | ||
286 | + u32 om:2; /* offload mode */ | ||
287 | + u32 eop:1; /* End Of Packet */ | ||
288 | + u32 cq:1; /* completion request */ | ||
289 | + u32 ext2:1; | ||
290 | + u32 ti:1; /* VLAN Tag Insertion */ | ||
291 | + u32 tci:16; /* Tag to Insert */ | ||
292 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
293 | + }; | ||
294 | + u32 val2; | ||
295 | + }; | ||
95 | }; | 296 | }; |
96 | 297 | ||
97 | diff --git a/qemu-options.hx b/qemu-options.hx | 298 | /* TxDesc.OM values */ |
98 | index XXXXXXX..XXXXXXX 100644 | 299 | @@ -XXX,XX +XXX,XX @@ struct Vmxnet3_TxDataDesc { |
99 | --- a/qemu-options.hx | 300 | #define VMXNET3_TCD_GEN_DWORD_SHIFT 3 |
100 | +++ b/qemu-options.hx | 301 | |
101 | @@ -XXX,XX +XXX,XX @@ Create a filter-redirector we need to differ outdev id from indev id, id can not | 302 | struct Vmxnet3_TxCompDesc { |
102 | be the same. we can just use indev or outdev, but at least one of indev or outdev | 303 | - u32 txdIdx:12; /* Index of the EOP TxDesc */ |
103 | need to be specified. | 304 | - u32 ext1:20; |
104 | 305 | - | |
105 | -@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid}[,queue=@var{all|rx|tx}] | 306 | + union { |
106 | +@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},queue=@var{all|rx|tx},[vnet_hdr_support] | 307 | + struct { |
107 | 308 | +#ifdef __BIG_ENDIAN_BITFIELD | |
108 | Filter-rewriter is a part of COLO project.It will rewrite tcp packet to | 309 | + u32 ext1:20; |
109 | secondary from primary to keep secondary tcp connection,and rewrite | 310 | + u32 txdIdx:12; /* Index of the EOP TxDesc */ |
110 | tcp packet to primary from secondary make tcp packet can be handled by | 311 | +#else |
111 | -client. | 312 | + u32 txdIdx:12; /* Index of the EOP TxDesc */ |
112 | +client.if it has the vnet_hdr_support flag, we can parse packet with vnet header. | 313 | + u32 ext1:20; |
113 | 314 | +#endif | |
114 | usage: | 315 | + }; |
115 | colo secondary: | 316 | + u32 val1; |
317 | + }; | ||
318 | __le32 ext2; | ||
319 | __le32 ext3; | ||
320 | |||
321 | - u32 rsvd:24; | ||
322 | - u32 type:7; /* completion type */ | ||
323 | - u32 gen:1; /* generation bit */ | ||
324 | + union { | ||
325 | + struct { | ||
326 | +#ifdef __BIG_ENDIAN_BITFIELD | ||
327 | + u32 gen:1; /* generation bit */ | ||
328 | + u32 type:7; /* completion type */ | ||
329 | + u32 rsvd:24; | ||
330 | +#else | ||
331 | + u32 rsvd:24; | ||
332 | + u32 type:7; /* completion type */ | ||
333 | + u32 gen:1; /* generation bit */ | ||
334 | +#endif | ||
335 | + }; | ||
336 | + u32 val2; | ||
337 | + }; | ||
338 | }; | ||
339 | |||
340 | struct Vmxnet3_RxDesc { | ||
341 | __le64 addr; | ||
342 | - | ||
343 | + union { | ||
344 | + struct { | ||
345 | #ifdef __BIG_ENDIAN_BITFIELD | ||
346 | - u32 gen:1; /* Generation bit */ | ||
347 | - u32 rsvd:15; | ||
348 | - u32 dtype:1; /* Descriptor type */ | ||
349 | - u32 btype:1; /* Buffer Type */ | ||
350 | - u32 len:14; | ||
351 | + u32 gen:1; /* Generation bit */ | ||
352 | + u32 rsvd:15; | ||
353 | + u32 dtype:1; /* Descriptor type */ | ||
354 | + u32 btype:1; /* Buffer Type */ | ||
355 | + u32 len:14; | ||
356 | #else | ||
357 | - u32 len:14; | ||
358 | - u32 btype:1; /* Buffer Type */ | ||
359 | - u32 dtype:1; /* Descriptor type */ | ||
360 | - u32 rsvd:15; | ||
361 | - u32 gen:1; /* Generation bit */ | ||
362 | + u32 len:14; | ||
363 | + u32 btype:1; /* Buffer Type */ | ||
364 | + u32 dtype:1; /* Descriptor type */ | ||
365 | + u32 rsvd:15; | ||
366 | + u32 gen:1; /* Generation bit */ | ||
367 | #endif | ||
368 | + }; | ||
369 | + u32 val1; | ||
370 | + }; | ||
371 | u32 ext1; | ||
372 | }; | ||
373 | |||
374 | @@ -XXX,XX +XXX,XX @@ struct Vmxnet3_RxDesc { | ||
375 | #define VMXNET3_RXD_GEN_SHIFT 31 | ||
376 | |||
377 | struct Vmxnet3_RxCompDesc { | ||
378 | + union { | ||
379 | + struct { | ||
380 | #ifdef __BIG_ENDIAN_BITFIELD | ||
381 | - u32 ext2:1; | ||
382 | - u32 cnc:1; /* Checksum Not Calculated */ | ||
383 | - u32 rssType:4; /* RSS hash type used */ | ||
384 | - u32 rqID:10; /* rx queue/ring ID */ | ||
385 | - u32 sop:1; /* Start of Packet */ | ||
386 | - u32 eop:1; /* End of Packet */ | ||
387 | - u32 ext1:2; | ||
388 | - u32 rxdIdx:12; /* Index of the RxDesc */ | ||
389 | + u32 ext2:1; | ||
390 | + u32 cnc:1; /* Checksum Not Calculated */ | ||
391 | + u32 rssType:4; /* RSS hash type used */ | ||
392 | + u32 rqID:10; /* rx queue/ring ID */ | ||
393 | + u32 sop:1; /* Start of Packet */ | ||
394 | + u32 eop:1; /* End of Packet */ | ||
395 | + u32 ext1:2; | ||
396 | + u32 rxdIdx:12; /* Index of the RxDesc */ | ||
397 | #else | ||
398 | - u32 rxdIdx:12; /* Index of the RxDesc */ | ||
399 | - u32 ext1:2; | ||
400 | - u32 eop:1; /* End of Packet */ | ||
401 | - u32 sop:1; /* Start of Packet */ | ||
402 | - u32 rqID:10; /* rx queue/ring ID */ | ||
403 | - u32 rssType:4; /* RSS hash type used */ | ||
404 | - u32 cnc:1; /* Checksum Not Calculated */ | ||
405 | - u32 ext2:1; | ||
406 | + u32 rxdIdx:12; /* Index of the RxDesc */ | ||
407 | + u32 ext1:2; | ||
408 | + u32 eop:1; /* End of Packet */ | ||
409 | + u32 sop:1; /* Start of Packet */ | ||
410 | + u32 rqID:10; /* rx queue/ring ID */ | ||
411 | + u32 rssType:4; /* RSS hash type used */ | ||
412 | + u32 cnc:1; /* Checksum Not Calculated */ | ||
413 | + u32 ext2:1; | ||
414 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
415 | + }; | ||
416 | + u32 val1; | ||
417 | + }; | ||
418 | |||
419 | __le32 rssHash; /* RSS hash value */ | ||
420 | |||
421 | + union { | ||
422 | + struct { | ||
423 | #ifdef __BIG_ENDIAN_BITFIELD | ||
424 | - u32 tci:16; /* Tag stripped */ | ||
425 | - u32 ts:1; /* Tag is stripped */ | ||
426 | - u32 err:1; /* Error */ | ||
427 | - u32 len:14; /* data length */ | ||
428 | + u32 tci:16; /* Tag stripped */ | ||
429 | + u32 ts:1; /* Tag is stripped */ | ||
430 | + u32 err:1; /* Error */ | ||
431 | + u32 len:14; /* data length */ | ||
432 | #else | ||
433 | - u32 len:14; /* data length */ | ||
434 | - u32 err:1; /* Error */ | ||
435 | - u32 ts:1; /* Tag is stripped */ | ||
436 | - u32 tci:16; /* Tag stripped */ | ||
437 | + u32 len:14; /* data length */ | ||
438 | + u32 err:1; /* Error */ | ||
439 | + u32 ts:1; /* Tag is stripped */ | ||
440 | + u32 tci:16; /* Tag stripped */ | ||
441 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
442 | + }; | ||
443 | + u32 val2; | ||
444 | + }; | ||
445 | |||
446 | - | ||
447 | + union { | ||
448 | + struct { | ||
449 | #ifdef __BIG_ENDIAN_BITFIELD | ||
450 | - u32 gen:1; /* generation bit */ | ||
451 | - u32 type:7; /* completion type */ | ||
452 | - u32 fcs:1; /* Frame CRC correct */ | ||
453 | - u32 frg:1; /* IP Fragment */ | ||
454 | - u32 v4:1; /* IPv4 */ | ||
455 | - u32 v6:1; /* IPv6 */ | ||
456 | - u32 ipc:1; /* IP Checksum Correct */ | ||
457 | - u32 tcp:1; /* TCP packet */ | ||
458 | - u32 udp:1; /* UDP packet */ | ||
459 | - u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
460 | - u32 csum:16; | ||
461 | + u32 gen:1; /* generation bit */ | ||
462 | + u32 type:7; /* completion type */ | ||
463 | + u32 fcs:1; /* Frame CRC correct */ | ||
464 | + u32 frg:1; /* IP Fragment */ | ||
465 | + u32 v4:1; /* IPv4 */ | ||
466 | + u32 v6:1; /* IPv6 */ | ||
467 | + u32 ipc:1; /* IP Checksum Correct */ | ||
468 | + u32 tcp:1; /* TCP packet */ | ||
469 | + u32 udp:1; /* UDP packet */ | ||
470 | + u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
471 | + u32 csum:16; | ||
472 | #else | ||
473 | - u32 csum:16; | ||
474 | - u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
475 | - u32 udp:1; /* UDP packet */ | ||
476 | - u32 tcp:1; /* TCP packet */ | ||
477 | - u32 ipc:1; /* IP Checksum Correct */ | ||
478 | - u32 v6:1; /* IPv6 */ | ||
479 | - u32 v4:1; /* IPv4 */ | ||
480 | - u32 frg:1; /* IP Fragment */ | ||
481 | - u32 fcs:1; /* Frame CRC correct */ | ||
482 | - u32 type:7; /* completion type */ | ||
483 | - u32 gen:1; /* generation bit */ | ||
484 | + u32 csum:16; | ||
485 | + u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
486 | + u32 udp:1; /* UDP packet */ | ||
487 | + u32 tcp:1; /* TCP packet */ | ||
488 | + u32 ipc:1; /* IP Checksum Correct */ | ||
489 | + u32 v6:1; /* IPv6 */ | ||
490 | + u32 v4:1; /* IPv4 */ | ||
491 | + u32 frg:1; /* IP Fragment */ | ||
492 | + u32 fcs:1; /* Frame CRC correct */ | ||
493 | + u32 type:7; /* completion type */ | ||
494 | + u32 gen:1; /* generation bit */ | ||
495 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
496 | + }; | ||
497 | + u32 val3; | ||
498 | + }; | ||
499 | }; | ||
500 | |||
501 | /* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */ | ||
116 | -- | 502 | -- |
117 | 2.7.4 | 503 | 2.7.4 |
118 | 504 | ||
119 | 505 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
4 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
5 | --- | ||
6 | docs/colo-proxy.txt | 26 ++++++++++++++++++++++++++ | ||
7 | 1 file changed, 26 insertions(+) | ||
8 | |||
9 | diff --git a/docs/colo-proxy.txt b/docs/colo-proxy.txt | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/docs/colo-proxy.txt | ||
12 | +++ b/docs/colo-proxy.txt | ||
13 | @@ -XXX,XX +XXX,XX @@ Secondary(ip:3.3.3.8): | ||
14 | -chardev socket,id=red1,host=3.3.3.3,port=9004 | ||
15 | -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0 | ||
16 | -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1 | ||
17 | +-object filter-rewriter,id=f3,netdev=hn0,queue=all | ||
18 | + | ||
19 | +If you want to use virtio-net-pci or other driver with vnet_header: | ||
20 | + | ||
21 | +Primary(ip:3.3.3.3): | ||
22 | +-netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown | ||
23 | +-device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66 | ||
24 | +-chardev socket,id=mirror0,host=3.3.3.3,port=9003,server,nowait | ||
25 | +-chardev socket,id=compare1,host=3.3.3.3,port=9004,server,nowait | ||
26 | +-chardev socket,id=compare0,host=3.3.3.3,port=9001,server,nowait | ||
27 | +-chardev socket,id=compare0-0,host=3.3.3.3,port=9001 | ||
28 | +-chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait | ||
29 | +-chardev socket,id=compare_out0,host=3.3.3.3,port=9005 | ||
30 | +-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0,vnet_hdr_support | ||
31 | +-object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out,vnet_hdr_support | ||
32 | +-object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0,vnet_hdr_support | ||
33 | +-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,vnet_hdr_support | ||
34 | + | ||
35 | +Secondary(ip:3.3.3.8): | ||
36 | +-netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown | ||
37 | +-device e1000,netdev=hn0,mac=52:a4:00:12:78:66 | ||
38 | +-chardev socket,id=red0,host=3.3.3.3,port=9003 | ||
39 | +-chardev socket,id=red1,host=3.3.3.3,port=9004 | ||
40 | +-object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0,vnet_hdr_support | ||
41 | +-object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1,vnet_hdr_support | ||
42 | +-object filter-rewriter,id=f3,netdev=hn0,queue=all,vnet_hdr_support | ||
43 | |||
44 | Note: | ||
45 | a.COLO-proxy must work with COLO-frame and Block-replication. | ||
46 | -- | ||
47 | 2.7.4 | ||
48 | |||
49 | diff view generated by jsdifflib |