mirror of https://gitlab.com/qemu-project/qemu
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 commit is contained in:
parent
f8d926e9cd
commit
0928a95ffe
|
@ -49,13 +49,15 @@ if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## __VA_ARGS__); fflush(dfd); }
|
||||||
#define dprintf(fmt, ...)
|
#define dprintf(fmt, ...)
|
||||||
#endif
|
#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;
|
BOOTPClient *bc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < NB_ADDR; 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;
|
goto found;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -192,7 +194,7 @@ static void bootp_reply(const struct bootp_t *bp)
|
||||||
}
|
}
|
||||||
if (!bc) {
|
if (!bc) {
|
||||||
new_addr:
|
new_addr:
|
||||||
bc = get_new_addr(&daddr.sin_addr);
|
bc = get_new_addr(&daddr.sin_addr, client_ethaddr);
|
||||||
if (!bc) {
|
if (!bc) {
|
||||||
dprintf("no address left\n");
|
dprintf("no address left\n");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue