1
The following changes since commit cda4a338c4243fa3bff4498b935340ac7121cc76:
1
The following changes since commit 2a95551e8b1456aa53ce54fac573df18809340a6:
2
2
3
tcg/tci: Add TCG_TARGET_DEFAULT_MO (2017-09-07 18:57:34 +0100)
3
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200330' into staging (2020-03-31 11:20:21 +0100)
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 861d51e62bb197b43606f888dbefbabebaf0d854:
9
for you to fetch changes up to 1153cf9f5b67fad41ca6f8571e9a26e2c7c70759:
10
10
11
colo-compare: Update the COLO document to add the IOThread configuration (2017-09-08 09:34:40 +0800)
11
qtest: add tulip test case (2020-03-31 21:14:35 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
Changes from V1:
16
17
- fix the compiling error
18
- include qtest for tulip OOB
19
15
----------------------------------------------------------------
20
----------------------------------------------------------------
16
Kamil Rytarowski (1):
21
Andrew Melnychenko (1):
17
e1000: Rename the SEC symbol to SEQEC
22
Fixed integer overflow in e1000e
18
23
19
Mao Zhongyi (8):
24
Li Qiang (1):
20
net/rocker: Remove the dead error handling
25
qtest: add tulip test case
21
net/rocker: Plug memory leak in pci_rocker_init()
22
net/rocker: Convert to realize()
23
net/rocker: Fix the unusual macro name
24
net/socket: Don't treat odd socket type as SOCK_STREAM
25
net/socket: Convert several helper functions to Error
26
net/net: Convert parse_host_port() to Error
27
net/socket: Improve -net socket error reporting
28
26
29
Matt Parker (1):
27
Peter Maydell (2):
30
net: rtl8139: do not use old_mmio accesses
28
hw/net/i82596.c: Avoid reading off end of buffer in i82596_receive()
29
hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads
31
30
32
Wang Yong (3):
31
Philippe Mathieu-Daudé (7):
33
qemu-iothread: IOThread supports the GMainContext event loop
32
hw/net/i82596: Correct command bitmask (CID 1419392)
34
colo-compare: Use IOThread to Check old packet regularly and Process pactkets of the primary
33
hw/net/e1000e_core: Let e1000e_can_receive() return a boolean
35
colo-compare: Update the COLO document to add the IOThread configuration
34
hw/net/smc91c111: Let smc91c111_can_receive() return a boolean
35
hw/net/rtl8139: Simplify if/else statement
36
hw/net/rtl8139: Update coding style to make checkpatch.pl happy
37
hw/net: Make NetCanReceive() return a boolean
38
hw/net/can: Make CanBusClientInfo::can_receive() return a boolean
36
39
37
Zhang Chen (5):
40
Prasad J Pandit (1):
38
net/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net
41
net: tulip: check frame size and r/w data length
39
MAINTAINERS: Update mail address for COLO Proxy
40
net/colo-compare.c: Optimize unpredictable tcp options comparison
41
net/colo-compare.c: Adjust net queue pop order for performance
42
net/colo-compare.c: Fix comments and scheme
43
42
44
MAINTAINERS | 2 +-
43
Zhang Chen (2):
45
docs/colo-proxy.txt | 3 +-
44
net/colo-compare.c: Expose "compare_timeout" to users
46
hw/net/e1000.c | 4 +-
45
net/colo-compare.c: Expose "expired_scan_cycle" to users
47
hw/net/e1000_regs.h | 2 +-
46
48
hw/net/e1000e_core.c | 2 +-
47
hw/net/allwinner-sun8i-emac.c | 14 +++----
49
hw/net/e1000x_common.h | 2 +-
48
hw/net/allwinner_emac.c | 2 +-
50
hw/net/rocker/rocker.c | 94 ++++++----------------
49
hw/net/cadence_gem.c | 8 ++--
51
hw/net/rocker/rocker_desc.c | 10 ---
50
hw/net/can/can_sja1000.c | 8 ++--
52
hw/net/rocker/rocker_fp.c | 4 -
51
hw/net/can/can_sja1000.h | 2 +-
53
hw/net/rocker/rocker_of_dpa.c | 20 -----
52
hw/net/dp8393x.c | 8 ++--
54
hw/net/rocker/rocker_world.c | 12 ++-
53
hw/net/e1000.c | 2 +-
55
hw/net/rtl8139.c | 53 +-----------
54
hw/net/e1000e.c | 4 +-
56
include/qemu/sockets.h | 3 +-
55
hw/net/e1000e_core.c | 2 +-
57
include/sysemu/iothread.h | 4 +
56
hw/net/e1000e_core.h | 2 +-
58
iothread.c | 45 +++++++++++
57
hw/net/ftgmac100.c | 6 +--
59
net/colo-compare.c | 183 ++++++++++++++++++++++++------------------
58
hw/net/i82596.c | 66 ++++++++++++++++++++----------
60
net/filter-rewriter.c | 6 +-
59
hw/net/i82596.h | 2 +-
61
net/net.c | 22 +++--
60
hw/net/imx_fec.c | 2 +-
62
net/socket.c | 156 +++++++++++++++++++----------------
61
hw/net/opencores_eth.c | 5 +--
63
19 files changed, 304 insertions(+), 323 deletions(-)
62
hw/net/rtl8139.c | 22 +++++-----
63
hw/net/smc91c111.c | 10 ++---
64
hw/net/spapr_llan.c | 4 +-
65
hw/net/sungem.c | 6 +--
66
hw/net/sunhme.c | 4 +-
67
hw/net/tulip.c | 36 ++++++++++++----
68
hw/net/virtio-net.c | 10 ++---
69
hw/net/xilinx_ethlite.c | 2 +-
70
include/net/can_emu.h | 2 +-
71
include/net/net.h | 2 +-
72
net/can/can_socketcan.c | 4 +-
73
net/colo-compare.c | 95 ++++++++++++++++++++++++++++++++++++++++---
74
net/filter-buffer.c | 2 +-
75
net/hub.c | 6 +--
76
qemu-options.hx | 10 +++--
77
tests/qtest/Makefile.include | 1 +
78
tests/qtest/tulip-test.c | 91 +++++++++++++++++++++++++++++++++++++++++
79
32 files changed, 328 insertions(+), 112 deletions(-)
80
create mode 100644 tests/qtest/tulip-test.c
64
81
65
82
diff view generated by jsdifflib
1
From: Wang Yong <wang.yong155@zte.com.cn>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Update colo-proxy.txt,add IOThread configuration.
3
The command is 32-bit, but we are loading the 16 upper bits with
4
Later we have to configure IOThread,if not COLO can not work.
4
the 'get_uint16(s->scb + 2)' call.
5
5
6
Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
Once shifted by 16, the command bits match the status bits:
7
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
7
8
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
8
- Command
9
Bit 31 ACK-CX Acknowledges that the CU completed an Action Command.
10
Bit 30 ACK-FR Acknowledges that the RU received a frame.
11
Bit 29 ACK-CNA Acknowledges that the Command Unit became not active.
12
Bit 28 ACK-RNR Acknowledges that the Receive Unit became not ready.
13
14
- Status
15
Bit 15 CX The CU finished executing a command with its I(interrupt) bit set.
16
Bit 14 FR The RU finished receiving a frame.
17
Bit 13 CNA The Command Unit left the Active state.
18
Bit 12 RNR The Receive Unit left the Ready state.
19
20
Add the SCB_COMMAND_ACK_MASK definition to simplify the code.
21
22
This fixes Coverity 1419392 (CONSTANT_EXPRESSION_RESULT):
23
24
/hw/net/i82596.c: 352 in examine_scb()
25
346 cuc = (command >> 8) & 0x7;
26
347 ruc = (command >> 4) & 0x7;
27
348 DBG(printf("MAIN COMMAND %04x cuc %02x ruc %02x\n", command, cuc, ruc));
28
349 /* and clear the scb command word */
29
350 set_uint16(s->scb + 2, 0);
30
351
31
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
32
>>> "command & (2147483648UL /* 1UL << 31 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
33
352 if (command & BIT(31)) /* ACK-CX */
34
353 s->scb_status &= ~SCB_STATUS_CX;
35
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
36
>>> "command & (1073741824UL /* 1UL << 30 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
37
354 if (command & BIT(30)) /*ACK-FR */
38
355 s->scb_status &= ~SCB_STATUS_FR;
39
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
40
>>> "command & (536870912UL /* 1UL << 29 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
41
356 if (command & BIT(29)) /*ACK-CNA */
42
357 s->scb_status &= ~SCB_STATUS_CNA;
43
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
44
>>> "command & (268435456UL /* 1UL << 28 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
45
358 if (command & BIT(28)) /*ACK-RNR */
46
359 s->scb_status &= ~SCB_STATUS_RNR;
47
48
Fixes: Covertiy CID 1419392 (commit 376b851909)
49
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
50
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
51
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
52
---
11
docs/colo-proxy.txt | 3 ++-
53
hw/net/i82596.c | 12 ++++--------
12
1 file changed, 2 insertions(+), 1 deletion(-)
54
1 file changed, 4 insertions(+), 8 deletions(-)
13
55
14
diff --git a/docs/colo-proxy.txt b/docs/colo-proxy.txt
56
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
15
index XXXXXXX..XXXXXXX 100644
57
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/colo-proxy.txt
58
--- a/hw/net/i82596.c
17
+++ b/docs/colo-proxy.txt
59
+++ b/hw/net/i82596.c
18
@@ -XXX,XX +XXX,XX @@ Primary(ip:3.3.3.3):
60
@@ -XXX,XX +XXX,XX @@
19
-chardev socket,id=compare0-0,host=3.3.3.3,port=9001
61
#define SCB_STATUS_CNA 0x2000 /* CU left active state */
20
-chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait
62
#define SCB_STATUS_RNR 0x1000 /* RU left active state */
21
-chardev socket,id=compare_out0,host=3.3.3.3,port=9005
63
22
+-object iothread,id=iothread1
64
+#define SCB_COMMAND_ACK_MASK \
23
-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
65
+ (SCB_STATUS_CX | SCB_STATUS_FR | SCB_STATUS_CNA | SCB_STATUS_RNR)
24
-object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
66
+
25
-object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
67
#define CU_IDLE 0
26
--object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0
68
#define CU_SUSPENDED 1
27
+-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,iothread=iothread1
69
#define CU_ACTIVE 2
28
70
@@ -XXX,XX +XXX,XX @@ static void examine_scb(I82596State *s)
29
Secondary(ip:3.3.3.8):
71
/* and clear the scb command word */
30
-netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown
72
set_uint16(s->scb + 2, 0);
73
74
- if (command & BIT(31)) /* ACK-CX */
75
- s->scb_status &= ~SCB_STATUS_CX;
76
- if (command & BIT(30)) /*ACK-FR */
77
- s->scb_status &= ~SCB_STATUS_FR;
78
- if (command & BIT(29)) /*ACK-CNA */
79
- s->scb_status &= ~SCB_STATUS_CNA;
80
- if (command & BIT(28)) /*ACK-RNR */
81
- s->scb_status &= ~SCB_STATUS_RNR;
82
+ s->scb_status &= ~(command & SCB_COMMAND_ACK_MASK);
83
84
switch (cuc) {
85
case 0: /* no change */
31
--
86
--
32
2.7.4
87
2.5.0
33
88
34
89
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
Because vnet_hdr have a offset to net packet, we must add it when use
3
The i82596_receive() function attempts to pass the guest a buffer
4
virtio-net.
4
which is effectively the concatenation of the data it is passed and a
5
4 byte CRC value. However, rather than implementing this as "write
6
the data; then write the CRC" it instead bumps the length value of
7
the data by 4, and writes 4 extra bytes from beyond the end of the
8
buffer, which it then overwrites with the CRC. It also assumed that
9
we could always fit all four bytes of the CRC into the final receive
10
buffer, which might not be true if the CRC needs to be split over two
11
receive buffers.
5
12
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
13
Calculate separately how many bytes we need to transfer into the
14
guest's receive buffer from the source buffer, and how many we need
15
to transfer from the CRC work.
16
17
We add a count 'bufsz' of the number of bytes left in the source
18
buffer, which we use purely to assert() that we don't overrun.
19
20
Spotted by Coverity (CID 1419396) for the specific case when we end
21
up using a local array as the source buffer.
22
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
25
---
9
net/filter-rewriter.c | 6 ++++--
26
hw/net/i82596.c | 44 +++++++++++++++++++++++++++++++++++---------
10
1 file changed, 4 insertions(+), 2 deletions(-)
27
1 file changed, 35 insertions(+), 9 deletions(-)
11
28
12
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
29
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
13
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
14
--- a/net/filter-rewriter.c
31
--- a/hw/net/i82596.c
15
+++ b/net/filter-rewriter.c
32
+++ b/hw/net/i82596.c
16
@@ -XXX,XX +XXX,XX @@ static int handle_primary_tcp_pkt(NetFilterState *nf,
33
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
17
/* handle packets to the secondary from the primary */
34
uint32_t rfd_p;
18
tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset);
35
uint32_t rbd;
19
36
uint16_t is_broadcast = 0;
20
- net_checksum_calculate((uint8_t *)pkt->data, pkt->size);
37
- size_t len = sz;
21
+ net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len,
38
+ size_t len = sz; /* length of data for guest (including CRC) */
22
+ pkt->size - pkt->vnet_hdr_len);
39
+ size_t bufsz = sz; /* length of data in buf */
40
uint32_t crc;
41
uint8_t *crc_ptr;
42
uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];
43
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
44
if (len < MIN_BUF_SIZE) {
45
len = MIN_BUF_SIZE;
23
}
46
}
47
+ bufsz = len;
24
}
48
}
25
49
26
@@ -XXX,XX +XXX,XX @@ static int handle_secondary_tcp_pkt(NetFilterState *nf,
50
/* Calculate the ethernet checksum (4 bytes) */
27
/* handle packets to the primary from the secondary*/
51
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
28
tcp_pkt->th_seq = htonl(ntohl(tcp_pkt->th_seq) - conn->offset);
52
while (len) {
29
53
uint16_t buffer_size, num;
30
- net_checksum_calculate((uint8_t *)pkt->data, pkt->size);
54
uint32_t rba;
31
+ net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len,
55
+ size_t bufcount, crccount;
32
+ pkt->size - pkt->vnet_hdr_len);
56
33
}
57
/* printf("Receive: rbd is %08x\n", rbd); */
34
}
58
buffer_size = get_uint16(rbd + 12);
35
59
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
60
}
61
rba = get_uint32(rbd + 8);
62
/* printf("rba is 0x%x\n", rba); */
63
- address_space_write(&address_space_memory, rba,
64
- MEMTXATTRS_UNSPECIFIED, buf, num);
65
- rba += num;
66
- buf += num;
67
- len -= num;
68
- if (len == 0) { /* copy crc */
69
- address_space_write(&address_space_memory, rba - 4,
70
- MEMTXATTRS_UNSPECIFIED, crc_ptr, 4);
71
+ /*
72
+ * Calculate how many bytes we want from buf[] and how many
73
+ * from the CRC.
74
+ */
75
+ if ((len - num) >= 4) {
76
+ /* The whole guest buffer, we haven't hit the CRC yet */
77
+ bufcount = num;
78
+ } else {
79
+ /* All that's left of buf[] */
80
+ bufcount = len - 4;
81
+ }
82
+ crccount = num - bufcount;
83
+
84
+ if (bufcount > 0) {
85
+ /* Still some of the actual data buffer to transfer */
86
+ assert(bufsz >= bufcount);
87
+ bufsz -= bufcount;
88
+ address_space_write(&address_space_memory, rba,
89
+ MEMTXATTRS_UNSPECIFIED, buf, bufcount);
90
+ rba += bufcount;
91
+ buf += bufcount;
92
+ len -= bufcount;
93
+ }
94
+
95
+ /* Write as much of the CRC as fits */
96
+ if (crccount > 0) {
97
+ address_space_write(&address_space_memory, rba,
98
+ MEMTXATTRS_UNSPECIFIED, crc_ptr, crccount);
99
+ rba += crccount;
100
+ crc_ptr += crccount;
101
+ len -= crccount;
102
}
103
104
num |= 0x4000; /* set F BIT */
36
--
105
--
37
2.7.4
106
2.5.0
38
107
39
108
diff view generated by jsdifflib
Deleted patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
1
3
Memory allocation functions like world_alloc, desc_ring_alloc etc,
4
they are all wrappers around g_malloc, g_new etc. But g_malloc and
5
similar functions doesn't return null. Because they ignore the fact
6
that g_malloc() of 0 bytes returns null. So error checks for these
7
allocation failure are superfluous. Now, remove them entirely.
8
9
Cc: jasowang@redhat.com
10
Cc: jiri@resnulli.us
11
Cc: armbru@redhat.com
12
Cc: f4bug@amsat.org
13
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
15
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
---
17
hw/net/rocker/rocker.c | 47 +------------------------------------------
18
hw/net/rocker/rocker_desc.c | 10 ---------
19
hw/net/rocker/rocker_fp.c | 4 ----
20
hw/net/rocker/rocker_of_dpa.c | 20 ------------------
21
hw/net/rocker/rocker_world.c | 12 +++++------
22
5 files changed, 6 insertions(+), 87 deletions(-)
23
24
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/net/rocker/rocker.c
27
+++ b/hw/net/rocker/rocker.c
28
@@ -XXX,XX +XXX,XX @@ static int tx_consume(Rocker *r, DescInfo *info)
29
}
30
iov[iovcnt].iov_len = frag_len;
31
iov[iovcnt].iov_base = g_malloc(frag_len);
32
- if (!iov[iovcnt].iov_base) {
33
- err = -ROCKER_ENOMEM;
34
- goto err_no_mem;
35
- }
36
37
pci_dma_read(dev, frag_addr, iov[iovcnt].iov_base,
38
iov[iovcnt].iov_len);
39
@@ -XXX,XX +XXX,XX @@ static int tx_consume(Rocker *r, DescInfo *info)
40
err = fp_port_eg(r->fp_port[port], iov, iovcnt);
41
42
err_too_many_frags:
43
-err_no_mem:
44
err_bad_attr:
45
for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
46
g_free(iov[i].iov_base);
47
@@ -XXX,XX +XXX,XX @@ int rx_produce(World *world, uint32_t pport,
48
*/
49
50
data = g_malloc(data_size);
51
- if (!data) {
52
- err = -ROCKER_ENOMEM;
53
- goto out;
54
- }
55
+
56
iov_to_buf(iov, iovcnt, 0, data, data_size);
57
pci_dma_write(dev, frag_addr, data, data_size);
58
g_free(data);
59
@@ -XXX,XX +XXX,XX @@ static void rocker_test_dma_ctrl(Rocker *r, uint32_t val)
60
61
buf = g_malloc(r->test_dma_size);
62
63
- if (!buf) {
64
- DPRINTF("test dma buffer alloc failed");
65
- return;
66
- }
67
-
68
switch (val) {
69
case ROCKER_TEST_DMA_CTRL_CLEAR:
70
memset(buf, 0, r->test_dma_size);
71
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
72
73
r->worlds[ROCKER_WORLD_TYPE_OF_DPA] = of_dpa_world_alloc(r);
74
75
- for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
76
- if (!r->worlds[i]) {
77
- err = -ENOMEM;
78
- goto err_world_alloc;
79
- }
80
- }
81
-
82
if (!r->world_name) {
83
r->world_name = g_strdup(world_name(r->worlds[ROCKER_WORLD_TYPE_OF_DPA]));
84
}
85
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
86
}
87
88
r->rings = g_new(DescRing *, rocker_pci_ring_count(r));
89
- if (!r->rings) {
90
- goto err_rings_alloc;
91
- }
92
93
/* Rings are ordered like this:
94
* - command ring
95
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
96
* .....
97
*/
98
99
- err = -ENOMEM;
100
for (i = 0; i < rocker_pci_ring_count(r); i++) {
101
DescRing *ring = desc_ring_alloc(r, i);
102
103
- if (!ring) {
104
- goto err_ring_alloc;
105
- }
106
-
107
if (i == ROCKER_RING_CMD) {
108
desc_ring_set_consume(ring, cmd_consume, ROCKER_MSIX_VEC_CMD);
109
} else if (i == ROCKER_RING_EVENT) {
110
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
111
fp_port_alloc(r, r->name, &r->fp_start_macaddr,
112
i, &r->fp_ports_peers[i]);
113
114
- if (!port) {
115
- goto err_port_alloc;
116
- }
117
-
118
r->fp_port[i] = port;
119
fp_port_set_world(port, r->world_dflt);
120
}
121
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
122
123
return 0;
124
125
-err_port_alloc:
126
- for (--i; i >= 0; i--) {
127
- FpPort *port = r->fp_port[i];
128
- fp_port_free(port);
129
- }
130
- i = rocker_pci_ring_count(r);
131
-err_ring_alloc:
132
- for (--i; i >= 0; i--) {
133
- desc_ring_free(r->rings[i]);
134
- }
135
- g_free(r->rings);
136
-err_rings_alloc:
137
err_duplicate:
138
rocker_msix_uninit(r);
139
err_msix_init:
140
object_unparent(OBJECT(&r->msix_bar));
141
object_unparent(OBJECT(&r->mmio));
142
err_world_type_by_name:
143
-err_world_alloc:
144
for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
145
if (r->worlds[i]) {
146
world_free(r->worlds[i]);
147
diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c
148
index XXXXXXX..XXXXXXX 100644
149
--- a/hw/net/rocker/rocker_desc.c
150
+++ b/hw/net/rocker/rocker_desc.c
151
@@ -XXX,XX +XXX,XX @@ char *desc_get_buf(DescInfo *info, bool read_only)
152
info->buf_size = size;
153
}
154
155
- if (!info->buf) {
156
- return NULL;
157
- }
158
-
159
pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size);
160
161
return info->buf;
162
@@ -XXX,XX +XXX,XX @@ bool desc_ring_set_size(DescRing *ring, uint32_t size)
163
ring->head = ring->tail = 0;
164
165
ring->info = g_renew(DescInfo, ring->info, size);
166
- if (!ring->info) {
167
- return false;
168
- }
169
170
memset(ring->info, 0, size * sizeof(DescInfo));
171
172
@@ -XXX,XX +XXX,XX @@ DescRing *desc_ring_alloc(Rocker *r, int index)
173
DescRing *ring;
174
175
ring = g_new0(DescRing, 1);
176
- if (!ring) {
177
- return NULL;
178
- }
179
180
ring->r = r;
181
ring->index = index;
182
diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
183
index XXXXXXX..XXXXXXX 100644
184
--- a/hw/net/rocker/rocker_fp.c
185
+++ b/hw/net/rocker/rocker_fp.c
186
@@ -XXX,XX +XXX,XX @@ FpPort *fp_port_alloc(Rocker *r, char *sw_name,
187
{
188
FpPort *port = g_new0(FpPort, 1);
189
190
- if (!port) {
191
- return NULL;
192
- }
193
-
194
port->r = r;
195
port->index = index;
196
port->pport = index + 1;
197
diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c
198
index XXXXXXX..XXXXXXX 100644
199
--- a/hw/net/rocker/rocker_of_dpa.c
200
+++ b/hw/net/rocker/rocker_of_dpa.c
201
@@ -XXX,XX +XXX,XX @@ static OfDpaFlow *of_dpa_flow_alloc(uint64_t cookie)
202
int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) / 1000;
203
204
flow = g_new0(OfDpaFlow, 1);
205
- if (!flow) {
206
- return NULL;
207
- }
208
209
flow->cookie = cookie;
210
flow->mask.tbl_id = 0xffffffff;
211
@@ -XXX,XX +XXX,XX @@ static OfDpaGroup *of_dpa_group_alloc(uint32_t id)
212
{
213
OfDpaGroup *group = g_new0(OfDpaGroup, 1);
214
215
- if (!group) {
216
- return NULL;
217
- }
218
-
219
group->id = id;
220
221
return group;
222
@@ -XXX,XX +XXX,XX @@ static int of_dpa_cmd_flow_add(OfDpa *of_dpa, uint64_t cookie,
223
}
224
225
flow = of_dpa_flow_alloc(cookie);
226
- if (!flow) {
227
- return -ROCKER_ENOMEM;
228
- }
229
230
err = of_dpa_cmd_flow_add_mod(of_dpa, flow, flow_tlvs);
231
if (err) {
232
@@ -XXX,XX +XXX,XX @@ static int of_dpa_cmd_add_l2_flood(OfDpa *of_dpa, OfDpaGroup *group,
233
rocker_tlv_get_le16(group_tlvs[ROCKER_TLV_OF_DPA_GROUP_COUNT]);
234
235
tlvs = g_new0(RockerTlv *, group->l2_flood.group_count + 1);
236
- if (!tlvs) {
237
- return -ROCKER_ENOMEM;
238
- }
239
240
g_free(group->l2_flood.group_ids);
241
group->l2_flood.group_ids =
242
g_new0(uint32_t, group->l2_flood.group_count);
243
- if (!group->l2_flood.group_ids) {
244
- err = -ROCKER_ENOMEM;
245
- goto err_out;
246
- }
247
248
rocker_tlv_parse_nested(tlvs, group->l2_flood.group_count,
249
group_tlvs[ROCKER_TLV_OF_DPA_GROUP_IDS]);
250
@@ -XXX,XX +XXX,XX @@ static int of_dpa_cmd_group_add(OfDpa *of_dpa, uint32_t group_id,
251
}
252
253
group = of_dpa_group_alloc(group_id);
254
- if (!group) {
255
- return -ROCKER_ENOMEM;
256
- }
257
258
err = of_dpa_cmd_group_do(of_dpa, group_id, group, group_tlvs);
259
if (err) {
260
diff --git a/hw/net/rocker/rocker_world.c b/hw/net/rocker/rocker_world.c
261
index XXXXXXX..XXXXXXX 100644
262
--- a/hw/net/rocker/rocker_world.c
263
+++ b/hw/net/rocker/rocker_world.c
264
@@ -XXX,XX +XXX,XX @@ World *world_alloc(Rocker *r, size_t sizeof_private,
265
{
266
World *w = g_malloc0(sizeof(World) + sizeof_private);
267
268
- if (w) {
269
- w->r = r;
270
- w->type = type;
271
- w->ops = ops;
272
- if (w->ops->init) {
273
- w->ops->init(w);
274
- }
275
+ w->r = r;
276
+ w->type = type;
277
+ w->ops = ops;
278
+ if (w->ops->init) {
279
+ w->ops->init(w);
280
}
281
282
return w;
283
--
284
2.7.4
285
286
diff view generated by jsdifflib
Deleted patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
1
3
pci_rocker_init() leaks a World when the name more than 9 chars,
4
then return a negative value directly, doesn't make a correct
5
cleanup. So add a new goto label to fix it.
6
7
Cc: jasowang@redhat.com
8
Cc: jiri@resnulli.us
9
Cc: armbru@redhat.com
10
Cc: f4bug@amsat.org
11
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
12
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Signed-off-by: Jason Wang <jasowang@redhat.com>
15
---
16
hw/net/rocker/rocker.c | 4 +++-
17
1 file changed, 3 insertions(+), 1 deletion(-)
18
19
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/net/rocker/rocker.c
22
+++ b/hw/net/rocker/rocker.c
23
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
24
fprintf(stderr,
25
"rocker: name too long; please shorten to at most %d chars\n",
26
MAX_ROCKER_NAME_LEN);
27
- return -EINVAL;
28
+ err = -EINVAL;
29
+ goto err_name_too_long;
30
}
31
32
if (memcmp(&r->fp_start_macaddr, &zero, sizeof(zero)) == 0) {
33
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
34
35
return 0;
36
37
+err_name_too_long:
38
err_duplicate:
39
rocker_msix_uninit(r);
40
err_msix_init:
41
--
42
2.7.4
43
44
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
My Fujitsu mail account will be disabled soon, update the mail info
3
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1737400
4
to my private mail.
4
Fixed setting max_queue_num if there are no peers in
5
NICConf. qemu_new_nic() creates NICState with 1 NetClientState(index
6
0) without peers, set max_queue_num to 0 - It prevents undefined
7
behavior and possible crashes, especially during pcie hotplug.
5
8
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
9
Fixes: 6f3fbe4ed06 ("net: Introduce e1000e device emulation")
10
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Reviewed-by: Dmitry Fleytman <dmitry.fleytman@gmail.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
14
---
9
MAINTAINERS | 2 +-
15
hw/net/e1000e.c | 2 +-
10
1 file changed, 1 insertion(+), 1 deletion(-)
16
1 file changed, 1 insertion(+), 1 deletion(-)
11
17
12
diff --git a/MAINTAINERS b/MAINTAINERS
18
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
13
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
14
--- a/MAINTAINERS
20
--- a/hw/net/e1000e.c
15
+++ b/MAINTAINERS
21
+++ b/hw/net/e1000e.c
16
@@ -XXX,XX +XXX,XX @@ F: include/migration/failover.h
22
@@ -XXX,XX +XXX,XX @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr)
17
F: docs/COLO-FT.txt
23
s->nic = qemu_new_nic(&net_e1000e_info, &s->conf,
18
24
object_get_typename(OBJECT(s)), dev->id, s);
19
COLO Proxy
25
20
-M: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
26
- s->core.max_queue_num = s->conf.peers.queues - 1;
21
+M: Zhang Chen <zhangckid@gmail.com>
27
+ s->core.max_queue_num = s->conf.peers.queues ? s->conf.peers.queues - 1 : 0;
22
M: Li Zhijian <lizhijian@cn.fujitsu.com>
28
23
S: Supported
29
trace_e1000e_mac_set_permanent(MAC_ARG(macaddr));
24
F: docs/colo-proxy.txt
30
memcpy(s->core.permanent_mac, macaddr, sizeof(s->core.permanent_mac));
25
--
31
--
26
2.7.4
32
2.5.0
27
33
28
34
diff view generated by jsdifflib
1
From: Kamil Rytarowski <n54@gmx.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
SunOS defines SEC in <sys/time.h> as 1 (commonly used time symbols).
3
The e1000e_can_receive() function simply returns a boolean value.
4
4
5
This fixes build on SmartOS (Joyent).
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Patch cherry-picked from pkgsrc by jperkin (Joyent).
7
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8
9
Signed-off-by: Kamil Rytarowski <n54@gmx.com>
10
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
9
---
13
hw/net/e1000.c | 4 ++--
10
hw/net/e1000e_core.c | 2 +-
14
hw/net/e1000_regs.h | 2 +-
11
hw/net/e1000e_core.h | 2 +-
15
hw/net/e1000e_core.c | 2 +-
12
2 files changed, 2 insertions(+), 2 deletions(-)
16
hw/net/e1000x_common.h | 2 +-
17
4 files changed, 5 insertions(+), 5 deletions(-)
18
13
19
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/net/e1000.c
22
+++ b/hw/net/e1000.c
23
@@ -XXX,XX +XXX,XX @@ static uint32_t (*macreg_readops[])(E1000State *, int) = {
24
getreg(TADV), getreg(ITR), getreg(FCRUC), getreg(IPAV),
25
getreg(WUC), getreg(WUS), getreg(SCC), getreg(ECOL),
26
getreg(MCC), getreg(LATECOL), getreg(COLC), getreg(DC),
27
- getreg(TNCRS), getreg(SEC), getreg(CEXTERR), getreg(RLEC),
28
+ getreg(TNCRS), getreg(SEQEC), getreg(CEXTERR), getreg(RLEC),
29
getreg(XONRXC), getreg(XONTXC), getreg(XOFFRXC), getreg(XOFFTXC),
30
getreg(RFC), getreg(RJC), getreg(RNBC), getreg(TSCTFC),
31
getreg(MGTPRC), getreg(MGTPDC), getreg(MGTPTC), getreg(GORCL),
32
@@ -XXX,XX +XXX,XX @@ static const uint8_t mac_reg_access[0x8000] = {
33
[FFLT] = markflag(MAC), [FFMT] = markflag(MAC),
34
[SCC] = markflag(MAC), [FCRUC] = markflag(MAC),
35
[LATECOL] = markflag(MAC), [COLC] = markflag(MAC),
36
- [SEC] = markflag(MAC), [CEXTERR] = markflag(MAC),
37
+ [SEQEC] = markflag(MAC), [CEXTERR] = markflag(MAC),
38
[XONTXC] = markflag(MAC), [XOFFRXC] = markflag(MAC),
39
[RJC] = markflag(MAC), [RNBC] = markflag(MAC),
40
[MGTPDC] = markflag(MAC), [MGTPTC] = markflag(MAC),
41
diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/net/e1000_regs.h
44
+++ b/hw/net/e1000_regs.h
45
@@ -XXX,XX +XXX,XX @@
46
#define E1000_COLC 0x04028 /* Collision Count - R/clr */
47
#define E1000_DC 0x04030 /* Defer Count - R/clr */
48
#define E1000_TNCRS 0x04034 /* TX-No CRS - R/clr */
49
-#define E1000_SEC 0x04038 /* Sequence Error Count - R/clr */
50
+#define E1000_SEQEC 0x04038 /* Sequence Error Count - R/clr */
51
#define E1000_CEXTERR 0x0403C /* Carrier Extension Error Count - R/clr */
52
#define E1000_RLEC 0x04040 /* Receive Length Error Count - R/clr */
53
#define E1000_XONRXC 0x04048 /* XON RX Count - R/clr */
54
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
14
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
55
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/net/e1000e_core.c
16
--- a/hw/net/e1000e_core.c
57
+++ b/hw/net/e1000e_core.c
17
+++ b/hw/net/e1000e_core.c
58
@@ -XXX,XX +XXX,XX @@ static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = {
18
@@ -XXX,XX +XXX,XX @@ e1000e_start_recv(E1000ECore *core)
59
e1000e_getreg(RDLEN0),
19
}
60
e1000e_getreg(RDH1),
20
}
61
e1000e_getreg(LATECOL),
21
62
- e1000e_getreg(SEC),
22
-int
63
+ e1000e_getreg(SEQEC),
23
+bool
64
e1000e_getreg(XONTXC),
24
e1000e_can_receive(E1000ECore *core)
65
e1000e_getreg(WUS),
25
{
66
e1000e_getreg(GORCL),
26
int i;
67
diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h
27
diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h
68
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/net/e1000x_common.h
29
--- a/hw/net/e1000e_core.h
70
+++ b/hw/net/e1000x_common.h
30
+++ b/hw/net/e1000e_core.h
71
@@ -XXX,XX +XXX,XX @@ enum {
31
@@ -XXX,XX +XXX,XX @@ e1000e_core_set_link_status(E1000ECore *core);
72
defreg(VFTA), defreg(VET), defreg(RDTR), defreg(RADV),
32
void
73
defreg(TADV), defreg(ITR), defreg(SCC), defreg(ECOL),
33
e1000e_core_pci_uninit(E1000ECore *core);
74
defreg(MCC), defreg(LATECOL), defreg(COLC), defreg(DC),
34
75
- defreg(TNCRS), defreg(SEC), defreg(CEXTERR), defreg(RLEC),
35
-int
76
+ defreg(TNCRS), defreg(SEQEC), defreg(CEXTERR), defreg(RLEC),
36
+bool
77
defreg(XONRXC), defreg(XONTXC), defreg(XOFFRXC), defreg(XOFFTXC),
37
e1000e_can_receive(E1000ECore *core);
78
defreg(FCRUC), defreg(AIT), defreg(TDFH), defreg(TDFT),
38
79
defreg(TDFHS), defreg(TDFTS), defreg(TDFPC), defreg(WUC),
39
ssize_t
80
--
40
--
81
2.7.4
41
2.5.0
82
42
83
43
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
When network is busy, some tcp options(like sack) will unpredictable
3
The smc91c111_can_receive() function simply returns a boolean value.
4
occur in primary side or secondary side. it will make packet size
5
not same, but the two packet's payload is identical. colo just
6
care about packet payload, so we skip the option field.
7
4
8
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
9
---
11
net/colo-compare.c | 39 +++++++++++++++++++++++++++------------
10
hw/net/smc91c111.c | 8 ++++----
12
1 file changed, 27 insertions(+), 12 deletions(-)
11
1 file changed, 4 insertions(+), 4 deletions(-)
13
12
14
diff --git a/net/colo-compare.c b/net/colo-compare.c
13
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/net/colo-compare.c
15
--- a/hw/net/smc91c111.c
17
+++ b/net/colo-compare.c
16
+++ b/hw/net/smc91c111.c
18
@@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode)
17
@@ -XXX,XX +XXX,XX @@ static void smc91c111_update(smc91c111_state *s)
19
* return: 0 means packet same
18
qemu_set_irq(s->irq, level);
20
* > 0 || < 0 means packet different
19
}
21
*/
20
22
-static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
21
-static int smc91c111_can_receive(smc91c111_state *s)
23
+static int colo_packet_compare_common(Packet *ppkt,
22
+static bool smc91c111_can_receive(smc91c111_state *s)
24
+ Packet *spkt,
25
+ int poffset,
26
+ int soffset)
27
{
23
{
28
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
24
if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST)) {
29
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
25
- return 1;
30
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
26
+ return true;
31
sec_ip_src, sec_ip_dst);
32
}
27
}
33
28
if (s->allocated == (1 << NUM_PACKETS) - 1 ||
34
- offset = ppkt->vnet_hdr_len + offset;
29
s->rx_fifo_len == NUM_PACKETS) {
35
+ poffset = ppkt->vnet_hdr_len + poffset;
30
- return 0;
36
+ soffset = ppkt->vnet_hdr_len + soffset;
31
+ return false;
37
38
- if (ppkt->size == spkt->size) {
39
- return memcmp(ppkt->data + offset,
40
- spkt->data + offset,
41
- spkt->size - offset);
42
+ if (ppkt->size - poffset == spkt->size - soffset) {
43
+ return memcmp(ppkt->data + poffset,
44
+ spkt->data + soffset,
45
+ spkt->size - soffset);
46
} else {
47
trace_colo_compare_main("Net packet size are not the same");
48
return -1;
49
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
50
* so we just need skip this field.
51
*/
52
if (ptcp->th_off > 5) {
53
- ptrdiff_t tcp_offset;
54
+ ptrdiff_t ptcp_offset, stcp_offset;
55
56
- tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
57
- + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
58
- res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
59
+ ptcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
60
+ + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
61
+ stcp_offset = spkt->transport_header - (uint8_t *)spkt->data
62
+ + (stcp->th_off * 4) - spkt->vnet_hdr_len;
63
+
64
+ /*
65
+ * When network is busy, some tcp options(like sack) will unpredictable
66
+ * occur in primary side or secondary side. it will make packet size
67
+ * not same, but the two packet's payload is identical. colo just
68
+ * care about packet payload, so we skip the option field.
69
+ */
70
+ res = colo_packet_compare_common(ppkt, spkt, ptcp_offset, stcp_offset);
71
} else if (ptcp->th_sum == stcp->th_sum) {
72
- res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
73
+ res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN, ETH_HLEN);
74
} else {
75
res = -1;
76
}
32
}
77
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_udp(Packet *spkt, Packet *ppkt)
33
- return 1;
78
* the ip payload here.
34
+ return true;
79
*/
80
ret = colo_packet_compare_common(ppkt, spkt,
81
+ network_header_length + ETH_HLEN,
82
network_header_length + ETH_HLEN);
83
84
if (ret) {
85
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt)
86
* the ip payload here.
87
*/
88
if (colo_packet_compare_common(ppkt, spkt,
89
+ network_header_length + ETH_HLEN,
90
network_header_length + ETH_HLEN)) {
91
trace_colo_compare_icmp_miscompare("primary pkt size",
92
ppkt->size);
93
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
94
sec_ip_src, sec_ip_dst);
95
}
96
97
- return colo_packet_compare_common(ppkt, spkt, 0);
98
+ return colo_packet_compare_common(ppkt, spkt, 0, 0);
99
}
35
}
100
36
101
static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time)
37
static inline void smc91c111_flush_queued_packets(smc91c111_state *s)
102
--
38
--
103
2.7.4
39
2.5.0
104
40
105
41
diff view generated by jsdifflib
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Cc: berrange@redhat.com
3
Rewrite:
4
Cc: kraxel@redhat.com
4
5
Cc: pbonzini@redhat.com
5
if (E) {
6
Cc: jasowang@redhat.com
6
return A;
7
Cc: armbru@redhat.com
7
} else {
8
Cc: eblake@redhat.com
8
return B;
9
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
9
}
10
Reviewed-by: Markus Armbruster <armbru@redhat.com>
10
/* EOF */
11
}
12
13
as:
14
15
if (E) {
16
return A;
17
}
18
return B;
19
}
20
21
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
23
Reviewed-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
25
---
13
include/qemu/sockets.h | 3 ++-
26
hw/net/rtl8139.c | 8 ++++----
14
net/net.c | 22 +++++++++++++++++-----
27
1 file changed, 4 insertions(+), 4 deletions(-)
15
net/socket.c | 22 +++++++++++++++-------
16
3 files changed, 34 insertions(+), 13 deletions(-)
17
28
18
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
29
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
19
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
20
--- a/include/qemu/sockets.h
31
--- a/hw/net/rtl8139.c
21
+++ b/include/qemu/sockets.h
32
+++ b/hw/net/rtl8139.c
22
@@ -XXX,XX +XXX,XX @@ void socket_listen_cleanup(int fd, Error **errp);
33
@@ -XXX,XX +XXX,XX @@ static int rtl8139_can_receive(NetClientState *nc)
23
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
34
/* ??? Flow control not implemented in c+ mode.
24
35
This is a hack to work around slirp deficiencies anyway. */
25
/* Old, ipv4 only bits. Don't use for new code. */
36
return 1;
26
-int parse_host_port(struct sockaddr_in *saddr, const char *str);
37
- } else {
27
+int parse_host_port(struct sockaddr_in *saddr, const char *str,
38
- avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
28
+ Error **errp);
39
- s->RxBufferSize);
29
int socket_init(void);
40
- return (avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow));
30
41
}
31
/**
42
+
32
diff --git a/net/net.c b/net/net.c
43
+ avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
33
index XXXXXXX..XXXXXXX 100644
44
+ s->RxBufferSize);
34
--- a/net/net.c
45
+ return avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow);
35
+++ b/net/net.c
36
@@ -XXX,XX +XXX,XX @@ static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
37
return 0;
38
}
46
}
39
47
40
-int parse_host_port(struct sockaddr_in *saddr, const char *str)
48
static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
41
+int parse_host_port(struct sockaddr_in *saddr, const char *str,
42
+ Error **errp)
43
{
44
char buf[512];
45
struct hostent *he;
46
@@ -XXX,XX +XXX,XX @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
47
int port;
48
49
p = str;
50
- if (get_str_sep(buf, sizeof(buf), &p, ':') < 0)
51
+ if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
52
+ error_setg(errp, "host address '%s' doesn't contain ':' "
53
+ "separating host from port", str);
54
return -1;
55
+ }
56
saddr->sin_family = AF_INET;
57
if (buf[0] == '\0') {
58
saddr->sin_addr.s_addr = 0;
59
} else {
60
if (qemu_isdigit(buf[0])) {
61
- if (!inet_aton(buf, &saddr->sin_addr))
62
+ if (!inet_aton(buf, &saddr->sin_addr)) {
63
+ error_setg(errp, "host address '%s' is not a valid "
64
+ "IPv4 address", buf);
65
return -1;
66
+ }
67
} else {
68
- if ((he = gethostbyname(buf)) == NULL)
69
+ he = gethostbyname(buf);
70
+ if (he == NULL) {
71
+ error_setg(errp, "can't resolve host address '%s'", buf);
72
return - 1;
73
+ }
74
saddr->sin_addr = *(struct in_addr *)he->h_addr;
75
}
76
}
77
port = strtol(p, (char **)&r, 0);
78
- if (r == p)
79
+ if (r == p) {
80
+ error_setg(errp, "port number '%s' is invalid", p);
81
return -1;
82
+ }
83
saddr->sin_port = htons(port);
84
return 0;
85
}
86
diff --git a/net/socket.c b/net/socket.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/net/socket.c
89
+++ b/net/socket.c
90
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
91
*/
92
93
if (is_connected && mcast != NULL) {
94
- if (parse_host_port(&saddr, mcast) < 0) {
95
- error_setg(errp, "fd=%d failed parse_host_port()", fd);
96
+ if (parse_host_port(&saddr, mcast, errp) < 0) {
97
goto err;
98
}
99
/* must be bound */
100
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
101
NetSocketState *s;
102
struct sockaddr_in saddr;
103
int fd, ret;
104
+ Error *err = NULL;
105
106
- if (parse_host_port(&saddr, host_str) < 0)
107
+ if (parse_host_port(&saddr, host_str, &err) < 0) {
108
+ error_report_err(err);
109
return -1;
110
+ }
111
112
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
113
if (fd < 0) {
114
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
115
struct sockaddr_in saddr;
116
Error *err = NULL;
117
118
- if (parse_host_port(&saddr, host_str) < 0)
119
+ if (parse_host_port(&saddr, host_str, &err) < 0) {
120
+ error_report_err(err);
121
return -1;
122
+ }
123
124
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
125
if (fd < 0) {
126
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
127
struct in_addr localaddr, *param_localaddr;
128
Error *err = NULL;
129
130
- if (parse_host_port(&saddr, host_str) < 0)
131
+ if (parse_host_port(&saddr, host_str, &err) < 0) {
132
+ error_report_err(err);
133
return -1;
134
+ }
135
136
if (localaddr_str != NULL) {
137
if (inet_aton(localaddr_str, &localaddr) == 0)
138
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
139
struct sockaddr_in laddr, raddr;
140
Error *err = NULL;
141
142
- if (parse_host_port(&laddr, lhost) < 0) {
143
+ if (parse_host_port(&laddr, lhost, &err) < 0) {
144
+ error_report_err(err);
145
return -1;
146
}
147
148
- if (parse_host_port(&raddr, rhost) < 0) {
149
+ if (parse_host_port(&raddr, rhost, &err) < 0) {
150
+ error_report_err(err);
151
return -1;
152
}
153
154
--
49
--
155
2.7.4
50
2.5.0
156
51
157
52
diff view generated by jsdifflib
1
From: Matt Parker <mtparkr@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Both io and memory use the same mmio functions in the rtl8139 device.
3
We will modify this code in the next commit. Clean it up
4
This patch removes the separate MemoryRegionOps and old_mmio accessors
4
first to avoid checkpatch.pl errors.
5
for memory, and replaces it with an alias to the io memory region.
6
5
7
Signed-off-by: Matt Parker <mtparkr@gmail.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
10
---
10
hw/net/rtl8139.c | 53 +++--------------------------------------------------
11
hw/net/rtl8139.c | 10 ++++++----
11
1 file changed, 3 insertions(+), 50 deletions(-)
12
1 file changed, 6 insertions(+), 4 deletions(-)
12
13
13
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
14
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/net/rtl8139.c
16
--- a/hw/net/rtl8139.c
16
+++ b/hw/net/rtl8139.c
17
+++ b/hw/net/rtl8139.c
17
@@ -XXX,XX +XXX,XX @@ static uint32_t rtl8139_io_readl(void *opaque, uint8_t addr)
18
@@ -XXX,XX +XXX,XX @@ static int rtl8139_can_receive(NetClientState *nc)
18
19
int avail;
19
/* */
20
20
21
/* Receive (drop) packets if card is disabled. */
21
-static void rtl8139_mmio_writeb(void *opaque, hwaddr addr, uint32_t val)
22
- if (!s->clock_enabled)
22
-{
23
- return 1;
23
- rtl8139_io_writeb(opaque, addr & 0xFF, val);
24
- if (!rtl8139_receiver_enabled(s))
24
-}
25
- return 1;
25
-
26
+ if (!s->clock_enabled) {
26
-static void rtl8139_mmio_writew(void *opaque, hwaddr addr, uint32_t val)
27
+ return 1;
27
-{
28
+ }
28
- rtl8139_io_writew(opaque, addr & 0xFF, val);
29
+ if (!rtl8139_receiver_enabled(s)) {
29
-}
30
+ return 1;
30
-
31
+ }
31
-static void rtl8139_mmio_writel(void *opaque, hwaddr addr, uint32_t val)
32
32
-{
33
if (rtl8139_cp_receiver_enabled(s) && rtl8139_cp_rx_valid(s)) {
33
- rtl8139_io_writel(opaque, addr & 0xFF, val);
34
/* ??? Flow control not implemented in c+ mode.
34
-}
35
-
36
-static uint32_t rtl8139_mmio_readb(void *opaque, hwaddr addr)
37
-{
38
- return rtl8139_io_readb(opaque, addr & 0xFF);
39
-}
40
-
41
-static uint32_t rtl8139_mmio_readw(void *opaque, hwaddr addr)
42
-{
43
- uint32_t val = rtl8139_io_readw(opaque, addr & 0xFF);
44
- return val;
45
-}
46
-
47
-static uint32_t rtl8139_mmio_readl(void *opaque, hwaddr addr)
48
-{
49
- uint32_t val = rtl8139_io_readl(opaque, addr & 0xFF);
50
- return val;
51
-}
52
-
53
static int rtl8139_post_load(void *opaque, int version_id)
54
{
55
RTL8139State* s = opaque;
56
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps rtl8139_io_ops = {
57
.endianness = DEVICE_LITTLE_ENDIAN,
58
};
59
60
-static const MemoryRegionOps rtl8139_mmio_ops = {
61
- .old_mmio = {
62
- .read = {
63
- rtl8139_mmio_readb,
64
- rtl8139_mmio_readw,
65
- rtl8139_mmio_readl,
66
- },
67
- .write = {
68
- rtl8139_mmio_writeb,
69
- rtl8139_mmio_writew,
70
- rtl8139_mmio_writel,
71
- },
72
- },
73
- .endianness = DEVICE_LITTLE_ENDIAN,
74
-};
75
-
76
static void rtl8139_timer(void *opaque)
77
{
78
RTL8139State *s = opaque;
79
@@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_realize(PCIDevice *dev, Error **errp)
80
81
memory_region_init_io(&s->bar_io, OBJECT(s), &rtl8139_io_ops, s,
82
"rtl8139", 0x100);
83
- memory_region_init_io(&s->bar_mem, OBJECT(s), &rtl8139_mmio_ops, s,
84
- "rtl8139", 0x100);
85
+ memory_region_init_alias(&s->bar_mem, OBJECT(s), "rtl8139-mem", &s->bar_io,
86
+ 0, 0x100);
87
+
88
pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->bar_io);
89
pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar_mem);
90
91
--
35
--
92
2.7.4
36
2.5.0
93
37
94
38
diff view generated by jsdifflib
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Cc: jasowang@redhat.com
3
The NetCanReceive handler return whether the device can or
4
Cc: jiri@resnulli.us
4
can not receive new packets. Make it obvious by returning
5
Cc: armbru@redhat.com
5
a boolean type.
6
Cc: f4bug@amsat.org
6
7
Suggested-by: Markus Armbruster <armbru@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
8
Acked-by: David Gibson <david@gibson.dropbear.id.au>
9
Reviewed-by: Markus Armbruster <armbru@redhat.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
12
---
13
hw/net/rocker/rocker.c | 18 +++++++++---------
13
hw/net/allwinner_emac.c | 2 +-
14
1 file changed, 9 insertions(+), 9 deletions(-)
14
hw/net/cadence_gem.c | 8 ++++----
15
hw/net/dp8393x.c | 8 +++-----
16
hw/net/e1000.c | 2 +-
17
hw/net/e1000e.c | 2 +-
18
hw/net/ftgmac100.c | 6 +++---
19
hw/net/i82596.c | 10 +++++-----
20
hw/net/i82596.h | 2 +-
21
hw/net/imx_fec.c | 2 +-
22
hw/net/opencores_eth.c | 5 ++---
23
hw/net/rtl8139.c | 8 ++++----
24
hw/net/smc91c111.c | 2 +-
25
hw/net/spapr_llan.c | 4 ++--
26
hw/net/sungem.c | 6 +++---
27
hw/net/sunhme.c | 4 ++--
28
hw/net/virtio-net.c | 10 +++++-----
29
hw/net/xilinx_ethlite.c | 2 +-
30
include/net/net.h | 2 +-
31
net/filter-buffer.c | 2 +-
32
net/hub.c | 6 +++---
33
20 files changed, 45 insertions(+), 48 deletions(-)
15
34
16
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
35
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
17
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/rocker/rocker.c
37
--- a/hw/net/allwinner_emac.c
19
+++ b/hw/net/rocker/rocker.c
38
+++ b/hw/net/allwinner_emac.c
20
@@ -XXX,XX +XXX,XX @@ struct rocker {
39
@@ -XXX,XX +XXX,XX @@ static uint32_t fifo8_pop_word(Fifo8 *fifo)
21
QLIST_ENTRY(rocker) next;
40
return ret;
41
}
42
43
-static int aw_emac_can_receive(NetClientState *nc)
44
+static bool aw_emac_can_receive(NetClientState *nc)
45
{
46
AwEmacState *s = qemu_get_nic_opaque(nc);
47
48
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/net/cadence_gem.c
51
+++ b/hw/net/cadence_gem.c
52
@@ -XXX,XX +XXX,XX @@ static void phy_update_link(CadenceGEMState *s)
53
}
54
}
55
56
-static int gem_can_receive(NetClientState *nc)
57
+static bool gem_can_receive(NetClientState *nc)
58
{
59
CadenceGEMState *s;
60
int i;
61
@@ -XXX,XX +XXX,XX @@ static int gem_can_receive(NetClientState *nc)
62
s->can_rx_state = 1;
63
DB_PRINT("can't receive - no enable\n");
64
}
65
- return 0;
66
+ return false;
67
}
68
69
for (i = 0; i < s->num_priority_queues; i++) {
70
@@ -XXX,XX +XXX,XX @@ static int gem_can_receive(NetClientState *nc)
71
s->can_rx_state = 2;
72
DB_PRINT("can't receive - all the buffer descriptors are busy\n");
73
}
74
- return 0;
75
+ return false;
76
}
77
78
if (s->can_rx_state != 0) {
79
s->can_rx_state = 0;
80
DB_PRINT("can receive\n");
81
}
82
- return 1;
83
+ return true;
84
}
85
86
/*
87
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/net/dp8393x.c
90
+++ b/hw/net/dp8393x.c
91
@@ -XXX,XX +XXX,XX @@ static void dp8393x_do_stop_timer(dp8393xState *s)
92
dp8393x_update_wt_regs(s);
93
}
94
95
-static int dp8393x_can_receive(NetClientState *nc);
96
+static bool dp8393x_can_receive(NetClientState *nc);
97
98
static void dp8393x_do_receiver_enable(dp8393xState *s)
99
{
100
@@ -XXX,XX +XXX,XX @@ static void dp8393x_watchdog(void *opaque)
101
dp8393x_update_irq(s);
102
}
103
104
-static int dp8393x_can_receive(NetClientState *nc)
105
+static bool dp8393x_can_receive(NetClientState *nc)
106
{
107
dp8393xState *s = qemu_get_nic_opaque(nc);
108
109
- if (!(s->regs[SONIC_CR] & SONIC_CR_RXEN))
110
- return 0;
111
- return 1;
112
+ return !!(s->regs[SONIC_CR] & SONIC_CR_RXEN);
113
}
114
115
static int dp8393x_receive_filter(dp8393xState *s, const uint8_t * buf,
116
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/net/e1000.c
119
+++ b/hw/net/e1000.c
120
@@ -XXX,XX +XXX,XX @@ static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
121
return total_size <= bufs * s->rxbuf_size;
122
}
123
124
-static int
125
+static bool
126
e1000_can_receive(NetClientState *nc)
127
{
128
E1000State *s = qemu_get_nic_opaque(nc);
129
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/net/e1000e.c
132
+++ b/hw/net/e1000e.c
133
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps io_ops = {
134
},
22
};
135
};
23
136
24
-#define ROCKER "rocker"
137
-static int
25
+#define TYPE_ROCKER "rocker"
138
+static bool
26
139
e1000e_nc_can_receive(NetClientState *nc)
27
-#define to_rocker(obj) \
140
{
28
- OBJECT_CHECK(Rocker, (obj), ROCKER)
141
E1000EState *s = qemu_get_nic_opaque(nc);
29
+#define ROCKER(obj) \
142
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
30
+ OBJECT_CHECK(Rocker, (obj), TYPE_ROCKER)
143
index XXXXXXX..XXXXXXX 100644
31
144
--- a/hw/net/ftgmac100.c
32
static QLIST_HEAD(, rocker) rockers;
145
+++ b/hw/net/ftgmac100.c
33
146
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
34
@@ -XXX,XX +XXX,XX @@ static World *rocker_world_type_by_name(Rocker *r, const char *name)
147
ftgmac100_update_irq(s);
35
148
}
36
static void pci_rocker_realize(PCIDevice *dev, Error **errp)
149
37
{
150
-static int ftgmac100_can_receive(NetClientState *nc)
38
- Rocker *r = to_rocker(dev);
151
+static bool ftgmac100_can_receive(NetClientState *nc)
39
+ Rocker *r = ROCKER(dev);
152
{
40
const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
153
FTGMAC100State *s = FTGMAC100(qemu_get_nic_opaque(nc));
41
const MACAddr dflt = { .a = { 0x52, 0x54, 0x00, 0x12, 0x35, 0x01 } };
154
FTGMAC100Desc bd;
42
static int sw_index;
155
43
@@ -XXX,XX +XXX,XX @@ static void pci_rocker_realize(PCIDevice *dev, Error **errp)
156
if ((s->maccr & (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN))
44
/* validate switch properties */
157
!= (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) {
45
158
- return 0;
46
if (!r->name) {
159
+ return false;
47
- r->name = g_strdup(ROCKER);
160
}
48
+ r->name = g_strdup(TYPE_ROCKER);
161
49
}
162
if (ftgmac100_read_bd(&bd, s->rx_descriptor)) {
50
163
- return 0;
51
if (rocker_find(r->name)) {
164
+ return false;
52
@@ -XXX,XX +XXX,XX @@ err_world_type_by_name:
165
}
53
166
return !(bd.des0 & FTGMAC100_RXDES0_RXPKT_RDY);
54
static void pci_rocker_uninit(PCIDevice *dev)
167
}
55
{
168
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
56
- Rocker *r = to_rocker(dev);
169
index XXXXXXX..XXXXXXX 100644
57
+ Rocker *r = ROCKER(dev);
170
--- a/hw/net/i82596.c
58
int i;
171
+++ b/hw/net/i82596.c
59
172
@@ -XXX,XX +XXX,XX @@ void i82596_h_reset(void *opaque)
60
QLIST_REMOVE(r, next);
173
i82596_s_reset(s);
61
@@ -XXX,XX +XXX,XX @@ static void pci_rocker_uninit(PCIDevice *dev)
174
}
62
175
63
static void rocker_reset(DeviceState *dev)
176
-int i82596_can_receive(NetClientState *nc)
64
{
177
+bool i82596_can_receive(NetClientState *nc)
65
- Rocker *r = to_rocker(dev);
178
{
66
+ Rocker *r = ROCKER(dev);
179
I82596State *s = qemu_get_nic_opaque(nc);
67
int i;
180
68
181
if (s->rx_status == RX_SUSPENDED) {
69
for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
182
- return 0;
70
@@ -XXX,XX +XXX,XX @@ static Property rocker_properties[] = {
183
+ return false;
184
}
185
186
if (!s->lnkst) {
187
- return 0;
188
+ return false;
189
}
190
191
if (USE_TIMER && !timer_pending(s->flush_queue_timer)) {
192
- return 1;
193
+ return true;
194
}
195
196
- return 1;
197
+ return true;
198
}
199
200
#define MIN_BUF_SIZE 60
201
diff --git a/hw/net/i82596.h b/hw/net/i82596.h
202
index XXXXXXX..XXXXXXX 100644
203
--- a/hw/net/i82596.h
204
+++ b/hw/net/i82596.h
205
@@ -XXX,XX +XXX,XX @@ void i82596_ioport_writel(void *opaque, uint32_t addr, uint32_t val);
206
uint32_t i82596_ioport_readl(void *opaque, uint32_t addr);
207
uint32_t i82596_bcr_readw(I82596State *s, uint32_t rap);
208
ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t size_);
209
-int i82596_can_receive(NetClientState *nc);
210
+bool i82596_can_receive(NetClientState *nc);
211
void i82596_set_link_status(NetClientState *nc);
212
void i82596_common_init(DeviceState *dev, I82596State *s, NetClientInfo *info);
213
extern const VMStateDescription vmstate_i82596;
214
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
215
index XXXXXXX..XXXXXXX 100644
216
--- a/hw/net/imx_fec.c
217
+++ b/hw/net/imx_fec.c
218
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
219
imx_eth_update(s);
220
}
221
222
-static int imx_eth_can_receive(NetClientState *nc)
223
+static bool imx_eth_can_receive(NetClientState *nc)
224
{
225
IMXFECState *s = IMX_FEC(qemu_get_nic_opaque(nc));
226
227
diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
228
index XXXXXXX..XXXXXXX 100644
229
--- a/hw/net/opencores_eth.c
230
+++ b/hw/net/opencores_eth.c
231
@@ -XXX,XX +XXX,XX @@ static void open_eth_reset(void *opaque)
232
open_eth_set_link_status(qemu_get_queue(s->nic));
233
}
234
235
-static int open_eth_can_receive(NetClientState *nc)
236
+static bool open_eth_can_receive(NetClientState *nc)
237
{
238
OpenEthState *s = qemu_get_nic_opaque(nc);
239
240
- return GET_REGBIT(s, MODER, RXEN) &&
241
- (s->regs[TX_BD_NUM] < 0x80);
242
+ return GET_REGBIT(s, MODER, RXEN) && (s->regs[TX_BD_NUM] < 0x80);
243
}
244
245
static ssize_t open_eth_receive(NetClientState *nc,
246
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
247
index XXXXXXX..XXXXXXX 100644
248
--- a/hw/net/rtl8139.c
249
+++ b/hw/net/rtl8139.c
250
@@ -XXX,XX +XXX,XX @@ static bool rtl8139_cp_rx_valid(RTL8139State *s)
251
return !(s->RxRingAddrLO == 0 && s->RxRingAddrHI == 0);
252
}
253
254
-static int rtl8139_can_receive(NetClientState *nc)
255
+static bool rtl8139_can_receive(NetClientState *nc)
256
{
257
RTL8139State *s = qemu_get_nic_opaque(nc);
258
int avail;
259
260
/* Receive (drop) packets if card is disabled. */
261
if (!s->clock_enabled) {
262
- return 1;
263
+ return true;
264
}
265
if (!rtl8139_receiver_enabled(s)) {
266
- return 1;
267
+ return true;
268
}
269
270
if (rtl8139_cp_receiver_enabled(s) && rtl8139_cp_rx_valid(s)) {
271
/* ??? Flow control not implemented in c+ mode.
272
This is a hack to work around slirp deficiencies anyway. */
273
- return 1;
274
+ return true;
275
}
276
277
avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
278
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
279
index XXXXXXX..XXXXXXX 100644
280
--- a/hw/net/smc91c111.c
281
+++ b/hw/net/smc91c111.c
282
@@ -XXX,XX +XXX,XX @@ static void smc91c111_writefn(void *opaque, hwaddr addr,
283
}
284
}
285
286
-static int smc91c111_can_receive_nc(NetClientState *nc)
287
+static bool smc91c111_can_receive_nc(NetClientState *nc)
288
{
289
smc91c111_state *s = qemu_get_nic_opaque(nc);
290
291
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
292
index XXXXXXX..XXXXXXX 100644
293
--- a/hw/net/spapr_llan.c
294
+++ b/hw/net/spapr_llan.c
295
@@ -XXX,XX +XXX,XX @@ typedef struct SpaprVioVlan {
296
RxBufPool *rx_pool[RX_MAX_POOLS]; /* Receive buffer descriptor pools */
297
} SpaprVioVlan;
298
299
-static int spapr_vlan_can_receive(NetClientState *nc)
300
+static bool spapr_vlan_can_receive(NetClientState *nc)
301
{
302
SpaprVioVlan *dev = qemu_get_nic_opaque(nc);
303
304
- return (dev->isopen && dev->rx_bufs > 0);
305
+ return dev->isopen && dev->rx_bufs > 0;
306
}
307
308
/**
309
diff --git a/hw/net/sungem.c b/hw/net/sungem.c
310
index XXXXXXX..XXXXXXX 100644
311
--- a/hw/net/sungem.c
312
+++ b/hw/net/sungem.c
313
@@ -XXX,XX +XXX,XX @@ static bool sungem_rx_full(SunGEMState *s, uint32_t kick, uint32_t done)
314
return kick == ((done + 1) & s->rx_mask);
315
}
316
317
-static int sungem_can_receive(NetClientState *nc)
318
+static bool sungem_can_receive(NetClientState *nc)
319
{
320
SunGEMState *s = qemu_get_nic_opaque(nc);
321
uint32_t kick, done, rxdma_cfg, rxmac_cfg;
322
@@ -XXX,XX +XXX,XX @@ static int sungem_can_receive(NetClientState *nc)
323
/* If MAC disabled, can't receive */
324
if ((rxmac_cfg & MAC_RXCFG_ENAB) == 0) {
325
trace_sungem_rx_mac_disabled();
326
- return 0;
327
+ return false;
328
}
329
if ((rxdma_cfg & RXDMA_CFG_ENABLE) == 0) {
330
trace_sungem_rx_txdma_disabled();
331
- return 0;
332
+ return false;
333
}
334
335
/* Check RX availability */
336
diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c
337
index XXXXXXX..XXXXXXX 100644
338
--- a/hw/net/sunhme.c
339
+++ b/hw/net/sunhme.c
340
@@ -XXX,XX +XXX,XX @@ static void sunhme_transmit(SunHMEState *s)
341
sunhme_update_irq(s);
342
}
343
344
-static int sunhme_can_receive(NetClientState *nc)
345
+static bool sunhme_can_receive(NetClientState *nc)
346
{
347
SunHMEState *s = qemu_get_nic_opaque(nc);
348
349
- return s->macregs[HME_MACI_RXCFG >> 2] & HME_MAC_RXCFG_ENABLE;
350
+ return !!(s->macregs[HME_MACI_RXCFG >> 2] & HME_MAC_RXCFG_ENABLE);
351
}
352
353
static void sunhme_link_status_changed(NetClientState *nc)
354
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
355
index XXXXXXX..XXXXXXX 100644
356
--- a/hw/net/virtio-net.c
357
+++ b/hw/net/virtio-net.c
358
@@ -XXX,XX +XXX,XX @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
359
qemu_flush_queued_packets(qemu_get_subqueue(n->nic, queue_index));
360
}
361
362
-static int virtio_net_can_receive(NetClientState *nc)
363
+static bool virtio_net_can_receive(NetClientState *nc)
364
{
365
VirtIONet *n = qemu_get_nic_opaque(nc);
366
VirtIODevice *vdev = VIRTIO_DEVICE(n);
367
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
368
369
if (!vdev->vm_running) {
370
- return 0;
371
+ return false;
372
}
373
374
if (nc->queue_index >= n->curr_queues) {
375
- return 0;
376
+ return false;
377
}
378
379
if (!virtio_queue_ready(q->rx_vq) ||
380
!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
381
- return 0;
382
+ return false;
383
}
384
385
- return 1;
386
+ return true;
387
}
388
389
static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize)
390
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
391
index XXXXXXX..XXXXXXX 100644
392
--- a/hw/net/xilinx_ethlite.c
393
+++ b/hw/net/xilinx_ethlite.c
394
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps eth_ops = {
395
}
71
};
396
};
72
397
73
static const VMStateDescription rocker_vmsd = {
398
-static int eth_can_rx(NetClientState *nc)
74
- .name = ROCKER,
399
+static bool eth_can_rx(NetClientState *nc)
75
+ .name = TYPE_ROCKER,
400
{
76
.unmigratable = 1,
401
struct xlx_ethlite *s = qemu_get_nic_opaque(nc);
77
};
402
unsigned int rxbase = s->rxbuf * (0x800 / 4);
78
403
diff --git a/include/net/net.h b/include/net/net.h
79
@@ -XXX,XX +XXX,XX @@ static void rocker_class_init(ObjectClass *klass, void *data)
404
index XXXXXXX..XXXXXXX 100644
80
}
405
--- a/include/net/net.h
81
406
+++ b/include/net/net.h
82
static const TypeInfo rocker_info = {
407
@@ -XXX,XX +XXX,XX @@ typedef struct NICConf {
83
- .name = ROCKER,
408
/* Net clients */
84
+ .name = TYPE_ROCKER,
409
85
.parent = TYPE_PCI_DEVICE,
410
typedef void (NetPoll)(NetClientState *, bool enable);
86
.instance_size = sizeof(Rocker),
411
-typedef int (NetCanReceive)(NetClientState *);
87
.class_init = rocker_class_init,
412
+typedef bool (NetCanReceive)(NetClientState *);
413
typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t);
414
typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int);
415
typedef void (NetCleanup) (NetClientState *);
416
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
417
index XXXXXXX..XXXXXXX 100644
418
--- a/net/filter-buffer.c
419
+++ b/net/filter-buffer.c
420
@@ -XXX,XX +XXX,XX @@ static ssize_t filter_buffer_receive_iov(NetFilterState *nf,
421
* the filter can still accept packets until its internal queue is full.
422
* For example:
423
* For some reason, receiver could not receive more packets
424
- * (.can_receive() returns zero). Without a filter, at most one packet
425
+ * (.can_receive() returns false). Without a filter, at most one packet
426
* will be queued in incoming queue and sender's poll will be disabled
427
* unit its sent_cb() was called. With a filter, it will keep receiving
428
* the packets without caring about the receiver. This is suboptimal.
429
diff --git a/net/hub.c b/net/hub.c
430
index XXXXXXX..XXXXXXX 100644
431
--- a/net/hub.c
432
+++ b/net/hub.c
433
@@ -XXX,XX +XXX,XX @@ static NetHub *net_hub_new(int id)
434
return hub;
435
}
436
437
-static int net_hub_port_can_receive(NetClientState *nc)
438
+static bool net_hub_port_can_receive(NetClientState *nc)
439
{
440
NetHubPort *port;
441
NetHubPort *src_port = DO_UPCAST(NetHubPort, nc, nc);
442
@@ -XXX,XX +XXX,XX @@ static int net_hub_port_can_receive(NetClientState *nc)
443
}
444
445
if (qemu_can_send_packet(&port->nc)) {
446
- return 1;
447
+ return true;
448
}
449
}
450
451
- return 0;
452
+ return false;
453
}
454
455
static ssize_t net_hub_port_receive(NetClientState *nc,
88
--
456
--
89
2.7.4
457
2.5.0
90
458
91
459
diff view generated by jsdifflib
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
The rocker device still implements the old PCIDeviceClass .init()
3
The CanBusClientInfo::can_receive handler return whether the
4
instead of the new .realize(). All devices need to be converted to
4
device can or can not receive new frames. Make it obvious by
5
.realize().
5
returning a boolean type.
6
6
7
.init() reports errors with fprintf() and return 0 on success, negative
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
number on failure. Meanwhile, when -device rocker fails, it first report
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
a specific error, then a generic one, like this:
9
Reviewed-by: Cédric Le Goater <clg@kaod.org>
10
11
$ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
12
rocker: name too long; please shorten to at most 9 chars
13
qemu-system-x86_64: -device rocker,name=qemu-rocker: Device initialization failed
14
15
Now, convert it to .realize() that passes errors to its callers via its
16
errp argument. Also avoid the superfluous second error message. After
17
the patch, effect like this:
18
19
$ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
20
qemu-system-x86_64: -device rocker,name=qemu-rocker: name too long; please shorten to at most 9 chars
21
22
Cc: jasowang@redhat.com
23
Cc: jiri@resnulli.us
24
Cc: armbru@redhat.com
25
Cc: f4bug@amsat.org
26
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
27
Reviewed-by: Markus Armbruster <armbru@redhat.com>
28
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
29
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
30
---
11
---
31
hw/net/rocker/rocker.c | 27 +++++++++++----------------
12
hw/net/allwinner-sun8i-emac.c | 2 +-
32
1 file changed, 11 insertions(+), 16 deletions(-)
13
hw/net/can/can_sja1000.c | 8 ++++----
14
hw/net/can/can_sja1000.h | 2 +-
15
include/net/can_emu.h | 2 +-
16
net/can/can_socketcan.c | 4 ++--
17
5 files changed, 9 insertions(+), 9 deletions(-)
33
18
34
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
19
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
35
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/net/rocker/rocker.c
21
--- a/hw/net/allwinner-sun8i-emac.c
37
+++ b/hw/net/rocker/rocker.c
22
+++ b/hw/net/allwinner-sun8i-emac.c
38
@@ -XXX,XX +XXX,XX @@ rollback:
23
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_flush_desc(FrameDescriptor *desc,
39
return err;
24
cpu_physical_memory_write(phys_addr, desc, sizeof(*desc));
40
}
25
}
41
26
42
-static int rocker_msix_init(Rocker *r)
27
-static int allwinner_sun8i_emac_can_receive(NetClientState *nc)
43
+static int rocker_msix_init(Rocker *r, Error **errp)
28
+static bool allwinner_sun8i_emac_can_receive(NetClientState *nc)
44
{
29
{
45
PCIDevice *dev = PCI_DEVICE(r);
30
AwSun8iEmacState *s = qemu_get_nic_opaque(nc);
46
int err;
31
FrameDescriptor desc;
47
- Error *local_err = NULL;
32
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
48
33
index XXXXXXX..XXXXXXX 100644
49
err = msix_init(dev, ROCKER_MSIX_VEC_COUNT(r->fp_ports),
34
--- a/hw/net/can/can_sja1000.c
50
&r->msix_bar,
35
+++ b/hw/net/can/can_sja1000.c
51
ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_TABLE_OFFSET,
36
@@ -XXX,XX +XXX,XX @@ uint64_t can_sja_mem_read(CanSJA1000State *s, hwaddr addr, unsigned size)
52
&r->msix_bar,
37
return temp;
53
ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_PBA_OFFSET,
54
- 0, &local_err);
55
+ 0, errp);
56
if (err) {
57
- error_report_err(local_err);
58
return err;
59
}
60
61
@@ -XXX,XX +XXX,XX @@ static World *rocker_world_type_by_name(Rocker *r, const char *name)
62
return NULL;
63
}
38
}
64
39
65
-static int pci_rocker_init(PCIDevice *dev)
40
-int can_sja_can_receive(CanBusClientState *client)
66
+static void pci_rocker_realize(PCIDevice *dev, Error **errp)
41
+bool can_sja_can_receive(CanBusClientState *client)
67
{
42
{
68
Rocker *r = to_rocker(dev);
43
CanSJA1000State *s = container_of(client, CanSJA1000State, bus_client);
69
const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
44
70
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
45
if (s->clock & 0x80) { /* PeliCAN Mode */
71
46
if (s->mode & 0x01) { /* reset mode. */
72
r->world_dflt = rocker_world_type_by_name(r, r->world_name);
47
- return 0;
73
if (!r->world_dflt) {
48
+ return false;
74
- fprintf(stderr,
49
}
75
- "rocker: requested world \"%s\" does not exist\n",
50
} else { /* BasicCAN mode */
76
+ error_setg(errp,
51
if (s->control & 0x01) {
77
+ "invalid argument requested world %s does not exist",
52
- return 0;
78
r->world_name);
53
+ return false;
79
- err = -EINVAL;
80
goto err_world_type_by_name;
81
}
82
83
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
84
85
/* MSI-X init */
86
87
- err = rocker_msix_init(r);
88
+ err = rocker_msix_init(r, errp);
89
if (err) {
90
goto err_msix_init;
91
}
92
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
93
}
94
95
if (rocker_find(r->name)) {
96
- err = -EEXIST;
97
+ error_setg(errp, "%s already exists", r->name);
98
goto err_duplicate;
99
}
100
101
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
102
#define ROCKER_IFNAMSIZ 16
103
#define MAX_ROCKER_NAME_LEN (ROCKER_IFNAMSIZ - 1 - 3 - 3)
104
if (strlen(r->name) > MAX_ROCKER_NAME_LEN) {
105
- fprintf(stderr,
106
- "rocker: name too long; please shorten to at most %d chars\n",
107
+ error_setg(errp,
108
+ "name too long; please shorten to at most %d chars",
109
MAX_ROCKER_NAME_LEN);
110
- err = -EINVAL;
111
goto err_name_too_long;
112
}
113
114
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
115
116
QLIST_INSERT_HEAD(&rockers, r, next);
117
118
- return 0;
119
+ return;
120
121
err_name_too_long:
122
err_duplicate:
123
@@ -XXX,XX +XXX,XX @@ err_world_type_by_name:
124
world_free(r->worlds[i]);
125
}
54
}
126
}
55
}
127
- return err;
56
57
- return 1; /* always return 1, when operation mode */
58
+ return true; /* always return true, when operation mode */
128
}
59
}
129
60
130
static void pci_rocker_uninit(PCIDevice *dev)
61
ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,
131
@@ -XXX,XX +XXX,XX @@ static void rocker_class_init(ObjectClass *klass, void *data)
62
diff --git a/hw/net/can/can_sja1000.h b/hw/net/can/can_sja1000.h
132
DeviceClass *dc = DEVICE_CLASS(klass);
63
index XXXXXXX..XXXXXXX 100644
133
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
64
--- a/hw/net/can/can_sja1000.h
134
65
+++ b/hw/net/can/can_sja1000.h
135
- k->init = pci_rocker_init;
66
@@ -XXX,XX +XXX,XX @@ void can_sja_disconnect(CanSJA1000State *s);
136
+ k->realize = pci_rocker_realize;
67
137
k->exit = pci_rocker_uninit;
68
int can_sja_init(CanSJA1000State *s, qemu_irq irq);
138
k->vendor_id = PCI_VENDOR_ID_REDHAT;
69
139
k->device_id = PCI_DEVICE_ID_REDHAT_ROCKER;
70
-int can_sja_can_receive(CanBusClientState *client);
71
+bool can_sja_can_receive(CanBusClientState *client);
72
73
ssize_t can_sja_receive(CanBusClientState *client,
74
const qemu_can_frame *frames, size_t frames_cnt);
75
diff --git a/include/net/can_emu.h b/include/net/can_emu.h
76
index XXXXXXX..XXXXXXX 100644
77
--- a/include/net/can_emu.h
78
+++ b/include/net/can_emu.h
79
@@ -XXX,XX +XXX,XX @@ typedef struct CanBusClientState CanBusClientState;
80
typedef struct CanBusState CanBusState;
81
82
typedef struct CanBusClientInfo {
83
- int (*can_receive)(CanBusClientState *);
84
+ bool (*can_receive)(CanBusClientState *);
85
ssize_t (*receive)(CanBusClientState *,
86
const struct qemu_can_frame *frames, size_t frames_cnt);
87
} CanBusClientInfo;
88
diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c
89
index XXXXXXX..XXXXXXX 100644
90
--- a/net/can/can_socketcan.c
91
+++ b/net/can/can_socketcan.c
92
@@ -XXX,XX +XXX,XX @@ static void can_host_socketcan_read(void *opaque)
93
}
94
}
95
96
-static int can_host_socketcan_can_receive(CanBusClientState *client)
97
+static bool can_host_socketcan_can_receive(CanBusClientState *client)
98
{
99
- return 1;
100
+ return true;
101
}
102
103
static ssize_t can_host_socketcan_receive(CanBusClientState *client,
140
--
104
--
141
2.7.4
105
2.5.0
142
106
143
107
diff view generated by jsdifflib
Deleted patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
1
3
In net_socket_fd_init(), the 'default' case is odd: it warns,
4
then continues as if the socket type was SOCK_STREAM. The
5
comment explains "this could be a eg. a pty", but that makes
6
no sense. If @fd really was a pty, getsockopt() would fail
7
with ENOTSOCK. If @fd was a socket, but neither SOCK_DGRAM nor
8
SOCK_STREAM. It should not be treated as if it was SOCK_STREAM.
9
10
Turn this case into an Error. If there is a genuine reason to
11
support something like SOCK_RAW, it should be explicitly
12
handled.
13
14
Cc: jasowang@redhat.com
15
Cc: armbru@redhat.com
16
Cc: berrange@redhat.com
17
Cc: armbru@redhat.com
18
Cc: eblake@redhat.com
19
Suggested-by: Markus Armbruster <armbru@redhat.com>
20
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
21
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
22
Reviewed-by: Markus Armbruster <armbru@redhat.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
---
25
net/socket.c | 6 +++---
26
1 file changed, 3 insertions(+), 3 deletions(-)
27
28
diff --git a/net/socket.c b/net/socket.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/net/socket.c
31
+++ b/net/socket.c
32
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,
33
case SOCK_STREAM:
34
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
35
default:
36
- /* who knows ... this could be a eg. a pty, do warn and continue as stream */
37
- fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
38
- return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
39
+ error_report("socket type=%d for fd=%d must be either"
40
+ " SOCK_DGRAM or SOCK_STREAM", so_type, fd);
41
+ closesocket(fd);
42
}
43
return NULL;
44
}
45
--
46
2.7.4
47
48
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Zhang Chen <chen.zhang@intel.com>
2
2
3
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
3
The "compare_timeout" determines the maximum time to hold the primary net packet.
4
This patch expose the "compare_timeout", make user have ability to
5
adjest the value according to application scenarios.
6
7
QMP command demo:
8
{ "execute": "qom-get",
9
"arguments": { "path": "/objects/comp0",
10
"property": "compare_timeout" } }
11
12
{ "execute": "qom-set",
13
"arguments": { "path": "/objects/comp0",
14
"property": "compare_timeout",
15
"value": 5000} }
16
17
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
18
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
---
19
---
6
net/colo-compare.c | 59 ++++++++++++++++++++++++++++--------------------------
20
net/colo-compare.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
7
1 file changed, 31 insertions(+), 28 deletions(-)
21
qemu-options.hx | 8 +++++---
22
2 files changed, 50 insertions(+), 5 deletions(-)
8
23
9
diff --git a/net/colo-compare.c b/net/colo-compare.c
24
diff --git a/net/colo-compare.c b/net/colo-compare.c
10
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
11
--- a/net/colo-compare.c
26
--- a/net/colo-compare.c
12
+++ b/net/colo-compare.c
27
+++ b/net/colo-compare.c
13
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@ static NotifierList colo_compare_notifiers =
29
30
/* TODO: Should be configurable */
14
#define REGULAR_PACKET_CHECK_MS 3000
31
#define REGULAR_PACKET_CHECK_MS 3000
15
32
+#define DEFAULT_TIME_OUT_MS 3000
16
/*
33
17
- + CompareState ++
34
static QemuMutex event_mtx;
18
- | |
35
static QemuCond event_complete_cond;
19
- +---------------+ +---------------+ +---------------+
20
- |conn list +--->conn +--------->conn |
21
- +---------------+ +---------------+ +---------------+
22
- | | | | | |
23
- +---------------+ +---v----+ +---v----+ +---v----+ +---v----+
24
- |primary | |secondary |primary | |secondary
25
- |packet | |packet + |packet | |packet +
26
- +--------+ +--------+ +--------+ +--------+
27
- | | | |
28
- +---v----+ +---v----+ +---v----+ +---v----+
29
- |primary | |secondary |primary | |secondary
30
- |packet | |packet + |packet | |packet +
31
- +--------+ +--------+ +--------+ +--------+
32
- | | | |
33
- +---v----+ +---v----+ +---v----+ +---v----+
34
- |primary | |secondary |primary | |secondary
35
- |packet | |packet + |packet | |packet +
36
- +--------+ +--------+ +--------+ +--------+
37
-*/
38
+ * + CompareState ++
39
+ * | |
40
+ * +---------------+ +---------------+ +---------------+
41
+ * | conn list + - > conn + ------- > conn + -- > ......
42
+ * +---------------+ +---------------+ +---------------+
43
+ * | | | | | |
44
+ * +---------------+ +---v----+ +---v----+ +---v----+ +---v----+
45
+ * |primary | |secondary |primary | |secondary
46
+ * |packet | |packet + |packet | |packet +
47
+ * +--------+ +--------+ +--------+ +--------+
48
+ * | | | |
49
+ * +---v----+ +---v----+ +---v----+ +---v----+
50
+ * |primary | |secondary |primary | |secondary
51
+ * |packet | |packet + |packet | |packet +
52
+ * +--------+ +--------+ +--------+ +--------+
53
+ * | | | |
54
+ * +---v----+ +---v----+ +---v----+ +---v----+
55
+ * |primary | |secondary |primary | |secondary
56
+ * |packet | |packet + |packet | |packet +
57
+ * +--------+ +--------+ +--------+ +--------+
58
+ */
59
typedef struct CompareState {
60
Object parent;
61
62
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
36
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
63
SocketReadState sec_rs;
37
SocketReadState sec_rs;
38
SocketReadState notify_rs;
64
bool vnet_hdr;
39
bool vnet_hdr;
65
40
+ uint32_t compare_timeout;
66
- /* connection list: the connections belonged to this NIC could be found
41
67
- * in this list.
42
/*
68
- * element type: Connection
43
* Record the connection that through the NIC
69
+ /*
70
+ * Record the connection that through the NIC
71
+ * Element type: Connection
72
*/
73
GQueue conn_list;
74
- /* hashtable to save connection */
75
+ /* Record the connection without repetition */
76
GHashTable *connection_track_table;
77
- /* compare thread, a thread for each NIC */
78
+ /* This thread just do packet compare job */
79
QemuThread thread;
80
81
GMainContext *worker_context;
82
@@ -XXX,XX +XXX,XX @@ static int colo_old_packet_check_one_conn(Connection *conn,
44
@@ -XXX,XX +XXX,XX @@ static int colo_old_packet_check_one_conn(Connection *conn,
45
CompareState *s)
46
{
47
GList *result = NULL;
48
- int64_t check_time = REGULAR_PACKET_CHECK_MS;
49
50
result = g_queue_find_custom(&conn->primary_list,
51
- &check_time,
52
+ &s->compare_timeout,
83
(GCompareFunc)colo_old_packet_check_one);
53
(GCompareFunc)colo_old_packet_check_one);
84
54
85
if (result) {
55
if (result) {
86
- /* do checkpoint will flush old packet */
56
@@ -XXX,XX +XXX,XX @@ static void compare_set_notify_dev(Object *obj, const char *value, Error **errp)
87
- /* TODO: colo_notify_checkpoint();*/
57
s->notify_dev = g_strdup(value);
88
+ /* Do checkpoint will flush old packet */
58
}
89
+ /*
59
90
+ * TODO: Notify colo frame to do checkpoint.
60
+static void compare_get_timeout(Object *obj, Visitor *v,
91
+ * colo_compare_inconsistent_notify();
61
+ const char *name, void *opaque,
92
+ */
62
+ Error **errp)
93
return 0;
63
+{
64
+ CompareState *s = COLO_COMPARE(obj);
65
+ uint32_t value = s->compare_timeout;
66
+
67
+ visit_type_uint32(v, name, &value, errp);
68
+}
69
+
70
+static void compare_set_timeout(Object *obj, Visitor *v,
71
+ const char *name, void *opaque,
72
+ Error **errp)
73
+{
74
+ CompareState *s = COLO_COMPARE(obj);
75
+ Error *local_err = NULL;
76
+ uint32_t value;
77
+
78
+ visit_type_uint32(v, name, &value, &local_err);
79
+ if (local_err) {
80
+ goto out;
81
+ }
82
+ if (!value) {
83
+ error_setg(&local_err, "Property '%s.%s' requires a positive value",
84
+ object_get_typename(obj), name);
85
+ goto out;
86
+ }
87
+ s->compare_timeout = value;
88
+
89
+out:
90
+ error_propagate(errp, local_err);
91
+}
92
+
93
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
94
{
95
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
96
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
97
return;
94
}
98
}
95
99
100
+ if (!s->compare_timeout) {
101
+ /* Set default value to 3000 MS */
102
+ s->compare_timeout = DEFAULT_TIME_OUT_MS;
103
+ }
104
+
105
if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
106
!qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
107
return;
108
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
109
compare_get_notify_dev, compare_set_notify_dev,
110
NULL);
111
112
+ object_property_add(obj, "compare_timeout", "uint32",
113
+ compare_get_timeout,
114
+ compare_set_timeout, NULL, NULL, NULL);
115
+
116
s->vnet_hdr = false;
117
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
118
compare_set_vnet_hdr, NULL);
119
diff --git a/qemu-options.hx b/qemu-options.hx
120
index XXXXXXX..XXXXXXX 100644
121
--- a/qemu-options.hx
122
+++ b/qemu-options.hx
123
@@ -XXX,XX +XXX,XX @@ SRST
124
stored. The file format is libpcap, so it can be analyzed with
125
tools such as tcpdump or Wireshark.
126
127
- ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id]``
128
+ ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}]``
129
Colo-compare gets packet from primary\_inchardevid and
130
secondary\_inchardevid, than compare primary packet with
131
secondary packet. If the packets are same, we will output
132
@@ -XXX,XX +XXX,XX @@ SRST
133
outdevchardevid. In order to improve efficiency, we need to put
134
the task of comparison in another thread. If it has the
135
vnet\_hdr\_support flag, colo compare will send/recv packet with
136
- vnet\_hdr\_len. If you want to use Xen COLO, will need the
137
- notify\_dev to notify Xen colo-frame to do checkpoint.
138
+ vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the
139
+ maximum delay colo-compare wait for the packet.
140
+ If you want to use Xen COLO, will need the notify\_dev to
141
+ notify Xen colo-frame to do checkpoint.
142
143
we must use it with the help of filter-mirror and
144
filter-redirector.
96
--
145
--
97
2.7.4
146
2.5.0
98
147
99
148
diff view generated by jsdifflib
1
From: Wang Yong <wang.yong155@zte.com.cn>
1
From: Zhang Chen <chen.zhang@intel.com>
2
2
3
Remove the task which check old packet in the comparing thread,
3
The "expired_scan_cycle" determines period of scanning expired
4
then use IOthread context timer to handle it.
4
primary node net packets.
5
5
6
Process pactkets in the IOThread which arrived over the socket.
6
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
7
we use iothread_get_g_main_context to create a new g_main_loop in
8
the IOThread.then the packets from the primary and the secondary
9
are processed in the IOThread.
10
11
Finally remove the colo-compare thread using the IOThread instead.
12
13
Reviewed-by: Zhang Chen<zhangchen.fnst@cn.fujitsu.com>
14
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
15
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
8
---
18
net/colo-compare.c | 83 +++++++++++++++++++++++++++++-------------------------
9
net/colo-compare.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
19
1 file changed, 45 insertions(+), 38 deletions(-)
10
qemu-options.hx | 4 +++-
11
2 files changed, 48 insertions(+), 4 deletions(-)
20
12
21
diff --git a/net/colo-compare.c b/net/colo-compare.c
13
diff --git a/net/colo-compare.c b/net/colo-compare.c
22
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
23
--- a/net/colo-compare.c
15
--- a/net/colo-compare.c
24
+++ b/net/colo-compare.c
16
+++ b/net/colo-compare.c
25
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static NotifierList colo_compare_notifiers =
26
#include "qemu/sockets.h"
18
#define COLO_COMPARE_FREE_PRIMARY 0x01
27
#include "qapi-visit.h"
19
#define COLO_COMPARE_FREE_SECONDARY 0x02
28
#include "net/colo.h"
20
29
+#include "sysemu/iothread.h"
21
-/* TODO: Should be configurable */
30
22
#define REGULAR_PACKET_CHECK_MS 3000
31
#define TYPE_COLO_COMPARE "colo-compare"
23
#define DEFAULT_TIME_OUT_MS 3000
32
#define COLO_COMPARE(obj) \
24
33
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
25
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
34
GQueue conn_list;
26
SocketReadState notify_rs;
35
/* Record the connection without repetition */
27
bool vnet_hdr;
36
GHashTable *connection_track_table;
28
uint32_t compare_timeout;
37
- /* This thread just do packet compare job */
29
+ uint32_t expired_scan_cycle;
38
- QemuThread thread;
30
39
31
/*
40
+ IOThread *iothread;
32
* Record the connection that through the NIC
41
GMainContext *worker_context;
33
@@ -XXX,XX +XXX,XX @@ static void check_old_packet_regular(void *opaque)
42
- GMainLoop *compare_loop;
43
+ QEMUTimer *packet_check_timer;
44
} CompareState;
45
46
typedef struct CompareClass {
47
@@ -XXX,XX +XXX,XX @@ static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size)
48
* Check old packet regularly so it can watch for any packets
49
* that the secondary hasn't produced equivalents of.
50
*/
51
-static gboolean check_old_packet_regular(void *opaque)
52
+static void check_old_packet_regular(void *opaque)
53
{
54
CompareState *s = opaque;
55
56
/* if have old packet we will notify checkpoint */
34
/* if have old packet we will notify checkpoint */
57
colo_old_packet_check(s);
35
colo_old_packet_check(s);
58
+ timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
36
timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
59
+ REGULAR_PACKET_CHECK_MS);
37
- REGULAR_PACKET_CHECK_MS);
38
+ s->expired_scan_cycle);
39
}
40
41
/* Public API, Used for COLO frame to notify compare event */
42
@@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s)
43
SCALE_MS, check_old_packet_regular,
44
s);
45
timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
46
- REGULAR_PACKET_CHECK_MS);
47
+ s->expired_scan_cycle);
48
}
49
50
static void colo_compare_timer_del(CompareState *s)
51
@@ -XXX,XX +XXX,XX @@ out:
52
error_propagate(errp, local_err);
53
}
54
55
+static void compare_get_expired_scan_cycle(Object *obj, Visitor *v,
56
+ const char *name, void *opaque,
57
+ Error **errp)
58
+{
59
+ CompareState *s = COLO_COMPARE(obj);
60
+ uint32_t value = s->expired_scan_cycle;
61
+
62
+ visit_type_uint32(v, name, &value, errp);
60
+}
63
+}
61
+
64
+
62
+static void colo_compare_timer_init(CompareState *s)
65
+static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
66
+ const char *name, void *opaque,
67
+ Error **errp)
63
+{
68
+{
64
+ AioContext *ctx = iothread_get_aio_context(s->iothread);
69
+ CompareState *s = COLO_COMPARE(obj);
65
70
+ Error *local_err = NULL;
66
- return TRUE;
71
+ uint32_t value;
67
+ s->packet_check_timer = aio_timer_new(ctx, QEMU_CLOCK_VIRTUAL,
72
+
68
+ SCALE_MS, check_old_packet_regular,
73
+ visit_type_uint32(v, name, &value, &local_err);
69
+ s);
74
+ if (local_err) {
70
+ timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
75
+ goto out;
71
+ REGULAR_PACKET_CHECK_MS);
76
+ }
72
}
77
+ if (!value) {
73
78
+ error_setg(&local_err, "Property '%s.%s' requires a positive value",
74
-static void *colo_compare_thread(void *opaque)
79
+ object_get_typename(obj), name);
75
+static void colo_compare_timer_del(CompareState *s)
80
+ goto out;
81
+ }
82
+ s->expired_scan_cycle = value;
83
+
84
+out:
85
+ error_propagate(errp, local_err);
86
+}
87
+
88
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
76
{
89
{
77
- CompareState *s = opaque;
90
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
78
- GSource *timeout_source;
91
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
79
+ if (s->packet_check_timer) {
92
s->compare_timeout = DEFAULT_TIME_OUT_MS;
80
+ timer_del(s->packet_check_timer);
93
}
81
+ timer_free(s->packet_check_timer);
94
82
+ s->packet_check_timer = NULL;
95
+ if (!s->expired_scan_cycle) {
96
+ /* Set default value to 3000 MS */
97
+ s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
83
+ }
98
+ }
84
+ }
99
+
85
100
if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
86
- s->worker_context = g_main_context_new();
101
!qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
87
+static void colo_compare_iothread(CompareState *s)
88
+{
89
+ object_ref(OBJECT(s->iothread));
90
+ s->worker_context = iothread_get_g_main_context(s->iothread);
91
92
qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read,
93
compare_pri_chr_in, NULL, NULL,
94
@@ -XXX,XX +XXX,XX @@ static void *colo_compare_thread(void *opaque)
95
compare_sec_chr_in, NULL, NULL,
96
s, s->worker_context, true);
97
98
- s->compare_loop = g_main_loop_new(s->worker_context, FALSE);
99
-
100
- /* To kick any packets that the secondary doesn't match */
101
- timeout_source = g_timeout_source_new(REGULAR_PACKET_CHECK_MS);
102
- g_source_set_callback(timeout_source,
103
- (GSourceFunc)check_old_packet_regular, s, NULL);
104
- g_source_attach(timeout_source, s->worker_context);
105
-
106
- g_main_loop_run(s->compare_loop);
107
-
108
- g_source_unref(timeout_source);
109
- g_main_loop_unref(s->compare_loop);
110
- g_main_context_unref(s->worker_context);
111
- return NULL;
112
+ colo_compare_timer_init(s);
113
}
114
115
static char *compare_get_pri_indev(Object *obj, Error **errp)
116
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
117
{
118
CompareState *s = COLO_COMPARE(uc);
119
Chardev *chr;
120
- char thread_name[64];
121
- static int compare_id;
122
123
- if (!s->pri_indev || !s->sec_indev || !s->outdev) {
124
+ if (!s->pri_indev || !s->sec_indev || !s->outdev || !s->iothread) {
125
error_setg(errp, "colo compare needs 'primary_in' ,"
126
- "'secondary_in','outdev' property set");
127
+ "'secondary_in','outdev','iothread' property set");
128
return;
102
return;
129
} else if (!strcmp(s->pri_indev, s->outdev) ||
130
!strcmp(s->sec_indev, s->outdev) ||
131
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
132
g_free,
133
connection_destroy);
134
135
- sprintf(thread_name, "colo-compare %d", compare_id);
136
- qemu_thread_create(&s->thread, thread_name,
137
- colo_compare_thread, s,
138
- QEMU_THREAD_JOINABLE);
139
- compare_id++;
140
-
141
+ colo_compare_iothread(s);
142
return;
143
}
144
145
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
103
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
146
object_property_add_str(obj, "outdev",
104
compare_get_timeout,
147
compare_get_outdev, compare_set_outdev,
105
compare_set_timeout, NULL, NULL, NULL);
148
NULL);
106
149
+ object_property_add_link(obj, "iothread", TYPE_IOTHREAD,
107
+ object_property_add(obj, "expired_scan_cycle", "uint32",
150
+ (Object **)&s->iothread,
108
+ compare_get_expired_scan_cycle,
151
+ object_property_allow_set_link,
109
+ compare_set_expired_scan_cycle, NULL, NULL, NULL);
152
+ OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL);
110
+
153
154
s->vnet_hdr = false;
111
s->vnet_hdr = false;
155
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
112
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
156
@@ -XXX,XX +XXX,XX @@ static void colo_compare_finalize(Object *obj)
113
compare_set_vnet_hdr, NULL);
157
qemu_chr_fe_deinit(&s->chr_pri_in, false);
114
diff --git a/qemu-options.hx b/qemu-options.hx
158
qemu_chr_fe_deinit(&s->chr_sec_in, false);
115
index XXXXXXX..XXXXXXX 100644
159
qemu_chr_fe_deinit(&s->chr_out, false);
116
--- a/qemu-options.hx
160
-
117
+++ b/qemu-options.hx
161
- g_main_loop_quit(s->compare_loop);
118
@@ -XXX,XX +XXX,XX @@ SRST
162
- qemu_thread_join(&s->thread);
119
stored. The file format is libpcap, so it can be analyzed with
163
-
120
tools such as tcpdump or Wireshark.
164
+ if (s->iothread) {
121
165
+ colo_compare_timer_del(s);
122
- ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}]``
166
+ }
123
+ ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}][,expired_scan_cycle=@var{ms}``
167
/* Release all unhandled packets after compare thead exited */
124
Colo-compare gets packet from primary\_inchardevid and
168
g_queue_foreach(&s->conn_list, colo_flush_packets, s);
125
secondary\_inchardevid, than compare primary packet with
169
126
secondary packet. If the packets are same, we will output
170
g_queue_clear(&s->conn_list);
127
@@ -XXX,XX +XXX,XX @@ SRST
171
128
vnet\_hdr\_support flag, colo compare will send/recv packet with
172
- g_hash_table_destroy(s->connection_track_table);
129
vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the
173
+ if (s->connection_track_table) {
130
maximum delay colo-compare wait for the packet.
174
+ g_hash_table_destroy(s->connection_track_table);
131
+ The expired\_scan\_cycle=@var{ms} to set the period of scanning
175
+ }
132
+ expired primary node network packets.
176
+
133
If you want to use Xen COLO, will need the notify\_dev to
177
+ if (s->iothread) {
134
notify Xen colo-frame to do checkpoint.
178
+ object_unref(OBJECT(s->iothread));
135
179
+ }
180
g_free(s->pri_indev);
181
g_free(s->sec_indev);
182
g_free(s->outdev);
183
--
136
--
184
2.7.4
137
2.5.0
185
138
186
139
diff view generated by jsdifflib
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
From: Prasad J Pandit <pjp@fedoraproject.org>
2
2
3
When -net socket fails, it first reports a specific error, then
3
Tulip network driver while copying tx/rx buffers does not check
4
a generic one, like this:
4
frame size against r/w data length. This may lead to OOB buffer
5
access. Add check to avoid it.
5
6
6
$ ./x86_64-softmmu/qemu-system-x86_64 -net socket,mcast=230.0.0.1:1234,listen
7
Limit iterations over descriptors to avoid potential infinite
7
qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: exactly one of listen=, connect=, mcast= or udp= is required
8
loop issue in tulip_xmit_list_update.
8
qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: Device 'socket' could not be initialized
9
9
10
Convert net_socket_*_init() to Error to get rid of the superfluous second
10
Reported-by: Li Qiang <pangpei.lq@antfin.com>
11
error message. After the patch, the effect like this:
11
Reported-by: Ziming Zhang <ezrakiez@gmail.com>
12
12
Reported-by: Jason Wang <jasowang@redhat.com>
13
$ ./x86_64-softmmu/qemu-system-x86_64 -net socket,mcast=230.0.0.1:1234,listen
13
Tested-by: Li Qiang <liq3ea@gmail.com>
14
qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: exactly one of listen=, connect=, mcast= or udp= is requireda
14
Reviewed-by: Li Qiang <liq3ea@gmail.com>
15
15
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
16
This also fixes a few silent failures to report an error.
17
18
Cc: jasowang@redhat.com
19
Cc: armbru@redhat.com
20
Cc: berrange@redhat.com
21
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
22
Reviewed-by: Markus Armbruster <armbru@redhat.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
---
17
---
25
net/socket.c | 92 +++++++++++++++++++++++++++++-------------------------------
18
hw/net/tulip.c | 36 +++++++++++++++++++++++++++---------
26
1 file changed, 44 insertions(+), 48 deletions(-)
19
1 file changed, 27 insertions(+), 9 deletions(-)
27
20
28
diff --git a/net/socket.c b/net/socket.c
21
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
29
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
30
--- a/net/socket.c
23
--- a/hw/net/tulip.c
31
+++ b/net/socket.c
24
+++ b/hw/net/tulip.c
32
@@ -XXX,XX +XXX,XX @@ static void net_socket_accept(void *opaque)
25
@@ -XXX,XX +XXX,XX @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
33
static int net_socket_listen_init(NetClientState *peer,
26
} else {
34
const char *model,
27
len = s->rx_frame_len;
35
const char *name,
36
- const char *host_str)
37
+ const char *host_str,
38
+ Error **errp)
39
{
40
NetClientState *nc;
41
NetSocketState *s;
42
struct sockaddr_in saddr;
43
int fd, ret;
44
- Error *err = NULL;
45
46
- if (parse_host_port(&saddr, host_str, &err) < 0) {
47
- error_report_err(err);
48
+ if (parse_host_port(&saddr, host_str, errp) < 0) {
49
return -1;
50
}
51
52
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
53
if (fd < 0) {
54
- perror("socket");
55
+ error_setg_errno(errp, errno, "can't create stream socket");
56
return -1;
57
}
58
qemu_set_nonblock(fd);
59
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
60
61
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
62
if (ret < 0) {
63
- perror("bind");
64
+ error_setg_errno(errp, errno, "can't bind ip=%s to socket",
65
+ inet_ntoa(saddr.sin_addr));
66
closesocket(fd);
67
return -1;
68
}
69
ret = listen(fd, 0);
70
if (ret < 0) {
71
- perror("listen");
72
+ error_setg_errno(errp, errno, "can't listen on socket");
73
closesocket(fd);
74
return -1;
75
}
76
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
77
static int net_socket_connect_init(NetClientState *peer,
78
const char *model,
79
const char *name,
80
- const char *host_str)
81
+ const char *host_str,
82
+ Error **errp)
83
{
84
NetSocketState *s;
85
int fd, connected, ret;
86
struct sockaddr_in saddr;
87
- Error *err = NULL;
88
89
- if (parse_host_port(&saddr, host_str, &err) < 0) {
90
- error_report_err(err);
91
+ if (parse_host_port(&saddr, host_str, errp) < 0) {
92
return -1;
93
}
94
95
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
96
if (fd < 0) {
97
- perror("socket");
98
+ error_setg_errno(errp, errno, "can't create stream socket");
99
return -1;
100
}
101
qemu_set_nonblock(fd);
102
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
103
errno == EINVAL) {
104
break;
105
} else {
106
- perror("connect");
107
+ error_setg_errno(errp, errno, "can't connect socket");
108
closesocket(fd);
109
return -1;
110
}
111
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
112
break;
113
}
28
}
114
}
29
+
115
- s = net_socket_fd_init(peer, model, name, fd, connected, NULL, &err);
30
+ if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
116
+ s = net_socket_fd_init(peer, model, name, fd, connected, NULL, errp);
31
+ return;
117
if (!s) {
118
- error_report_err(err);
119
return -1;
120
}
121
122
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
123
const char *model,
124
const char *name,
125
const char *host_str,
126
- const char *localaddr_str)
127
+ const char *localaddr_str,
128
+ Error **errp)
129
{
130
NetSocketState *s;
131
int fd;
132
struct sockaddr_in saddr;
133
struct in_addr localaddr, *param_localaddr;
134
- Error *err = NULL;
135
136
- if (parse_host_port(&saddr, host_str, &err) < 0) {
137
- error_report_err(err);
138
+ if (parse_host_port(&saddr, host_str, errp) < 0) {
139
return -1;
140
}
141
142
if (localaddr_str != NULL) {
143
- if (inet_aton(localaddr_str, &localaddr) == 0)
144
+ if (inet_aton(localaddr_str, &localaddr) == 0) {
145
+ error_setg(errp, "localaddr '%s' is not a valid IPv4 address",
146
+ localaddr_str);
147
return -1;
148
+ }
32
+ }
149
param_localaddr = &localaddr;
33
pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
150
} else {
34
(s->rx_frame_size - s->rx_frame_len), len);
151
param_localaddr = NULL;
35
s->rx_frame_len -= len;
152
}
36
@@ -XXX,XX +XXX,XX @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
153
37
} else {
154
- fd = net_socket_mcast_create(&saddr, param_localaddr, &err);
38
len = s->rx_frame_len;
155
+ fd = net_socket_mcast_create(&saddr, param_localaddr, errp);
156
if (fd < 0) {
157
- error_report_err(err);
158
return -1;
159
}
160
161
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
162
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, errp);
163
if (!s) {
164
- error_report_err(err);
165
return -1;
166
}
167
168
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
169
const char *model,
170
const char *name,
171
const char *rhost,
172
- const char *lhost)
173
+ const char *lhost,
174
+ Error **errp)
175
{
176
NetSocketState *s;
177
int fd, ret;
178
struct sockaddr_in laddr, raddr;
179
- Error *err = NULL;
180
181
- if (parse_host_port(&laddr, lhost, &err) < 0) {
182
- error_report_err(err);
183
+ if (parse_host_port(&laddr, lhost, errp) < 0) {
184
return -1;
185
}
186
187
- if (parse_host_port(&raddr, rhost, &err) < 0) {
188
- error_report_err(err);
189
+ if (parse_host_port(&raddr, rhost, errp) < 0) {
190
return -1;
191
}
192
193
fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);
194
if (fd < 0) {
195
- perror("socket(PF_INET, SOCK_DGRAM)");
196
+ error_setg_errno(errp, errno, "can't create datagram socket");
197
return -1;
198
}
199
200
ret = socket_set_fast_reuse(fd);
201
if (ret < 0) {
202
+ error_setg_errno(errp, errno,
203
+ "can't set socket option SO_REUSEADDR");
204
closesocket(fd);
205
return -1;
206
}
207
ret = bind(fd, (struct sockaddr *)&laddr, sizeof(laddr));
208
if (ret < 0) {
209
- perror("bind");
210
+ error_setg_errno(errp, errno, "can't bind ip=%s to socket",
211
+ inet_ntoa(laddr.sin_addr));
212
closesocket(fd);
213
return -1;
214
}
215
qemu_set_nonblock(fd);
216
217
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
218
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, errp);
219
if (!s) {
220
- error_report_err(err);
221
return -1;
222
}
223
224
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
225
int net_init_socket(const Netdev *netdev, const char *name,
226
NetClientState *peer, Error **errp)
227
{
228
- /* FIXME error_setg(errp, ...) on failure */
229
- Error *err = NULL;
230
const NetdevSocketOptions *sock;
231
232
assert(netdev->type == NET_CLIENT_DRIVER_SOCKET);
233
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
234
235
if (sock->has_listen + sock->has_connect + sock->has_mcast +
236
sock->has_udp > 1) {
237
- error_report("exactly one of listen=, connect=, mcast= or udp="
238
- " is required");
239
+ error_setg(errp, "exactly one of listen=, connect=, mcast= or udp="
240
+ " is required");
241
return -1;
242
}
243
244
if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) {
245
- error_report("localaddr= is only valid with mcast= or udp=");
246
+ error_setg(errp, "localaddr= is only valid with mcast= or udp=");
247
return -1;
248
}
249
250
if (sock->has_fd) {
251
int fd;
252
253
- fd = monitor_fd_param(cur_mon, sock->fd, &err);
254
+ fd = monitor_fd_param(cur_mon, sock->fd, errp);
255
if (fd == -1) {
256
- error_report_err(err);
257
return -1;
258
}
39
}
259
qemu_set_nonblock(fd);
40
+
260
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
41
+ if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
261
}
42
+ return;
262
43
+ }
263
if (sock->has_listen) {
44
pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
264
- if (net_socket_listen_init(peer, "socket", name, sock->listen) == -1) {
45
(s->rx_frame_size - s->rx_frame_len), len);
265
+ if (net_socket_listen_init(peer, "socket", name, sock->listen, errp)
46
s->rx_frame_len -= len;
266
+ < 0) {
47
@@ -XXX,XX +XXX,XX @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
267
return -1;
48
268
}
49
trace_tulip_receive(buf, size);
50
51
- if (size < 14 || size > 2048 || s->rx_frame_len || tulip_rx_stopped(s)) {
52
+ if (size < 14 || size > sizeof(s->rx_frame) - 4
53
+ || s->rx_frame_len || tulip_rx_stopped(s)) {
269
return 0;
54
return 0;
270
}
55
}
271
56
272
if (sock->has_connect) {
57
@@ -XXX,XX +XXX,XX @@ static ssize_t tulip_receive_nc(NetClientState *nc,
273
- if (net_socket_connect_init(peer, "socket", name, sock->connect) ==
58
return tulip_receive(qemu_get_nic_opaque(nc), buf, size);
274
- -1) {
59
}
275
+ if (net_socket_connect_init(peer, "socket", name, sock->connect, errp)
60
276
+ < 0) {
61
-
277
return -1;
62
static NetClientInfo net_tulip_info = {
63
.type = NET_CLIENT_DRIVER_NIC,
64
.size = sizeof(NICState),
65
@@ -XXX,XX +XXX,XX @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
66
if ((s->csr[6] >> CSR6_OM_SHIFT) & CSR6_OM_MASK) {
67
/* Internal or external Loopback */
68
tulip_receive(s, s->tx_frame, s->tx_frame_len);
69
- } else {
70
+ } else if (s->tx_frame_len <= sizeof(s->tx_frame)) {
71
qemu_send_packet(qemu_get_queue(s->nic),
72
s->tx_frame, s->tx_frame_len);
278
}
73
}
279
return 0;
74
@@ -XXX,XX +XXX,XX @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
280
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
75
}
281
/* if sock->localaddr is missing, it has been initialized to "all bits
76
}
282
* zero" */
77
283
if (net_socket_mcast_init(peer, "socket", name, sock->mcast,
78
-static void tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
284
- sock->localaddr) == -1) {
79
+static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
285
+ sock->localaddr, errp) < 0) {
80
{
286
return -1;
81
int len1 = (desc->control >> TDES1_BUF1_SIZE_SHIFT) & TDES1_BUF1_SIZE_MASK;
82
int len2 = (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZE_MASK;
83
84
+ if (s->tx_frame_len + len1 > sizeof(s->tx_frame)) {
85
+ return -1;
86
+ }
87
if (len1) {
88
pci_dma_read(&s->dev, desc->buf_addr1,
89
s->tx_frame + s->tx_frame_len, len1);
90
s->tx_frame_len += len1;
91
}
92
93
+ if (s->tx_frame_len + len2 > sizeof(s->tx_frame)) {
94
+ return -1;
95
+ }
96
if (len2) {
97
pci_dma_read(&s->dev, desc->buf_addr2,
98
s->tx_frame + s->tx_frame_len, len2);
99
s->tx_frame_len += len2;
100
}
101
desc->status = (len1 + len2) ? 0 : 0x7fffffff;
102
+
103
+ return 0;
104
}
105
106
static void tulip_setup_filter_addr(TULIPState *s, uint8_t *buf, int n)
107
@@ -XXX,XX +XXX,XX @@ static uint32_t tulip_ts(TULIPState *s)
108
109
static void tulip_xmit_list_update(TULIPState *s)
110
{
111
+#define TULIP_DESC_MAX 128
112
+ uint8_t i = 0;
113
struct tulip_descriptor desc;
114
115
if (tulip_ts(s) != CSR5_TS_SUSPENDED) {
116
return;
117
}
118
119
- for (;;) {
120
+ for (i = 0; i < TULIP_DESC_MAX; i++) {
121
tulip_desc_read(s, s->current_tx_desc, &desc);
122
tulip_dump_tx_descriptor(s, &desc);
123
124
@@ -XXX,XX +XXX,XX @@ static void tulip_xmit_list_update(TULIPState *s)
125
s->tx_frame_len = 0;
126
}
127
128
- tulip_copy_tx_buffers(s, &desc);
129
-
130
- if (desc.control & TDES1_LS) {
131
- tulip_tx(s, &desc);
132
+ if (!tulip_copy_tx_buffers(s, &desc)) {
133
+ if (desc.control & TDES1_LS) {
134
+ tulip_tx(s, &desc);
135
+ }
136
}
287
}
137
}
288
return 0;
138
tulip_desc_write(s, s->current_tx_desc, &desc);
289
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
290
291
assert(sock->has_udp);
292
if (!sock->has_localaddr) {
293
- error_report("localaddr= is mandatory with udp=");
294
+ error_setg(errp, "localaddr= is mandatory with udp=");
295
return -1;
296
}
297
- if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) ==
298
- -1) {
299
+ if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr,
300
+ errp) < 0) {
301
return -1;
302
}
303
return 0;
304
--
139
--
305
2.7.4
140
2.5.0
306
141
307
142
diff view generated by jsdifflib
1
From: Wang Yong <wang.yong155@zte.com.cn>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
IOThread uses AioContext event loop and does not run a GMainContext.
3
Coverity points out (CID 1421926) that the read code for
4
Therefore,chardev cannot work in IOThread,such as the chardev is
4
REG_ADDR_HIGH reads off the end of the buffer, because it does a
5
used for colo-compare packets reception.
5
32-bit read from byte 4 of a 6-byte buffer.
6
6
7
This patch makes the IOThread run the GMainContext event loop,
7
The code also has an endianness issue for both REG_ADDR_HIGH and
8
chardev and IOThread can work together.
8
REG_ADDR_LOW, because it will do the wrong thing on a big-endian
9
host.
9
10
10
Reviewed-by: Fam Zheng <famz@redhat.com>
11
Rewrite the read code to use ldl_le_p() and lduw_le_p() to fix this;
11
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
12
the write code is not incorrect, but for consistency we make it use
12
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
13
stl_le_p() and stw_le_p().
14
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
17
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Jason Wang <jasowang@redhat.com>
19
Signed-off-by: Jason Wang <jasowang@redhat.com>
14
---
20
---
15
include/sysemu/iothread.h | 4 ++++
21
hw/net/allwinner-sun8i-emac.c | 12 ++++--------
16
iothread.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
22
1 file changed, 4 insertions(+), 8 deletions(-)
17
2 files changed, 49 insertions(+)
18
23
19
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
24
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
20
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
21
--- a/include/sysemu/iothread.h
26
--- a/hw/net/allwinner-sun8i-emac.c
22
+++ b/include/sysemu/iothread.h
27
+++ b/hw/net/allwinner-sun8i-emac.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct {
28
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
24
29
value = s->mii_data;
25
QemuThread thread;
30
break;
26
AioContext *ctx;
31
case REG_ADDR_HIGH: /* MAC Address High */
27
+ GMainContext *worker_context;
32
- value = *(((uint32_t *) (s->conf.macaddr.a)) + 1);
28
+ GMainLoop *main_loop;
33
+ value = lduw_le_p(s->conf.macaddr.a + 4);
29
+ GOnce once;
34
break;
30
QemuMutex init_done_lock;
35
case REG_ADDR_LOW: /* MAC Address Low */
31
QemuCond init_done_cond; /* is thread initialization done? */
36
- value = *(uint32_t *) (s->conf.macaddr.a);
32
bool stopping;
37
+ value = ldl_le_p(s->conf.macaddr.a);
33
@@ -XXX,XX +XXX,XX @@ typedef struct {
38
break;
34
char *iothread_get_id(IOThread *iothread);
39
case REG_TX_DMA_STA: /* Transmit DMA Status */
35
AioContext *iothread_get_aio_context(IOThread *iothread);
40
break;
36
void iothread_stop_all(void);
41
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_write(void *opaque, hwaddr offset,
37
+GMainContext *iothread_get_g_main_context(IOThread *iothread);
42
s->mii_data = value;
38
43
break;
39
#endif /* IOTHREAD_H */
44
case REG_ADDR_HIGH: /* MAC Address High */
40
diff --git a/iothread.c b/iothread.c
45
- s->conf.macaddr.a[4] = (value & 0xff);
41
index XXXXXXX..XXXXXXX 100644
46
- s->conf.macaddr.a[5] = (value & 0xff00) >> 8;
42
--- a/iothread.c
47
+ stw_le_p(s->conf.macaddr.a + 4, value);
43
+++ b/iothread.c
48
break;
44
@@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque)
49
case REG_ADDR_LOW: /* MAC Address Low */
45
50
- s->conf.macaddr.a[0] = (value & 0xff);
46
while (!atomic_read(&iothread->stopping)) {
51
- s->conf.macaddr.a[1] = (value & 0xff00) >> 8;
47
aio_poll(iothread->ctx, true);
52
- s->conf.macaddr.a[2] = (value & 0xff0000) >> 16;
48
+
53
- s->conf.macaddr.a[3] = (value & 0xff000000) >> 24;
49
+ if (atomic_read(&iothread->worker_context)) {
54
+ stl_le_p(s->conf.macaddr.a, value);
50
+ GMainLoop *loop;
55
break;
51
+
56
case REG_TX_DMA_STA: /* Transmit DMA Status */
52
+ g_main_context_push_thread_default(iothread->worker_context);
57
case REG_TX_CUR_DESC: /* Transmit Current Descriptor */
53
+ iothread->main_loop =
54
+ g_main_loop_new(iothread->worker_context, TRUE);
55
+ loop = iothread->main_loop;
56
+
57
+ g_main_loop_run(iothread->main_loop);
58
+ iothread->main_loop = NULL;
59
+ g_main_loop_unref(loop);
60
+
61
+ g_main_context_pop_thread_default(iothread->worker_context);
62
+ g_main_context_unref(iothread->worker_context);
63
+ iothread->worker_context = NULL;
64
+ }
65
}
66
67
rcu_unregister_thread();
68
@@ -XXX,XX +XXX,XX @@ static int iothread_stop(Object *object, void *opaque)
69
}
70
iothread->stopping = true;
71
aio_notify(iothread->ctx);
72
+ if (atomic_read(&iothread->main_loop)) {
73
+ g_main_loop_quit(iothread->main_loop);
74
+ }
75
qemu_thread_join(&iothread->thread);
76
return 0;
77
}
78
@@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp)
79
80
qemu_mutex_init(&iothread->init_done_lock);
81
qemu_cond_init(&iothread->init_done_cond);
82
+ iothread->once = (GOnce) G_ONCE_INIT;
83
84
/* This assumes we are called from a thread with useful CPU affinity for us
85
* to inherit.
86
@@ -XXX,XX +XXX,XX @@ void iothread_stop_all(void)
87
88
object_child_foreach(container, iothread_stop, NULL);
89
}
90
+
91
+static gpointer iothread_g_main_context_init(gpointer opaque)
92
+{
93
+ AioContext *ctx;
94
+ IOThread *iothread = opaque;
95
+ GSource *source;
96
+
97
+ iothread->worker_context = g_main_context_new();
98
+
99
+ ctx = iothread_get_aio_context(iothread);
100
+ source = aio_get_g_source(ctx);
101
+ g_source_attach(source, iothread->worker_context);
102
+ g_source_unref(source);
103
+
104
+ aio_notify(iothread->ctx);
105
+ return NULL;
106
+}
107
+
108
+GMainContext *iothread_get_g_main_context(IOThread *iothread)
109
+{
110
+ g_once(&iothread->once, iothread_g_main_context_init, iothread);
111
+
112
+ return iothread->worker_context;
113
+}
114
--
58
--
115
2.7.4
59
2.5.0
116
60
117
61
diff view generated by jsdifflib
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
From: Li Qiang <liq3ea@163.com>
2
2
3
Currently, net_socket_mcast_create(), net_socket_fd_init_dgram() and
3
The tulip networking card emulation has an OOB issue in
4
net_socket_fd_init() use the function such as fprintf(), perror() to
4
'tulip_copy_tx_buffers' when the guest provide malformed descriptor.
5
report an error message.
5
This test will trigger a ASAN heap overflow crash. To trigger this
6
issue we can construct the data as following:
6
7
7
Now, convert these functions to Error.
8
1. construct a 'tulip_descriptor'. Its control is set to
9
'0x7ff | 0x7ff << 11', this will make the 'tulip_copy_tx_buffers's
10
'len1' and 'len2' to 0x7ff(2047). So 'len1+len2' will overflow
11
'TULIPState's 'tx_frame' field. This descriptor's 'buf_addr1' and
12
'buf_addr2' should set to a guest address.
8
13
9
Cc: jasowang@redhat.com
14
2. write this descriptor to tulip device's CSR4 register. This will
10
Cc: armbru@redhat.com
15
set the 'TULIPState's 'current_tx_desc' field.
11
Cc: berrange@redhat.com
16
12
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
17
3. write 'CSR6_ST' to tulip device's CSR6 register. This will trigger
13
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
18
'tulip_xmit_list_update' and finally calls 'tulip_copy_tx_buffers'.
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
19
20
Following shows the backtrack of crash:
21
22
==31781==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x628000007cd0 at pc 0x7fe03c5a077a bp 0x7fff05b46770 sp 0x7fff05b45f18
23
WRITE of size 2047 at 0x628000007cd0 thread T0
24
#0 0x7fe03c5a0779 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x79779)
25
#1 0x5575fb6daa6a in flatview_read_continue /home/test/qemu/exec.c:3194
26
#2 0x5575fb6daccb in flatview_read /home/test/qemu/exec.c:3227
27
#3 0x5575fb6dae66 in address_space_read_full /home/test/qemu/exec.c:3240
28
#4 0x5575fb6db0cb in address_space_rw /home/test/qemu/exec.c:3268
29
#5 0x5575fbdfd460 in dma_memory_rw_relaxed /home/test/qemu/include/sysemu/dma.h:87
30
#6 0x5575fbdfd4b5 in dma_memory_rw /home/test/qemu/include/sysemu/dma.h:110
31
#7 0x5575fbdfd866 in pci_dma_rw /home/test/qemu/include/hw/pci/pci.h:787
32
#8 0x5575fbdfd8a3 in pci_dma_read /home/test/qemu/include/hw/pci/pci.h:794
33
#9 0x5575fbe02761 in tulip_copy_tx_buffers hw/net/tulip.c:585
34
#10 0x5575fbe0366b in tulip_xmit_list_update hw/net/tulip.c:678
35
#11 0x5575fbe04073 in tulip_write hw/net/tulip.c:783
36
37
Signed-off-by: Li Qiang <liq3ea@163.com>
15
Signed-off-by: Jason Wang <jasowang@redhat.com>
38
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
---
39
---
17
net/socket.c | 82 ++++++++++++++++++++++++++++++++++++------------------------
40
tests/qtest/Makefile.include | 1 +
18
1 file changed, 50 insertions(+), 32 deletions(-)
41
tests/qtest/tulip-test.c | 91 ++++++++++++++++++++++++++++++++++++++++++++
42
2 files changed, 92 insertions(+)
43
create mode 100644 tests/qtest/tulip-test.c
19
44
20
diff --git a/net/socket.c b/net/socket.c
45
diff --git a/tests/qtest/Makefile.include b/tests/qtest/Makefile.include
21
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
22
--- a/net/socket.c
47
--- a/tests/qtest/Makefile.include
23
+++ b/net/socket.c
48
+++ b/tests/qtest/Makefile.include
24
@@ -XXX,XX +XXX,XX @@ static void net_socket_send_dgram(void *opaque)
49
@@ -XXX,XX +XXX,XX @@ qos-test-obj-y += tests/qtest/es1370-test.o
25
}
50
qos-test-obj-y += tests/qtest/ipoctal232-test.o
26
}
51
qos-test-obj-y += tests/qtest/megasas-test.o
27
52
qos-test-obj-y += tests/qtest/ne2000-test.o
28
-static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr *localaddr)
53
+qos-test-obj-y += tests/qtest/tulip-test.o
29
+static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
54
qos-test-obj-y += tests/qtest/nvme-test.o
30
+ struct in_addr *localaddr,
55
qos-test-obj-y += tests/qtest/pca9552-test.o
31
+ Error **errp)
56
qos-test-obj-y += tests/qtest/pci-test.o
32
{
57
diff --git a/tests/qtest/tulip-test.c b/tests/qtest/tulip-test.c
33
struct ip_mreq imr;
58
new file mode 100644
34
int fd;
59
index XXXXXXX..XXXXXXX
35
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
60
--- /dev/null
36
#endif
61
+++ b/tests/qtest/tulip-test.c
37
62
@@ -XXX,XX +XXX,XX @@
38
if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) {
63
+/*
39
- fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) "
64
+ * QTest testcase for DEC/Intel Tulip 21143
40
- "does not contain a multicast address\n",
65
+ *
41
- inet_ntoa(mcastaddr->sin_addr),
66
+ * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
42
- (int)ntohl(mcastaddr->sin_addr.s_addr));
67
+ *
43
+ error_setg(errp, "specified mcastaddr %s (0x%08x) "
68
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
44
+ "does not contain a multicast address",
69
+ * See the COPYING file in the top-level directory.
45
+ inet_ntoa(mcastaddr->sin_addr),
70
+ */
46
+ (int)ntohl(mcastaddr->sin_addr.s_addr));
47
return -1;
48
-
49
}
50
+
71
+
51
fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);
72
+#include "qemu/osdep.h"
52
if (fd < 0) {
73
+#include "libqtest.h"
53
- perror("socket(PF_INET, SOCK_DGRAM)");
74
+#include "qemu/module.h"
54
+ error_setg_errno(errp, errno, "can't create datagram socket");
75
+#include "libqos/qgraph.h"
55
return -1;
76
+#include "libqos/pci.h"
56
}
77
+#include "qemu/bitops.h"
57
78
+#include "hw/net/tulip.h"
58
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
79
+
59
val = 1;
80
+typedef struct QTulip_pci QTulip_pci;
60
ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
81
+
61
if (ret < 0) {
82
+struct QTulip_pci {
62
- perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
83
+ QOSGraphObject obj;
63
+ error_setg_errno(errp, errno,
84
+ QPCIDevice dev;
64
+ "can't set socket option SO_REUSEADDR");
85
+};
65
goto fail;
86
+
66
}
87
+static void *tulip_pci_get_driver(void *obj, const char *interface)
67
88
+{
68
ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr));
89
+ QTulip_pci *tulip_pci = obj;
69
if (ret < 0) {
90
+
70
- perror("bind");
91
+ if (!g_strcmp0(interface, "pci-device")) {
71
+ error_setg_errno(errp, errno, "can't bind ip=%s to socket",
92
+ return &tulip_pci->dev;
72
+ inet_ntoa(mcastaddr->sin_addr));
73
goto fail;
74
}
75
76
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
77
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
78
&imr, sizeof(struct ip_mreq));
79
if (ret < 0) {
80
- perror("setsockopt(IP_ADD_MEMBERSHIP)");
81
+ error_setg_errno(errp, errno,
82
+ "can't add socket to multicast group %s",
83
+ inet_ntoa(imr.imr_multiaddr));
84
goto fail;
85
}
86
87
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
88
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
89
&loop, sizeof(loop));
90
if (ret < 0) {
91
- perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)");
92
+ error_setg_errno(errp, errno,
93
+ "can't force multicast message to loopback");
94
goto fail;
95
}
96
97
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
98
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
99
localaddr, sizeof(*localaddr));
100
if (ret < 0) {
101
- perror("setsockopt(IP_MULTICAST_IF)");
102
+ error_setg_errno(errp, errno,
103
+ "can't set the default network send interface");
104
goto fail;
105
}
106
}
107
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
108
const char *model,
109
const char *name,
110
int fd, int is_connected,
111
- const char *mcast)
112
+ const char *mcast,
113
+ Error **errp)
114
{
115
struct sockaddr_in saddr;
116
int newfd;
117
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
118
119
if (is_connected && mcast != NULL) {
120
if (parse_host_port(&saddr, mcast) < 0) {
121
- fprintf(stderr,
122
- "qemu: error: init_dgram: fd=%d failed parse_host_port()\n",
123
- fd);
124
+ error_setg(errp, "fd=%d failed parse_host_port()", fd);
125
goto err;
126
}
127
/* must be bound */
128
if (saddr.sin_addr.s_addr == 0) {
129
- fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
130
- "cannot setup multicast dst addr\n", fd);
131
+ error_setg(errp, "can't setup multicast destination address");
132
goto err;
133
}
134
/* clone dgram socket */
135
- newfd = net_socket_mcast_create(&saddr, NULL);
136
+ newfd = net_socket_mcast_create(&saddr, NULL, errp);
137
if (newfd < 0) {
138
- /* error already reported by net_socket_mcast_create() */
139
goto err;
140
}
141
/* clone newfd to fd, close newfd */
142
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
143
144
static NetSocketState *net_socket_fd_init(NetClientState *peer,
145
const char *model, const char *name,
146
- int fd, int is_connected, const char *mc)
147
+ int fd, int is_connected,
148
+ const char *mc, Error **errp)
149
{
150
int so_type = -1, optlen=sizeof(so_type);
151
152
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
153
(socklen_t *)&optlen)< 0) {
154
- fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n",
155
- fd);
156
+ error_setg(errp, "can't get socket option SO_TYPE");
157
closesocket(fd);
158
return NULL;
159
}
160
switch(so_type) {
161
case SOCK_DGRAM:
162
- return net_socket_fd_init_dgram(peer, model, name, fd, is_connected, mc);
163
+ return net_socket_fd_init_dgram(peer, model, name, fd, is_connected,
164
+ mc, errp);
165
case SOCK_STREAM:
166
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
167
default:
168
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
169
NetSocketState *s;
170
int fd, connected, ret;
171
struct sockaddr_in saddr;
172
+ Error *err = NULL;
173
174
if (parse_host_port(&saddr, host_str) < 0)
175
return -1;
176
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
177
break;
178
}
179
}
180
- s = net_socket_fd_init(peer, model, name, fd, connected, NULL);
181
- if (!s)
182
+ s = net_socket_fd_init(peer, model, name, fd, connected, NULL, &err);
183
+ if (!s) {
184
+ error_report_err(err);
185
return -1;
186
+ }
93
+ }
187
+
94
+
188
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
95
+ fprintf(stderr, "%s not present in tulip_pci\n", interface);
189
"socket: connect to %s:%d",
96
+ g_assert_not_reached();
190
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
97
+}
191
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
98
+
192
int fd;
99
+static void *tulip_pci_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
193
struct sockaddr_in saddr;
100
+{
194
struct in_addr localaddr, *param_localaddr;
101
+ QTulip_pci *tulip_pci = g_new0(QTulip_pci, 1);
195
+ Error *err = NULL;
102
+ QPCIBus *bus = pci_bus;
196
103
+
197
if (parse_host_port(&saddr, host_str) < 0)
104
+ qpci_device_init(&tulip_pci->dev, bus, addr);
198
return -1;
105
+ tulip_pci->obj.get_driver = tulip_pci_get_driver;
199
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
106
+
200
param_localaddr = NULL;
107
+ return &tulip_pci->obj;
201
}
108
+}
202
109
+
203
- fd = net_socket_mcast_create(&saddr, param_localaddr);
110
+static void tulip_large_tx(void *obj, void *data, QGuestAllocator *alloc)
204
- if (fd < 0)
111
+{
205
+ fd = net_socket_mcast_create(&saddr, param_localaddr, &err);
112
+ QTulip_pci *tulip_pci = obj;
206
+ if (fd < 0) {
113
+ QPCIDevice *dev = &tulip_pci->dev;
207
+ error_report_err(err);
114
+ QPCIBar bar;
208
return -1;
115
+ struct tulip_descriptor context;
209
+ }
116
+ char guest_data[4096];
210
117
+ uint64_t context_pa;
211
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL);
118
+ uint64_t guest_pa;
212
- if (!s)
119
+
213
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
120
+ qpci_device_enable(dev);
214
+ if (!s) {
121
+ bar = qpci_iomap(dev, 0, NULL);
215
+ error_report_err(err);
122
+ context_pa = guest_alloc(alloc, sizeof(context));
216
return -1;
123
+ guest_pa = guest_alloc(alloc, 4096);
217
+ }
124
+ memset(guest_data, 'A', sizeof(guest_data));
218
125
+ context.status = TDES0_OWN;
219
s->dgram_dst = saddr;
126
+ context.control = TDES1_BUF2_SIZE_MASK << TDES1_BUF2_SIZE_SHIFT |
220
127
+ TDES1_BUF1_SIZE_MASK << TDES1_BUF1_SIZE_SHIFT;
221
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
128
+ context.buf_addr2 = guest_pa;
222
NetSocketState *s;
129
+ context.buf_addr1 = guest_pa;
223
int fd, ret;
130
+
224
struct sockaddr_in laddr, raddr;
131
+ qtest_memwrite(dev->bus->qts, context_pa, &context, sizeof(context));
225
+ Error *err = NULL;
132
+ qtest_memwrite(dev->bus->qts, guest_pa, guest_data, sizeof(guest_data));
226
133
+ qpci_io_writel(dev, bar, 0x20, context_pa);
227
if (parse_host_port(&laddr, lhost) < 0) {
134
+ qpci_io_writel(dev, bar, 0x30, CSR6_ST);
228
return -1;
135
+ guest_free(alloc, context_pa);
229
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
136
+ guest_free(alloc, guest_pa);
230
}
137
+}
231
qemu_set_nonblock(fd);
138
+
232
139
+static void tulip_register_nodes(void)
233
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL);
140
+{
234
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
141
+ QOSGraphEdgeOptions opts = {
235
if (!s) {
142
+ .extra_device_opts = "addr=04.0",
236
+ error_report_err(err);
143
+ };
237
return -1;
144
+ add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
238
}
145
+
239
146
+ qos_node_create_driver("tulip", tulip_pci_create);
240
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
147
+ qos_node_consumes("tulip", "pci-bus", &opts);
241
return -1;
148
+ qos_node_produces("tulip", "pci-device");
242
}
149
+
243
qemu_set_nonblock(fd);
150
+ qos_add_test("tulip_large_tx", "tulip", tulip_large_tx, NULL);
244
- if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast)) {
151
+}
245
+ if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast,
152
+
246
+ errp)) {
153
+libqos_init(tulip_register_nodes);
247
return -1;
248
}
249
return 0;
250
--
154
--
251
2.7.4
155
2.5.0
252
156
253
157
diff view generated by jsdifflib
Deleted patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
1
3
The packet_enqueue() use g_queue_push_tail() to
4
enqueue net packet, so it is more efficent way use
5
g_queue_pop_head() to get packet for compare.
6
That will improve the success rate of comparison.
7
In my test the performance of ftp put 1000M file
8
will increase 10%
9
10
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
13
net/colo-compare.c | 4 ++--
14
1 file changed, 2 insertions(+), 2 deletions(-)
15
16
diff --git a/net/colo-compare.c b/net/colo-compare.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/net/colo-compare.c
19
+++ b/net/colo-compare.c
20
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
21
22
while (!g_queue_is_empty(&conn->primary_list) &&
23
!g_queue_is_empty(&conn->secondary_list)) {
24
- pkt = g_queue_pop_tail(&conn->primary_list);
25
+ pkt = g_queue_pop_head(&conn->primary_list);
26
switch (conn->ip_proto) {
27
case IPPROTO_TCP:
28
result = g_queue_find_custom(&conn->secondary_list,
29
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
30
* until next comparison.
31
*/
32
trace_colo_compare_main("packet different");
33
- g_queue_push_tail(&conn->primary_list, pkt);
34
+ g_queue_push_head(&conn->primary_list, pkt);
35
/* TODO: colo_notify_checkpoint();*/
36
break;
37
}
38
--
39
2.7.4
40
41
diff view generated by jsdifflib