[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] udhcpd: discard saved leases if conflicting with static_lease config
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2014-11-25 17:50:50
Message-ID: CAK1hOcPtc=tkOrK5K8aRNbmDDfBZWtpMrqqtdHAC+=KQxd+6FQ () mail ! gmail ! com
[Download RAW message or body]

On Wed, Nov 5, 2014 at 9:33 PM, Michael McTernan
<Michael.McTernan.2001@cs.bris.ac.uk> wrote:
> Hi All,
> 
> There's a FIXME in udhcpd which describes a small corner case when saved leases are \
> read and honoured even if the IP or MAC of that lease overlaps a static_lease from \
> the config file.  I found that because of this, after updating config and \
> restarting udhcpd, a client which already had a lease can continue to renew that \
> lease instead of either getting the IP specified in a new 'static_lease' config \
> item, or being nak'd and assigned a new free IP. 
> Following is a small patch which removes the FIXME and adds a check to discard \
> saved lease records if they would conflict with a static_lease from the config \
> file. 
> In my configuration, this added 48 bytes to the stripped executable.  I tested it \
> by defining a /24 subnet and adding static_lease records for all but 1 on the \
> available IP addresses, and then moving that 1 available IP around while \
> reconnecting a single client.  After the patch, verbose logging and Wireshark show \
> NAK and then offering of the single free address, with the client having it's IP \
> updated each time ipconfig /renew is issued. 
> Please consider for inclusion to busybox.
> 
> +                       // Check if there is a different static lease for this IP \
> or MAC +                       slnip = \
> get_static_nip_by_mac(server_config.static_leases, lease.lease_mac); +              \
> if ((slnip != 0 && slnip != lease.lease_nip) +                        || (slnip == \
> 0 && is_nip_reserved(server_config.static_leases, lease.lease_nip))) +              \
> continue; +

I'm going with a somewhat different version:

+                       /* Check if there is a different static lease
for this IP or MAC */
+                       static_nip =
get_static_nip_by_mac(server_config.static_leases, lease.lease_mac);
+                       if (static_nip) {
+                               /* NB: we do not add lease even if
static_nip == lease.lease_nip.
+                                */
+                               continue;
+                       }
+                       if
(is_nip_reserved(server_config.static_leases, lease.lease_nip))
+                               continue;

Thanks!
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic