mirror of https://gitee.com/openkylin/qemu.git
net: return status from qemu_deliver_packet()
Will allow qemu_send_packet() handle queue full condition. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
This commit is contained in:
parent
4f1c942b7f
commit
3e021d40b7
20
net.c
20
net.c
|
@ -409,16 +409,30 @@ int qemu_can_send_packet(VLANClientState *sender)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size)
|
qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
VLANClientState *vc;
|
VLANClientState *vc;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {
|
for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {
|
||||||
if (vc != sender && !vc->link_down) {
|
ssize_t len;
|
||||||
vc->receive(vc, buf, size);
|
|
||||||
|
if (vc == sender) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vc->link_down) {
|
||||||
|
ret = size;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = vc->receive(vc, buf, size);
|
||||||
|
|
||||||
|
ret = (ret >= 0) ? ret : len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size)
|
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size)
|
||||||
|
|
Loading…
Reference in New Issue