From owner-freebsd-sparc64@FreeBSD.ORG Sun Jun 27 14:00:44 2004 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 24A2616A4DB for ; Sun, 27 Jun 2004 14:00:44 +0000 (GMT) Received: from ida.interface-business.de (ida.interface-business.de [193.101.57.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9F98A43D3F for ; Sun, 27 Jun 2004 14:00:35 +0000 (GMT) (envelope-from j@ida.interface-business.de) Received: by ida.interface-business.de (Postfix, from userid 107) id A51027A49; Sun, 27 Jun 2004 16:00:33 +0200 (MET DST) Date: Sun, 27 Jun 2004 16:00:33 +0200 From: Joerg Wunsch To: dhcp-hackers@isc.org Message-ID: <20040627160033.G75210@ida.interface-business.de> References: <20040627005719.M38063@cvs.imp.ch> <20040627090642.A75210@ida.interface-business.de> <20040627101539.G38063@cvs.imp.ch> <20040627115951.C75210@ida.interface-business.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20040627115951.C75210@ida.interface-business.de>; from j@ida.interface-business.de on Sun, Jun 27, 2004 at 11:59:51AM +0200 X-Phone: +49-351-31809-14 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Organization: interface systems GmbH, Dresden cc: sparc64@freebsd.org Subject: Re: 64-bit time_t safe lease time X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Joerg Wunsch List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jun 2004 14:00:44 -0000 [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 -#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/