From 47f2d7ef7d4dbeea19a55f9d73ef826f9d06650f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 16 Jun 2009 10:20:27 +0200 Subject: udhcpd: don't fail ARP check if returned MAC matches client's one Also, do not unicast replies to yiaddr. Signed-off-by: Denys Vlasenko --- networking/udhcp/leases.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'networking/udhcp/leases.c') diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c index e17fb9e3f..b2cdd1942 100644 --- a/networking/udhcp/leases.c +++ b/networking/udhcp/leases.c @@ -118,7 +118,7 @@ struct dhcpOfferedAddr* FAST_FUNC find_lease_by_yiaddr(uint32_t yiaddr) /* check is an IP is taken, if it is, add it to the lease table */ -static int nobody_responds_to_arp(uint32_t addr) +static int nobody_responds_to_arp(uint32_t addr, const uint8_t *safe_mac) { /* 16 zero bytes */ static const uint8_t blank_chaddr[16] = { 0 }; @@ -127,7 +127,9 @@ static int nobody_responds_to_arp(uint32_t addr) struct in_addr temp; int r; - r = arpping(addr, server_config.server, server_config.arp, server_config.interface); + r = arpping(addr, safe_mac, + server_config.server, server_config.arp, + server_config.interface); if (r) return r; @@ -140,7 +142,7 @@ static int nobody_responds_to_arp(uint32_t addr) /* Find a new usable (we think) address. */ -uint32_t FAST_FUNC find_free_or_expired_address(void) +uint32_t FAST_FUNC find_free_or_expired_address(const uint8_t *chaddr) { uint32_t addr; struct dhcpOfferedAddr *oldest_lease = NULL; @@ -163,7 +165,7 @@ uint32_t FAST_FUNC find_free_or_expired_address(void) lease = find_lease_by_yiaddr(net_addr); if (!lease) { - if (nobody_responds_to_arp(net_addr)) + if (nobody_responds_to_arp(net_addr, chaddr)) return net_addr; } else { if (!oldest_lease || lease->expires < oldest_lease->expires) @@ -172,7 +174,7 @@ uint32_t FAST_FUNC find_free_or_expired_address(void) } if (oldest_lease && lease_expired(oldest_lease) - && nobody_responds_to_arp(oldest_lease->yiaddr) + && nobody_responds_to_arp(oldest_lease->yiaddr, chaddr) ) { return oldest_lease->yiaddr; } -- cgit v1.2.3