Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 576

kvm-83-164.el5_5.9.src.rpm

From ab73cc3575d6c3b0ebddd0df4a442368567a6d86 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Tue, 24 Nov 2009 19:43:07 -0200
Subject: [PATCH 08/11] slirp: Reassign same address to same DHCP client

RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <20091117163643.GB31521@blackpad.lan.raisama.net>
Patchwork-id: 3727
O-Subject: [RHEL-5.5 KVM PATCH] slirp: Reassign same address to same DHCP client
Bugzilla: 531631
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: john cooper <john.cooper@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=531631

Backport of upstream commit:

commit 0928a95ffe91862938cee997c9e30602fa7884ab
Author: Jan Kiszka <jan.kiszka@web.de>
Date:   Thu May 21 22:43:39 2009 +0200

    slirp: Reassign same address to same DHCP client

    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>

This bug not only makes the dhcp client table fill quickly, but it makes the
server send different addresses to the client, depending on the request type
(DHCPDISCOVER gets a new addres, and DHCPREQUEST gets an old address),
confusing some clients (e.g. Windows XP).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/slirp/bootp.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/slirp/bootp.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/qemu/slirp/bootp.c b/qemu/slirp/bootp.c
index bf704ab..6e0ef8b 100644
--- a/qemu/slirp/bootp.c
+++ b/qemu/slirp/bootp.c
@@ -49,13 +49,15 @@ if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## args); fflush(dfd); }
 #define dprintf(fmt, args...)
 #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;
@@ -156,7 +158,7 @@ static void bootp_reply(struct bootp_t *bp)
 
     if (dhcp_msg_type == DHCPDISCOVER) {
     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;
-- 
1.6.3.rc4.29.g8146