Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Jun 2004 16:00:33 +0200
From:      Joerg Wunsch <j@ida.interface-business.de>
To:        dhcp-hackers@isc.org
Cc:        sparc64@freebsd.org
Subject:   Re: 64-bit time_t safe lease time
Message-ID:  <20040627160033.G75210@ida.interface-business.de>
In-Reply-To: <20040627115951.C75210@ida.interface-business.de>; from j@ida.interface-business.de on Sun, Jun 27, 2004 at 11:59:51AM %2B0200
References:  <20040627005719.M38063@cvs.imp.ch> <20040627090642.A75210@ida.interface-business.de> <20040627101539.G38063@cvs.imp.ch> <20040627115951.C75210@ida.interface-business.de>

next in thread | previous in thread | raw e-mail | index | archive | help
[Cc to sparc64@freebsd.org, since that's probably the group of users
currently most interested in the matter.]

As Joerg Wunsch wrote:

> Ad Martin Blapp wrote:
> > Does it help if you define TIME as int32_t ?

> Yes, that helps quite a bit.  Well, now it starts to send requests quickly,
> but it sends the requests to a random dst port so the DHCP server never
> responds:
> 
> 11:57:57.075934 0.0.0.0.68 > 255.255.255.255.39463:  (request) xid:0x4f353b0d vend-rfc1048 DHCP:DISCOVER PR:SM+BR+TZ+DG+DN+NS+HN [tos 0x10] 
> ^C

The problem was that GET_TIME() (first called in script_go())
clobbered part of sockaddr_broadcast.  The memory area it clobbers
looks a bit surprising to me, but the actual error became obvious
then: calling time() on a TIME* object, when sizeof(time_t) !=
sizeof(TIME) is just an error.

As a workaround, I added the following inline function:

Index: includes/cf/freebsd.h
===================================================================
RCS file: /home/ncvs/src/contrib/isc-dhcp/includes/cf/freebsd.h,v
retrieving revision 1.7
diff -u -r1.7 freebsd.h
--- includes/cf/freebsd.h	26 Jun 2004 10:37:42 -0000	1.7
+++ includes/cf/freebsd.h	27 Jun 2004 13:47:48 -0000
@@ -79,8 +79,14 @@
 
 /* Time stuff... */
 #include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x)	time ((x))
+#define TIME int32_t
+static __inline void
+freebsd_get_time(TIME *tp) {
+	time_t now;
+	time(&now);
+	*tp = (TIME)now;
+}
+#define GET_TIME(x)	freebsd_get_time ((x))
 
 #define HAVE_SA_LEN
 
That suffices as a workaround, though I think the code should be fixed
to not assume a particular integer width for time_t.  OK, year 2038 is
still somewhat ahead. ;-)

# dhclient -v gem0
Internet Systems Consortium DHCP Client V3.0.1rc14
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP

Listening on BPF/gem0/08:00:20:fe:a2:6e
Sending on   BPF/gem0/08:00:20:fe:a2:6e
Sending on   Socket/fallback
DHCPDISCOVER on gem0 to 255.255.255.255 port 67 interval 7
DHCPOFFER from 193.101.57.34
DHCPREQUEST on gem0 to 255.255.255.255 port 67
DHCPACK from 193.101.57.34
bound to 193.101.57.70 -- renewal in 40644 seconds.

Btw., that's without Dag-Erling's patch.  I cannot fully verifiy the
validity of the 40644 seconds above, but the default lease time here
is 86400, and the same lease has been given to that machine before.

As a note to the sparc64@freebsd.org listeners, the above assumes you
upgraded src/contrib/isc-dhcp and src/sbin/dhclient to Martin's
yesterday's import of V3.0.1rc14.  There seem to be no further side
effects from this, i. e. you don't necessarily need to upgrade the
entire world right now.

-- 
J"org Wunsch					       Unix support engineer
joerg_wunsch@interface-systems.de        http://www.interface-systems.de/~j/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040627160033.G75210>