qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client
Date: Thu, 21 May 2009 22:43:39 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

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 <address@hidden>
---

 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: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]