Commit 3e021d40b7548b2eeec62a082411c0745a5c635f
1 parent
4f1c942b
net: return status from qemu_deliver_packet()
Will allow qemu_send_packet() handle queue full condition. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Showing
1 changed file
with
17 additions
and
3 deletions
net.c
@@ -409,16 +409,30 @@ int qemu_can_send_packet(VLANClientState *sender) | @@ -409,16 +409,30 @@ int qemu_can_send_packet(VLANClientState *sender) | ||
409 | return 0; | 409 | return 0; |
410 | } | 410 | } |
411 | 411 | ||
412 | -static void | 412 | +static int |
413 | qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size) | 413 | qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size) |
414 | { | 414 | { |
415 | VLANClientState *vc; | 415 | VLANClientState *vc; |
416 | + int ret = -1; | ||
416 | 417 | ||
417 | for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) { | 418 | for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) { |
418 | - if (vc != sender && !vc->link_down) { | ||
419 | - vc->receive(vc, buf, size); | 419 | + ssize_t len; |
420 | + | ||
421 | + if (vc == sender) { | ||
422 | + continue; | ||
423 | + } | ||
424 | + | ||
425 | + if (vc->link_down) { | ||
426 | + ret = size; | ||
427 | + continue; | ||
420 | } | 428 | } |
429 | + | ||
430 | + len = vc->receive(vc, buf, size); | ||
431 | + | ||
432 | + ret = (ret >= 0) ? ret : len; | ||
421 | } | 433 | } |
434 | + | ||
435 | + return ret; | ||
422 | } | 436 | } |
423 | 437 | ||
424 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size) | 438 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size) |