1 | The following changes since commit 5dae13cd71f0755a1395b5a4cde635b8a6ee3f58: | 1 | The following changes since commit 23895cbd82be95428e90168b12e925d0d3ca2f06: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/rth/tags/pull-or-20170214' into staging (2017-02-14 09:55:48 +0000) | 3 | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20201123.0' into staging (2020-11-23 18:51:13 +0000) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the git repository at: |
6 | 6 | ||
7 | https://github.com/jasowang/qemu.git tags/net-pull-request | 7 | https://github.com/jasowang/qemu.git tags/net-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 4154c7e03fa55b4cf52509a83d50d6c09d743b77: | 9 | for you to fetch changes up to 9925990d01a92564af55f6f69d0f5f59b47609b1: |
10 | 10 | ||
11 | net: e1000e: fix an infinite loop issue (2017-02-15 11:18:57 +0800) | 11 | net: Use correct default-path macro for downscript (2020-11-24 10:40:17 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | 14 | ||
15 | ---------------------------------------------------------------- | 15 | ---------------------------------------------------------------- |
16 | Li Qiang (1): | 16 | Keqian Zhu (1): |
17 | net: e1000e: fix an infinite loop issue | 17 | net: Use correct default-path macro for downscript |
18 | 18 | ||
19 | Paolo Bonzini (1): | 19 | Paolo Bonzini (1): |
20 | net: e1000e: fix dead code in e1000e_write_packet_to_guest | 20 | net: do not exit on "netdev_add help" monitor command |
21 | 21 | ||
22 | Prasad J Pandit (1): | 22 | Prasad J Pandit (1): |
23 | net: imx: limit buffer descriptor count | 23 | hw/net/e1000e: advance desc_offset in case of null descriptor |
24 | 24 | ||
25 | Thomas Huth (1): | 25 | Yuri Benditovich (1): |
26 | net: Mark 'vlan' parameter as deprecated | 26 | net: purge queued rx packets on queue deletion |
27 | 27 | ||
28 | Zhang Chen (1): | 28 | yuanjungong (1): |
29 | colo-compare: sort TCP packet queue by sequence number | 29 | tap: fix a memory leak |
30 | 30 | ||
31 | hw/net/e1000e_core.c | 9 +++++++-- | 31 | hw/net/e1000e_core.c | 8 +++--- |
32 | hw/net/imx_fec.c | 10 ++++++---- | 32 | include/net/net.h | 1 + |
33 | net/colo-compare.c | 19 +++++++++++++++++++ | 33 | monitor/hmp-cmds.c | 6 ++++ |
34 | net/net.c | 6 ++++++ | 34 | net/net.c | 80 +++++++++++++++++++++++++++------------------------- |
35 | 4 files changed, 38 insertions(+), 6 deletions(-) | 35 | net/tap.c | 5 +++- |
36 | 5 files changed, 57 insertions(+), 43 deletions(-) | ||
36 | 37 | ||
37 | 38 | diff view generated by jsdifflib |
1 | From: Prasad J Pandit <pjp@fedoraproject.org> | 1 | From: Prasad J Pandit <pjp@fedoraproject.org> |
---|---|---|---|
2 | 2 | ||
3 | i.MX Fast Ethernet Controller uses buffer descriptors to manage | 3 | While receiving packets via e1000e_write_packet_to_guest() routine, |
4 | data flow to/fro receive & transmit queues. While transmitting | 4 | 'desc_offset' is advanced only when RX descriptor is processed. And |
5 | packets, it could continue to read buffer descriptors if a buffer | 5 | RX descriptor is not processed if it has NULL buffer address. |
6 | descriptor has length of zero and has crafted values in bd.flags. | 6 | This may lead to an infinite loop condition. Increament 'desc_offset' |
7 | Set an upper limit to number of buffer descriptors. | 7 | to process next descriptor in the ring to avoid infinite loop. |
8 | 8 | ||
9 | Reported-by: Li Qiang <liqiang6-s@360.cn> | 9 | Reported-by: Cheol-woo Myung <330cjfdn@gmail.com> |
10 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> | 10 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> |
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 11 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 12 | --- |
13 | hw/net/imx_fec.c | 10 ++++++---- | 13 | hw/net/e1000e_core.c | 8 ++++---- |
14 | 1 file changed, 6 insertions(+), 4 deletions(-) | 14 | 1 file changed, 4 insertions(+), 4 deletions(-) |
15 | 15 | ||
16 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 16 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/net/imx_fec.c | 18 | --- a/hw/net/e1000e_core.c |
19 | +++ b/hw/net/imx_fec.c | 19 | +++ b/hw/net/e1000e_core.c |
20 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, |
21 | } \ | 21 | (const char *) &fcs_pad, e1000x_fcs_len(core->mac)); |
22 | } while (0) | 22 | } |
23 | 23 | } | |
24 | +#define IMX_MAX_DESC 1024 | 24 | - desc_offset += desc_size; |
25 | + | 25 | - if (desc_offset >= total_size) { |
26 | static const char *imx_default_reg_name(IMXFECState *s, uint32_t index) | 26 | - is_last = true; |
27 | { | 27 | - } |
28 | static char tmp[20]; | 28 | } else { /* as per intel docs; skip descriptors with null buf addr */ |
29 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s) | 29 | trace_e1000e_rx_null_descriptor(); |
30 | 30 | } | |
31 | static void imx_fec_do_tx(IMXFECState *s) | 31 | + desc_offset += desc_size; |
32 | { | 32 | + if (desc_offset >= total_size) { |
33 | - int frame_size = 0; | 33 | + is_last = true; |
34 | + int frame_size = 0, descnt = 0; | 34 | + } |
35 | uint8_t frame[ENET_MAX_FRAME_SIZE]; | 35 | |
36 | uint8_t *ptr = frame; | 36 | e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL, |
37 | uint32_t addr = s->tx_descriptor; | 37 | rss_info, do_ps ? ps_hdr_len : 0, &bastate.written); |
38 | |||
39 | - while (1) { | ||
40 | + while (descnt++ < IMX_MAX_DESC) { | ||
41 | IMXFECBufDesc bd; | ||
42 | int len; | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s) | ||
45 | |||
46 | static void imx_enet_do_tx(IMXFECState *s) | ||
47 | { | ||
48 | - int frame_size = 0; | ||
49 | + int frame_size = 0, descnt = 0; | ||
50 | uint8_t frame[ENET_MAX_FRAME_SIZE]; | ||
51 | uint8_t *ptr = frame; | ||
52 | uint32_t addr = s->tx_descriptor; | ||
53 | |||
54 | - while (1) { | ||
55 | + while (descnt++ < IMX_MAX_DESC) { | ||
56 | IMXENETBufDesc bd; | ||
57 | int len; | ||
58 | |||
59 | -- | 38 | -- |
60 | 2.7.4 | 39 | 2.7.4 |
61 | 40 | ||
62 | 41 | diff view generated by jsdifflib |
1 | From: Paolo Bonzini <pbonzini@redhat.com> | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Because is_first is declared inside a loop, it is always true. The store | 3 | "netdev_add help" is causing QEMU to exit because the code that |
4 | is dead, and so is the "else" branch of "if (is_first)". is_last is | 4 | invokes show_netdevs is shared between CLI and HMP processing. |
5 | okay though. | 5 | Move the check to the callers so that exit(0) remains only |
6 | in the CLI flow. | ||
6 | 7 | ||
7 | Reported by Coverity. | 8 | "netdev_add help" is not fixed by this patch; that is left for |
9 | later work. | ||
8 | 10 | ||
9 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | 11 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
10 | Reviewed-by: Dmitry Fleytman <dmitry@daynix.com> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 12 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 13 | --- |
13 | hw/net/e1000e_core.c | 2 +- | 14 | include/net/net.h | 1 + |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 15 | monitor/hmp-cmds.c | 6 +++++ |
16 | net/net.c | 68 +++++++++++++++++++++++++++--------------------------- | ||
17 | 3 files changed, 41 insertions(+), 34 deletions(-) | ||
15 | 18 | ||
16 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | 19 | diff --git a/include/net/net.h b/include/net/net.h |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/net/e1000e_core.c | 21 | --- a/include/net/net.h |
19 | +++ b/hw/net/e1000e_core.c | 22 | +++ b/include/net/net.h |
20 | @@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, | 23 | @@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[]; |
21 | const E1000E_RingInfo *rxi; | 24 | |
22 | size_t ps_hdr_len = 0; | 25 | /* from net.c */ |
23 | bool do_ps = e1000e_do_ps(core, pkt, &ps_hdr_len); | 26 | int net_client_parse(QemuOptsList *opts_list, const char *str); |
24 | + bool is_first = true; | 27 | +void show_netdevs(void); |
25 | 28 | int net_init_clients(Error **errp); | |
26 | rxi = rxr->i; | 29 | void net_check_clients(void); |
27 | 30 | void net_cleanup(void); | |
28 | @@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, | 31 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c |
29 | hwaddr ba[MAX_PS_BUFFERS]; | 32 | index XXXXXXX..XXXXXXX 100644 |
30 | e1000e_ba_state bastate = { { 0 } }; | 33 | --- a/monitor/hmp-cmds.c |
31 | bool is_last = false; | 34 | +++ b/monitor/hmp-cmds.c |
32 | - bool is_first = true; | 35 | @@ -XXX,XX +XXX,XX @@ |
33 | 36 | #include "qemu/option.h" | |
34 | desc_size = total_size - desc_offset; | 37 | #include "qemu/timer.h" |
38 | #include "qemu/sockets.h" | ||
39 | +#include "qemu/help_option.h" | ||
40 | #include "monitor/monitor-internal.h" | ||
41 | #include "qapi/error.h" | ||
42 | #include "qapi/clone-visitor.h" | ||
43 | @@ -XXX,XX +XXX,XX @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict) | ||
44 | { | ||
45 | Error *err = NULL; | ||
46 | QemuOpts *opts; | ||
47 | + const char *type = qdict_get_try_str(qdict, "type"); | ||
48 | |||
49 | + if (type && is_help_option(type)) { | ||
50 | + show_netdevs(); | ||
51 | + return; | ||
52 | + } | ||
53 | opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err); | ||
54 | if (err) { | ||
55 | goto out; | ||
56 | diff --git a/net/net.c b/net/net.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/net/net.c | ||
59 | +++ b/net/net.c | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | #include "qemu/config-file.h" | ||
62 | #include "qemu/ctype.h" | ||
63 | #include "qemu/iov.h" | ||
64 | +#include "qemu/qemu-print.h" | ||
65 | #include "qemu/main-loop.h" | ||
66 | #include "qemu/option.h" | ||
67 | #include "qapi/error.h" | ||
68 | @@ -XXX,XX +XXX,XX @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp) | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | -static void show_netdevs(void) | ||
73 | +void show_netdevs(void) | ||
74 | { | ||
75 | int idx; | ||
76 | const char *available_netdevs[] = { | ||
77 | @@ -XXX,XX +XXX,XX @@ static void show_netdevs(void) | ||
78 | #endif | ||
79 | }; | ||
80 | |||
81 | - printf("Available netdev backend types:\n"); | ||
82 | + qemu_printf("Available netdev backend types:\n"); | ||
83 | for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) { | ||
84 | - puts(available_netdevs[idx]); | ||
85 | + qemu_printf("%s\n", available_netdevs[idx]); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) | ||
90 | int ret = -1; | ||
91 | Visitor *v = opts_visitor_new(opts); | ||
92 | |||
93 | - const char *type = qemu_opt_get(opts, "type"); | ||
94 | - | ||
95 | - if (is_netdev && type && is_help_option(type)) { | ||
96 | - show_netdevs(); | ||
97 | - exit(0); | ||
98 | - } else { | ||
99 | - /* Parse convenience option format ip6-net=fec0::0[/64] */ | ||
100 | - const char *ip6_net = qemu_opt_get(opts, "ipv6-net"); | ||
101 | + /* Parse convenience option format ip6-net=fec0::0[/64] */ | ||
102 | + const char *ip6_net = qemu_opt_get(opts, "ipv6-net"); | ||
103 | |||
104 | - if (ip6_net) { | ||
105 | - char *prefix_addr; | ||
106 | - unsigned long prefix_len = 64; /* Default 64bit prefix length. */ | ||
107 | + if (ip6_net) { | ||
108 | + char *prefix_addr; | ||
109 | + unsigned long prefix_len = 64; /* Default 64bit prefix length. */ | ||
110 | |||
111 | - substrings = g_strsplit(ip6_net, "/", 2); | ||
112 | - if (!substrings || !substrings[0]) { | ||
113 | - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net", | ||
114 | - "a valid IPv6 prefix"); | ||
115 | - goto out; | ||
116 | - } | ||
117 | + substrings = g_strsplit(ip6_net, "/", 2); | ||
118 | + if (!substrings || !substrings[0]) { | ||
119 | + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net", | ||
120 | + "a valid IPv6 prefix"); | ||
121 | + goto out; | ||
122 | + } | ||
123 | |||
124 | - prefix_addr = substrings[0]; | ||
125 | + prefix_addr = substrings[0]; | ||
126 | |||
127 | - /* Handle user-specified prefix length. */ | ||
128 | - if (substrings[1] && | ||
129 | - qemu_strtoul(substrings[1], NULL, 10, &prefix_len)) | ||
130 | - { | ||
131 | - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, | ||
132 | - "ipv6-prefixlen", "a number"); | ||
133 | - goto out; | ||
134 | - } | ||
135 | - | ||
136 | - qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort); | ||
137 | - qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len, | ||
138 | - &error_abort); | ||
139 | - qemu_opt_unset(opts, "ipv6-net"); | ||
140 | + /* Handle user-specified prefix length. */ | ||
141 | + if (substrings[1] && | ||
142 | + qemu_strtoul(substrings[1], NULL, 10, &prefix_len)) | ||
143 | + { | ||
144 | + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, | ||
145 | + "ipv6-prefixlen", "a number"); | ||
146 | + goto out; | ||
147 | } | ||
148 | + | ||
149 | + qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort); | ||
150 | + qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len, | ||
151 | + &error_abort); | ||
152 | + qemu_opt_unset(opts, "ipv6-net"); | ||
153 | } | ||
154 | |||
155 | /* Create an ID for -net if the user did not specify one */ | ||
156 | @@ -XXX,XX +XXX,XX @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp) | ||
157 | |||
158 | static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp) | ||
159 | { | ||
160 | + const char *type = qemu_opt_get(opts, "type"); | ||
161 | + | ||
162 | + if (type && is_help_option(type)) { | ||
163 | + show_netdevs(); | ||
164 | + exit(0); | ||
165 | + } | ||
166 | return net_client_init(opts, true, errp); | ||
167 | } | ||
35 | 168 | ||
36 | -- | 169 | -- |
37 | 2.7.4 | 170 | 2.7.4 |
38 | 171 | ||
39 | 172 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Yuri Benditovich <yuri.benditovich@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | The 'vlan' parameter is a continuous source of confusion for the users, | 3 | https://bugzilla.redhat.com/show_bug.cgi?id=1829272 |
4 | many people mix it up with the more common term VLAN (the link layer | 4 | When deleting queue pair, purge pending RX packets if any. |
5 | packet encapsulation), and even if they realize that the QEMU 'vlan' is | 5 | Example of problematic flow: |
6 | rather some kind of network hub emulation, there is still a high risk | 6 | 1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e |
7 | that they configure their QEMU networking in a wrong way with this | 7 | 2. Run ping flood to the VM NIC ( 1 ms interval) |
8 | parameter (e.g. by hooking NICs together, so they get a 'loopback' | 8 | 3. Hot unplug the NIC device (device_del) |
9 | between one and the other NIC). | 9 | During unplug process one or more packets come, the NIC |
10 | Thus at one point in time, we should finally get rid of the 'vlan' | 10 | can't receive, tap disables read_poll |
11 | feature in QEMU. Let's do a first step in this direction by declaring | 11 | 4. Hot plug the device (device_add) with the same netdev |
12 | the 'vlan' parameter as deprecated and informing the users to use the | 12 | The tap stays with read_poll disabled and does not receive |
13 | 'netdev' parameter instead. | 13 | any packets anymore (tap_send never triggered) |
14 | 14 | ||
15 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 15 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> |
16 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 16 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
17 | --- | 17 | --- |
18 | net/net.c | 6 ++++++ | 18 | net/net.c | 12 ++++++++---- |
19 | 1 file changed, 6 insertions(+) | 19 | 1 file changed, 8 insertions(+), 4 deletions(-) |
20 | 20 | ||
21 | diff --git a/net/net.c b/net/net.c | 21 | diff --git a/net/net.c b/net/net.c |
22 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/net/net.c | 23 | --- a/net/net.c |
24 | +++ b/net/net.c | 24 | +++ b/net/net.c |
25 | @@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) | 25 | @@ -XXX,XX +XXX,XX @@ void qemu_del_nic(NICState *nic) |
26 | const Netdev *netdev; | 26 | |
27 | const char *name; | 27 | qemu_macaddr_set_free(&nic->conf->macaddr); |
28 | NetClientState *peer = NULL; | 28 | |
29 | + static bool vlan_warned; | 29 | - /* If this is a peer NIC and peer has already been deleted, free it now. */ |
30 | 30 | - if (nic->peer_deleted) { | |
31 | if (is_netdev) { | 31 | - for (i = 0; i < queues; i++) { |
32 | netdev = object; | 32 | - qemu_free_net_client(qemu_get_subqueue(nic, i)->peer); |
33 | @@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) | 33 | + for (i = 0; i < queues; i++) { |
34 | !opts->u.nic.data->has_netdev) { | 34 | + NetClientState *nc = qemu_get_subqueue(nic, i); |
35 | peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); | 35 | + /* If this is a peer NIC and peer has already been deleted, free it now. */ |
36 | + if (nic->peer_deleted) { | ||
37 | + qemu_free_net_client(nc->peer); | ||
38 | + } else if (nc->peer) { | ||
39 | + /* if there are RX packets pending, complete them */ | ||
40 | + qemu_purge_queued_packets(nc->peer); | ||
36 | } | 41 | } |
37 | + | ||
38 | + if (net->has_vlan && !vlan_warned) { | ||
39 | + error_report("'vlan' is deprecated. Please use 'netdev' instead."); | ||
40 | + vlan_warned = true; | ||
41 | + } | ||
42 | } | 42 | } |
43 | 43 | ||
44 | if (net_client_init_fun[netdev->type](netdev, name, peer, errp) < 0) { | ||
45 | -- | 44 | -- |
46 | 2.7.4 | 45 | 2.7.4 |
47 | 46 | ||
48 | 47 | diff view generated by jsdifflib |
1 | From: Li Qiang <liq3ea@gmail.com> | 1 | From: yuanjungong <ruc_gongyuanjun@163.com> |
---|---|---|---|
2 | 2 | ||
3 | This issue is like the issue in e1000 network card addressed in | 3 | Close fd before returning. |
4 | this commit: | ||
5 | e1000: eliminate infinite loops on out-of-bounds transfer start. | ||
6 | 4 | ||
7 | Signed-off-by: Li Qiang <liqiang6-s@360.cn> | 5 | Buglink: https://bugs.launchpad.net/qemu/+bug/1904486 |
8 | Reviewed-by: Dmitry Fleytman <dmitry@daynix.com> | 6 | |
7 | Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 9 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
10 | --- | 10 | --- |
11 | hw/net/e1000e_core.c | 7 ++++++- | 11 | net/tap.c | 2 ++ |
12 | 1 file changed, 6 insertions(+), 1 deletion(-) | 12 | 1 file changed, 2 insertions(+) |
13 | 13 | ||
14 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | 14 | diff --git a/net/tap.c b/net/tap.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/net/e1000e_core.c | 16 | --- a/net/tap.c |
17 | +++ b/hw/net/e1000e_core.c | 17 | +++ b/net/tap.c |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct E1000E_RingInfo_st { | 18 | @@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name, |
19 | static inline bool | 19 | if (ret < 0) { |
20 | e1000e_ring_empty(E1000ECore *core, const E1000E_RingInfo *r) | 20 | error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d", |
21 | { | 21 | name, fd); |
22 | - return core->mac[r->dh] == core->mac[r->dt]; | 22 | + close(fd); |
23 | + return core->mac[r->dh] == core->mac[r->dt] || | 23 | return -1; |
24 | + core->mac[r->dt] >= core->mac[r->dlen] / E1000_RING_DESC_LEN; | ||
25 | } | ||
26 | |||
27 | static inline uint64_t | ||
28 | @@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, | ||
29 | desc_size = core->rx_desc_buf_size; | ||
30 | } | 24 | } |
31 | 25 | ||
32 | + if (e1000e_ring_empty(core, rxi)) { | 26 | @@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name, |
33 | + return; | 27 | vhostfdname, vnet_hdr, fd, &err); |
34 | + } | 28 | if (err) { |
35 | + | 29 | error_propagate(errp, err); |
36 | base = e1000e_ring_head_descr(core, rxi); | 30 | + close(fd); |
37 | 31 | return -1; | |
38 | pci_dma_read(d, base, &desc, core->rx_desc_len); | 32 | } |
33 | } else if (tap->has_fds) { | ||
39 | -- | 34 | -- |
40 | 2.7.4 | 35 | 2.7.4 |
41 | 36 | ||
42 | 37 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | From: Keqian Zhu <zhukeqian1@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Improve efficiency of TCP packet comparison. | 3 | Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts) |
4 | 4 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> | |
5 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
6 | Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 5 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
8 | --- | 6 | --- |
9 | net/colo-compare.c | 19 +++++++++++++++++++ | 7 | net/tap.c | 3 ++- |
10 | 1 file changed, 19 insertions(+) | 8 | 1 file changed, 2 insertions(+), 1 deletion(-) |
11 | 9 | ||
12 | diff --git a/net/colo-compare.c b/net/colo-compare.c | 10 | diff --git a/net/tap.c b/net/tap.c |
13 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/net/colo-compare.c | 12 | --- a/net/tap.c |
15 | +++ b/net/colo-compare.c | 13 | +++ b/net/tap.c |
16 | @@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CharBackend *out, | 14 | @@ -XXX,XX +XXX,XX @@ free_fail: |
17 | const uint8_t *buf, | 15 | script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT); |
18 | uint32_t size); | 16 | } |
19 | 17 | if (!downscript) { | |
20 | +static gint seq_sorter(Packet *a, Packet *b, gpointer data) | 18 | - downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT); |
21 | +{ | 19 | + downscript = default_downscript = |
22 | + struct tcphdr *atcp, *btcp; | 20 | + get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT); |
23 | + | 21 | } |
24 | + atcp = (struct tcphdr *)(a->transport_header); | 22 | |
25 | + btcp = (struct tcphdr *)(b->transport_header); | 23 | if (tap->has_ifname) { |
26 | + return ntohl(atcp->th_seq) - ntohl(btcp->th_seq); | ||
27 | +} | ||
28 | + | ||
29 | /* | ||
30 | * Return 0 on success, if return -1 means the pkt | ||
31 | * is unsupported(arp and ipv6) and will be sent later | ||
32 | @@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode) | ||
33 | if (g_queue_get_length(&conn->primary_list) <= | ||
34 | MAX_QUEUE_SIZE) { | ||
35 | g_queue_push_tail(&conn->primary_list, pkt); | ||
36 | + if (conn->ip_proto == IPPROTO_TCP) { | ||
37 | + g_queue_sort(&conn->primary_list, | ||
38 | + (GCompareDataFunc)seq_sorter, | ||
39 | + NULL); | ||
40 | + } | ||
41 | } else { | ||
42 | error_report("colo compare primary queue size too big," | ||
43 | "drop packet"); | ||
44 | @@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode) | ||
45 | if (g_queue_get_length(&conn->secondary_list) <= | ||
46 | MAX_QUEUE_SIZE) { | ||
47 | g_queue_push_tail(&conn->secondary_list, pkt); | ||
48 | + if (conn->ip_proto == IPPROTO_TCP) { | ||
49 | + g_queue_sort(&conn->secondary_list, | ||
50 | + (GCompareDataFunc)seq_sorter, | ||
51 | + NULL); | ||
52 | + } | ||
53 | } else { | ||
54 | error_report("colo compare secondary queue size too big," | ||
55 | "drop packet"); | ||
56 | -- | 24 | -- |
57 | 2.7.4 | 25 | 2.7.4 |
58 | 26 | ||
59 | 27 | diff view generated by jsdifflib |