summaryrefslogtreecommitdiffhomepage
path: root/networking/udhcp/leases.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-16 10:20:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-16 10:20:27 +0200
commit47f2d7ef7d4dbeea19a55f9d73ef826f9d06650f (patch)
treea84db8f0215526b9728f2f2b94214100e853a98c /networking/udhcp/leases.c
parent1f363a086779152ab04067e81484b8bb69e4af72 (diff)
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 <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/leases.c')
-rw-r--r--networking/udhcp/leases.c12
1 files changed, 7 insertions, 5 deletions
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;
}