Commit ed8b330bccabb03c930ed1e4d72e341130f9b406
Committed by
Anthony Liguori
1 parent
976305b7
Don't send all gratuitous packets at once.
Use timer to separate them in time. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
19 additions
and
5 deletions
savevm.c
| ... | ... | @@ -116,23 +116,37 @@ static int announce_self_create(uint8_t *buf, |
| 116 | 116 | return 64; /* len */ |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | -void qemu_announce_self(void) | |
| 119 | +static void qemu_announce_self_once(void *opaque) | |
| 120 | 120 | { |
| 121 | - int i, j, len; | |
| 121 | + int i, len; | |
| 122 | 122 | VLANState *vlan; |
| 123 | 123 | VLANClientState *vc; |
| 124 | 124 | uint8_t buf[256]; |
| 125 | + static int count = SELF_ANNOUNCE_ROUNDS; | |
| 126 | + QEMUTimer *timer = *(QEMUTimer **)opaque; | |
| 125 | 127 | |
| 126 | 128 | for (i = 0; i < MAX_NICS; i++) { |
| 127 | 129 | if (!nd_table[i].used) |
| 128 | 130 | continue; |
| 129 | 131 | len = announce_self_create(buf, nd_table[i].macaddr); |
| 130 | 132 | vlan = nd_table[i].vlan; |
| 131 | - for(vc = vlan->first_client; vc != NULL; vc = vc->next) { | |
| 132 | - for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++) | |
| 133 | - vc->fd_read(vc->opaque, buf, len); | |
| 133 | + for(vc = vlan->first_client; vc != NULL; vc = vc->next) { | |
| 134 | + vc->fd_read(vc->opaque, buf, len); | |
| 134 | 135 | } |
| 135 | 136 | } |
| 137 | + if (count--) { | |
| 138 | + qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100); | |
| 139 | + } else { | |
| 140 | + qemu_del_timer(timer); | |
| 141 | + qemu_free_timer(timer); | |
| 142 | + } | |
| 143 | +} | |
| 144 | + | |
| 145 | +void qemu_announce_self(void) | |
| 146 | +{ | |
| 147 | + static QEMUTimer *timer; | |
| 148 | + timer = qemu_new_timer(rt_clock, qemu_announce_self_once, &timer); | |
| 149 | + qemu_announce_self_once(&timer); | |
| 136 | 150 | } |
| 137 | 151 | |
| 138 | 152 | /***********************************************************/ | ... | ... |