* [Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client
@ 2009-05-21 20:43 Jan Kiszka
2009-05-24 11:10 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2009-05-21 20:43 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]
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 <jan.kiszka@siemens.com>
---
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
-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;
for(i = 0; i < NB_ADDR; i++) {
- if (!bootp_clients[i].allocated)
+ bc = &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 = get_new_addr(&daddr.sin_addr);
+ bc = get_new_addr(&daddr.sin_addr, client_ethaddr);
if (!bc) {
dprintf("no address left\n");
return;
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-24 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-21 20:43 [Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client Jan Kiszka
2009-05-24 11:10 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).