diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-11-25 18:49:14 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-11-25 18:49:14 +0100 |
commit | 298fabaefcdb79037d0dd33ba331369586690202 (patch) | |
tree | bd008aae768dea75cbda32371502746dadd24048 | |
parent | 2bba9ad67a917de2624d427c8c107ce3e2d3d085 (diff) | |
download | busybox-w32-298fabaefcdb79037d0dd33ba331369586690202.tar.gz busybox-w32-298fabaefcdb79037d0dd33ba331369586690202.tar.bz2 busybox-w32-298fabaefcdb79037d0dd33ba331369586690202.zip |
udhcpd: if a lease from lease file coincides with a static one, ignore it
function old new delta
read_leases 269 328 +59
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/files.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 6840f3c25..1c8808c0f 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -189,12 +189,24 @@ void FAST_FUNC read_leases(const char *file) | |||
189 | goto ret; | 189 | goto ret; |
190 | 190 | ||
191 | while (full_read(fd, &lease, sizeof(lease)) == sizeof(lease)) { | 191 | while (full_read(fd, &lease, sizeof(lease)) == sizeof(lease)) { |
192 | //FIXME: what if it matches some static lease? | ||
193 | uint32_t y = ntohl(lease.lease_nip); | 192 | uint32_t y = ntohl(lease.lease_nip); |
194 | if (y >= server_config.start_ip && y <= server_config.end_ip) { | 193 | if (y >= server_config.start_ip && y <= server_config.end_ip) { |
195 | signed_leasetime_t expires = ntohl(lease.expires) - (signed_leasetime_t)time_passed; | 194 | signed_leasetime_t expires = ntohl(lease.expires) - (signed_leasetime_t)time_passed; |
195 | uint32_t static_nip; | ||
196 | |||
196 | if (expires <= 0) | 197 | if (expires <= 0) |
197 | continue; | 198 | continue; |
199 | |||
200 | /* Check if there is a different static lease for this IP or MAC */ | ||
201 | static_nip = get_static_nip_by_mac(server_config.static_leases, lease.lease_mac); | ||
202 | if (static_nip) { | ||
203 | /* NB: we do not add lease even if static_nip == lease.lease_nip. | ||
204 | */ | ||
205 | continue; | ||
206 | } | ||
207 | if (is_nip_reserved(server_config.static_leases, lease.lease_nip)) | ||
208 | continue; | ||
209 | |||
198 | /* NB: add_lease takes "relative time", IOW, | 210 | /* NB: add_lease takes "relative time", IOW, |
199 | * lease duration, not lease deadline. */ | 211 | * lease duration, not lease deadline. */ |
200 | if (add_lease(lease.lease_mac, lease.lease_nip, | 212 | if (add_lease(lease.lease_mac, lease.lease_nip, |