All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client
Date: Thu, 21 May 2009 22:43:39 +0200	[thread overview]
Message-ID: <4A15BCFB.2080503@web.de> (raw)

[-- 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 --]

             reply	other threads:[~2009-05-21 20:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-21 20:43 Jan Kiszka [this message]
2009-05-24 11:10 ` [Qemu-devel] [PATCH] slirp: Reassign same address to same DHCP client Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A15BCFB.2080503@web.de \
    --to=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.