Re: dhclient/dhclient.conf change in -CURRENT? (fwd)

From: Larry Rosenman <ler_at_lerctr.org>
Date: Mon, 04 Aug 2003 20:35:06 -0500
Forwarding to the list...


------------ Forwarded Message ------------
Date: Monday, August 04, 2003 20:18:28 -0500
From: Larry Rosenman <ler_at_lerctr.org>
To: Martin Blapp <mb_at_imp.ch>
Cc:
Subject: Re: dhclient/dhclient.conf change in -CURRENT?

It did ****NOT**** do the right thing at boot.  I did run it with -d -v and
got the following....


Script started on Mon Aug  4 20:13:21 2003
lerlaptop# dhclient -d -v wi0

Internet Software Consortium DHCP Client V3.0.1rc11
Copyright 1995-2002 Internet Software Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP

Listening on BPF/wi0/00:06:25:18:1a:37
Sending on   BPF/wi0/00:06:25:18:1a:37
Sending on   Socket/fallback
DHCPREQUEST on wi0 to 255.255.255.255 port 67
DHCPREQUEST on wi0 to 255.255.255.255 port 67
Trying medium "wepmode off ssid 'rednet' wepkey 1:- wepkey 2:- wepkey 3:-
wepkey 4:- " 1 DHCPDISCOVER on wi0 to 255.255.255.255 port 67 interval 6
Trying medium "wepmode off ssid 'IA-01' wepkey 1:- wepkey 2:- wepkey 3:-
wepkey 4:-" 0 DHCPDISCOVER on wi0 to 255.255.255.255 port 67 interval 6
Trying medium "wepmode off ssid 'LERCTR NETWORK' wepkey 1:- wepkey 2:-
wepkey 3:- wepkey 4:-" 0 DHCPDISCOVER on wi0 to 255.255.255.255 port 67
interval 6
DHCPREQUEST on wi0 to 255.255.255.255 port 67
Trying medium "wepmode off ssid 'rednet' wepkey 1:- wepkey 2:- wepkey 3:-
wepkey 4:- " 1 DHCPDISCOVER on wi0 to 255.255.255.255 port 67 interval 8
Trying medium "wepmode off ssid 'IA-01' wepkey 1:- wepkey 2:- wepkey 3:-
wepkey 4:-" 0 DHCPDISCOVER on wi0 to 255.255.255.255 port 67 interval 3
Trying medium "wepmode off ssid 'LERCTR NETWORK' wepkey 1:- wepkey 2:-
wepkey 3:- wepkey 4:-" 0 DHCPDISCOVER on wi0 to 255.255.255.255 port 67
interval 3
DHCPREQUEST on wi0 to 255.255.255.255 port 67
Trying medium "wepmode off ssid 'rednet' wepkey 1:- wepkey 2:- wepkey 3:-
wepkey 4:- " 1 DHCPDISCOVER on wi0 to 255.255.255.255 port 67 interval 9
DHCPREQUEST on wi0 to 255.255.255.255 port 67
Trying medium "wepmode off ssid 'IA-01' wepkey 1:- wepkey 2:- wepkey 3:-
wepkey 4:-" 0 DHCPDISCOVER on wi0 to 255.255.255.255 port 67 interval 9
Trying medium "wepmode off ssid 'LERCTR NETWORK' wepkey 1:- wepkey 2:-
wepkey 3:- wepkey 4:-" 0 DHCPDISCOVER on wi0 to 255.255.255.255 port 67
interval 3
DHCPOFFER from 207.158.72.11
DHCPREQUEST on wi0 to 255.255.255.255 port 67
DHCPACK from 207.158.72.11
bound to 207.158.72.14 -- renewal in 1087437530 seconds.
DHCPREQUEST on wi0 to 255.255.255.255 port 67
DHCPACK from 207.158.72.11
^Z
Suspended
lerlaptop# bg

[1]    dhclient -d -v wi0 &
lerlaptop# ^D??exit

Script done on Mon Aug  4 20:15:28 2003


--On Tuesday, August 05, 2003 00:52:25 +0200 Martin Blapp <mb_at_imp.ch> wrote:

>
> Hi Larry,
>
> And here is a more correct version. It still has some issues.
>
> The sleep interval for dhclient after we lost a successful
> link is too big.
>
> Can you live with this solution ?
>
> Martin
>
> --- src/contrib/isc-dhcp/includes/dhcpd.h.orig	Mon Aug  4 23:57:06 2003
> +++ src/contrib/isc-dhcp/includes/dhcpd.h	Mon Aug  4 23:57:37 2003
> _at__at_ -782,6 +782,7 _at__at_
>  	char name [IFNAMSIZ];		/* Its name... */
>  	int linkstatus;			/* Link status */
>  	int ieee802;			/* True if media is ieee802 */
> +	int mediaflag;			/* True if dhclient.conf has media settings */
>  	int index;			/* Its index. */
>  	int rfdesc;			/* Its read file descriptor. */
>  	int wfdesc;			/* Its write file descriptor, if
> --- src/contrib/isc-dhcp/client/dhclient.c.orig	Tue Aug  5 00:42:37 2003
> +++ src/contrib/isc-dhcp/client/dhclient.c	Tue Aug  5 00:45:05 2003
> _at__at_ -257,7 +257,9 _at__at_
>  			    log_fatal ("%s: interface name too long (max %ld)",
>  				       argv [i], (long)strlen (argv [i]));
>   		    strlcpy (tmp -> name, argv [i], IFNAMSIZ);
> -		    set_ieee802(tmp);
> +#ifdef __FreeBSD__
> +		    set_ieee80211(tmp);
> +#endif
>  		    tmp->linkstatus = interface_active(tmp);
>  		    if (interfaces) {
>  			    interface_reference (&tmp -> next,
> _at__at_ -412,7 +414,14 _at__at_
>  					     INTERFACE_AUTOMATIC)) !=
>  			     INTERFACE_REQUESTED))
>  				continue;
> -			set_ieee802(ip);
> +#ifdef __FreeBSD__
> +			set_ieee80211(ip);
> +#endif
> +			if (ip -> client -> config -> media != NULL)
> +				ip->mediaflag = 1;
> +			else
> +				ip->mediaflag = 0;
> +
>  			script_init (ip -> client,
>  				     "PREINIT", (struct string_list *)0);
>  			if (ip -> client -> alias)
> _at__at_ -1385,9 +1394,6 _at__at_
>  	int interval;
>  	int increase = 1;
>
> -	if (interface_active(client -> interface) == 0)
> -		return;
> -
>  	/* Figure out how long it's been since we started transmitting. */
>  	interval = cur_time - client -> first_sending;
>
> _at__at_ -1427,6 +1433,9 _at__at_
>  		}
>  	}
>
> +	if (interface_active(client -> interface) == 0)
> +		return;
> +
>  	/* If we're supposed to increase the interval, do so.  If it's
>  	   currently zero (i.e., we haven't sent any packets yet), set
>  	   it to one; otherwise, add to it a random number between
> _at__at_ -3215,14 +3224,29 _at__at_
>  	if (ifmr.ifm_status & IFM_AVALID) {
>  		if (ip->ieee802) {
>  			if ((IFM_TYPE(ifmr.ifm_active) == IFM_IEEE80211) &&
> -			     (ifmr.ifm_status & IFM_ACTIVE))
> +			     (ifmr.ifm_status & IFM_ACTIVE)) {
> +				if (ip->mediaflag &&
> +				    ip -> client -> state != S_BOUND)
> +					return (2);
>  				return (1);
> +			}
>  		} else {
> -			if (ifmr.ifm_status & IFM_ACTIVE)
> +			if (ifmr.ifm_status & IFM_ACTIVE) {
> +				if (ip->mediaflag &&
> +				    ip -> client -> state != S_BOUND)
> +					return (2);
>  				return (1);
> +			}
>  		}
>  	}
>
> +	/*
> +	 * If dhclient.conf contains media settings, we cannot
> +	 * abort if the interface is not set to active mode.
> +	 */
> +	if (ip->mediaflag && ip -> client -> state != S_BOUND)
> +		return (1);
> +
>  	return (0);
>  # else /* ifdef __FreeBSD__ */
>
> _at__at_ -3231,7 +3255,7 _at__at_
>  }
>
>  # ifdef __FreeBSD__
> -set_ieee802 (struct interface_info *ip) {
> +set_ieee80211 (struct interface_info *ip) {
>
>  	struct ieee80211req     ireq;
>  	u_int8_t                data[32];
> _at__at_ -3273,6 +3297,7 _at__at_
>  {
>  	struct interface_info *ip;
>  	struct client_state *client;
> +	int result;
>
>  # ifdef DEBUG
>  	printf("Polling interface status\n");
> _at__at_ -3312,11 +3337,19 _at__at_
>  				ip->linkstatus = 0;
>  			}
>  		} else {
> -			if (interface_active(ip) == 0) {
> +			if ((result = interface_active(ip)) == 0) {
>  # ifdef DEBUG
>  				printf("%s: Lost Link on interface\n", ip->name);
>  # endif
>  				ip->linkstatus = 0;
> +			}
> +			if (result == 2) {
> +				for (client = ip -> client;
> +                                     client; client = client -> next) {
> +                                        add_timeout(cur_time + random ()
> % 5, +                                                     state_reboot,
> client, 0, 0); +                                }
> +				ip->linkstatus = 1;
>  			}
>  		}
>  	}
>
> Martin Blapp, <mb_at_imp.ch> <mbr_at_FreeBSD.org>
> ------------------------------------------------------------------
> ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH
> Phone: +41 61 826 93 00 Fax: +41 61 826 93 01
> PGP: <finger -l mbr_at_freebsd.org>
> PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E
> ------------------------------------------------------------------



-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler_at_lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

---------- End Forwarded Message ----------



-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler_at_lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Received on Mon Aug 04 2003 - 16:35:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:17 UTC