Subject: bin/9405: dhclient throws away a valid static lease
To: None <gnats-bugs@gnats.netbsd.org>
From: None <M.Drochner@fz-juelich.de>
List: netbsd-bugs
Date: 02/13/2000 06:54:39
>Number:         9405
>Category:       bin
>Synopsis:       dhclient throws away a valid static lease
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 13 06:54:00 2000
>Last-Modified:
>Originator:     Matthias Drochner
>Organization:
	KFA Juelich
>Release:        today
>Environment:
	NetBSD-current
System: NetBSD zelz26 1.4S NetBSD 1.4S (xxx) #102: Thu Feb 10 12:23:34 MET 2000 drochner@zelz26:/home/drochner/xxx i386


>Description:
	I'm preparing a laptop for operation within a mini-network which
is not connected to my DHCP server (nor any other). For that, I've
put a static lease with the same IP address as I use normally into
/etc/dhclient.conf. The laptop wasn't connected to my DHCP server for
a while, so /var/db/dhclient.leases contains only an expired lease.
On startup, dhclient parses the static lease correctly and puts it to
ip->client->leases. Later, when /var/db/dhclient.leases is parsed, it
will be thrown away by this piece of code
(clparse.c:parse_client_lease_statement):
	/* The new lease may supersede a lease that's not the
	   active lease but is still on the lease list, so scan the
	   lease list looking for a lease with the same address, and
	   if we find it, toss it. */
	pl = (struct client_lease *)0;
	for (lp = ip -> client -> leases; lp; lp = lp -> next) {
		if (lp -> address.len == lease -> address.len &&
		    !memcmp (lp -> address.iabuf, lease -> address.iabuf,
			     lease -> address.len)) {
			if (pl)
				pl -> next = lp -> next;
			else
				ip -> client -> leases = lp -> next;
			free_client_lease (lp);
			break;
		}
	}

[side note: "pl" is always zero, perhaps "pl = lp;" at the end?]

Without a DHCP server we end up without an IP address.
>How-To-Repeat:
	-Assign an IP address via DHCP
	-Wait until it is expired
	-Set up a static lease with the same Address
	-Start dhclient
>Fix:
	???
>Audit-Trail:
>Unformatted: