Commit 2e1e06411095ed122d44bf0e3f5e18e8a6304b16
1 parent
5b01e886
net: vlan clients with no fd_can_read() can always receive
If a vlan client has no fd_can_read(), that means it can always receive packets. The current code assumes it can *never* receive packets. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Showing
1 changed file
with
10 additions
and
6 deletions
net.c
@@ -389,15 +389,19 @@ VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque) | @@ -389,15 +389,19 @@ VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque) | ||
389 | return NULL; | 389 | return NULL; |
390 | } | 390 | } |
391 | 391 | ||
392 | -int qemu_can_send_packet(VLANClientState *vc1) | 392 | +int qemu_can_send_packet(VLANClientState *sender) |
393 | { | 393 | { |
394 | - VLANState *vlan = vc1->vlan; | 394 | + VLANState *vlan = sender->vlan; |
395 | VLANClientState *vc; | 395 | VLANClientState *vc; |
396 | 396 | ||
397 | - for(vc = vlan->first_client; vc != NULL; vc = vc->next) { | ||
398 | - if (vc != vc1) { | ||
399 | - if (vc->fd_can_read && vc->fd_can_read(vc->opaque)) | ||
400 | - return 1; | 397 | + for (vc = vlan->first_client; vc != NULL; vc = vc->next) { |
398 | + if (vc == sender) { | ||
399 | + continue; | ||
400 | + } | ||
401 | + | ||
402 | + /* no fd_can_read() handler, they can always receive */ | ||
403 | + if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) { | ||
404 | + return 1; | ||
401 | } | 405 | } |
402 | } | 406 | } |
403 | return 0; | 407 | return 0; |