From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7F7K-0001aF-O6 for qemu-devel@nongnu.org; Thu, 21 May 2009 16:43:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7F7F-0001SU-Ip for qemu-devel@nongnu.org; Thu, 21 May 2009 16:43:54 -0400 Received: from [199.232.76.173] (port=32984 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7F7F-0001SF-Df for qemu-devel@nongnu.org; Thu, 21 May 2009 16:43:49 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:48740) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M7F7E-000152-QT for qemu-devel@nongnu.org; Thu, 21 May 2009 16:43:49 -0400 Received: from smtp08.web.de (fmsmtp08.dlan.cinetic.de [172.20.5.216]) by fmmailgate01.web.de (Postfix) with ESMTP id D211D1038FF8D for ; Thu, 21 May 2009 22:43:47 +0200 (CEST) Received: from [88.66.121.94] (helo=[192.168.1.3]) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1M7F7D-0001Vu-00 for qemu-devel@nongnu.org; Thu, 21 May 2009 22:43:47 +0200 Message-ID: <4A15BCFB.2080503@web.de> Date: Thu, 21 May 2009 22:43:39 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig526517CCF552E4AAEE8020D9" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig526517CCF552E4AAEE8020D9 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable In case a client restarts a DHCP recovery without releasing its old address, reassign the same address to prevent consuming free addresses and moving away from the standard client address. Signed-off-by: Jan Kiszka --- slirp/bootp.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/slirp/bootp.c b/slirp/bootp.c index ae71e46..4e0082d 100644 --- a/slirp/bootp.c +++ b/slirp/bootp.c @@ -49,13 +49,15 @@ if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## _= _VA_ARGS__); fflush(dfd); } #define dprintf(fmt, ...) #endif =20 -static BOOTPClient *get_new_addr(struct in_addr *paddr) +static BOOTPClient *get_new_addr(struct in_addr *paddr, + const uint8_t *macaddr) { BOOTPClient *bc; int i; =20 for(i =3D 0; i < NB_ADDR; i++) { - if (!bootp_clients[i].allocated) + bc =3D &bootp_clients[i]; + if (!bc->allocated || !memcmp(macaddr, bc->macaddr, 6)) goto found; } return NULL; @@ -192,7 +194,7 @@ static void bootp_reply(const struct bootp_t *bp) } if (!bc) { new_addr: - bc =3D get_new_addr(&daddr.sin_addr); + bc =3D get_new_addr(&daddr.sin_addr, client_ethaddr); if (!bc) { dprintf("no address left\n"); return; --------------enig526517CCF552E4AAEE8020D9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkoVvP8ACgkQniDOoMHTA+nn6QCfUpVj25dghpv1Lepri341yAlA qE0An2kfIcj9xONUvriCxOFpZV1wkZBG =kGlB -----END PGP SIGNATURE----- --------------enig526517CCF552E4AAEE8020D9--