From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M795l-0002Fs-GE for qemu-devel@nongnu.org; Thu, 21 May 2009 10:17:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M795g-0002DX-Nw for qemu-devel@nongnu.org; Thu, 21 May 2009 10:17:53 -0400 Received: from [199.232.76.173] (port=48325 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M795g-0002DR-HU for qemu-devel@nongnu.org; Thu, 21 May 2009 10:17:48 -0400 Received: from mx2.redhat.com ([66.187.237.31]:34693) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M795g-0006a0-1q for qemu-devel@nongnu.org; Thu, 21 May 2009 10:17:48 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4LEHk0l032046 for ; Thu, 21 May 2009 10:17:46 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4LEHkas014261 for ; Thu, 21 May 2009 10:17:46 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4LEHjx2020855 for ; Thu, 21 May 2009 10:17:45 -0400 From: Gleb Natapov Date: Thu, 21 May 2009 17:17:44 +0300 Message-Id: <1242915464-451-2-git-send-email-gleb@redhat.com> Subject: [Qemu-devel] [PATCH] Don't send all gratuitous packets at once. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Use timer to separate them in time. Signed-off-by: Gleb Natapov --- savevm.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/savevm.c b/savevm.c index 89af93b..774305d 100644 --- a/savevm.c +++ b/savevm.c @@ -116,23 +116,37 @@ static int announce_self_create(uint8_t *buf, return 64; /* len */ } -void qemu_announce_self(void) +static void qemu_announce_self_once(void *opaque) { - int i, j, len; + int i, len; VLANState *vlan; VLANClientState *vc; uint8_t buf[256]; + static int count = SELF_ANNOUNCE_ROUNDS; + QEMUTimer *timer = *(QEMUTimer **)opaque; for (i = 0; i < MAX_NICS; i++) { if (!nd_table[i].used) continue; len = announce_self_create(buf, nd_table[i].macaddr); vlan = nd_table[i].vlan; - for(vc = vlan->first_client; vc != NULL; vc = vc->next) { - for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++) - vc->fd_read(vc->opaque, buf, len); + for(vc = vlan->first_client; vc != NULL; vc = vc->next) { + vc->fd_read(vc->opaque, buf, len); } } + if (count--) { + qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100); + } else { + qemu_del_timer(timer); + qemu_free_timer(timer); + } +} + +void qemu_announce_self(void) +{ + static QEMUTimer *timer; + timer = qemu_new_timer(rt_clock, qemu_announce_self_once, &timer); + qemu_announce_self_once(&timer); } /***********************************************************/ -- 1.6.2.1