dhcpd crashes from time to time

sscdvp at gmail.com sscdvp at gmail.com
Tue Sep 11 14:19:41 UTC 2012


The patch seems to lack some trivial tests (for example if fopen() had
succeeded, also some tests for not-null pointer should be done:

-if (oc -> data.len)
+if (oc && oc -> data.len && oc -> option && oc -> option -> name)

etc).
Anyhow I believe you should refer to patch's author - manser at datapark.ch in
order the patch will get a fix.

Serghei Samsi

2012/9/10 Tobias Szyndler <szyndler at datapark.ch>

>  Sorry for not giving all the needed information.
> Here more info about the server:
> dhcp-Version: isc-dhcpd-4.2.3-P2
> OS-Version: debian-squeeze 64bit
> Kernel: 2.6.32-5-amd64
>
> I put the conf file below as well as the patch that was used to patch the
> dhcpd. Sorry quite a bunch of code.
>
> Thanks a lot for any idea :-)
>
> dhcpd.conf:
> <<
> server-identifier 213.X.Y.70;
> authoritative;
>
> allow leasequery;
>
> # Log configuration
> log-facility local7;
>
> subnet 213.X.Y.0 netmask 255.255.255.0 { }
>
> option space mtaprov;
> option mtaprov.dhcpserver code 1 = ip-address;
> option mtaprov.provserver code 3 = string;
> option mtaprov.realm code 6 = string;
> option mta code 122 = encapsulate mtaprov;
>
> # Modems/fixed IP adresses
> include "/etc/dhcpd.d/modems.conf";
> include "/etc/dhcpd.d/fixedips.conf";
>
> # CMTS
> include "/etc/dhcpd.d/cmts1-casa-ipbundle-1.conf";
> include "/etc/dhcpd.d/cmts1-casa-ipbundle-2.conf";
> include "/etc/dhcpd.d/cmts3-cuda-ipbundle-1.conf";
> #include "/etc/dhcpd.d/cmts99-casa-ipbundle-1.conf";
> #include "/etc/dhcpd.d/cmts99-cuda-ipbundle-1.conf";
>
> # GPON
> include "/etc/dhcpd.d/gpon1.conf";
>
> # Default lease times for CPE
> default-lease-time 43200;
> max-lease-time 43200;
> min-lease-time 43200;
> >>
>
> We patched the dhcpd with this patch:
> <<
>
> diff -crB dhcp-4.2.3-P2-original/includes/dhcpd.h dhcp-4.2.3-P2/includes/dhcpd.h*** dhcp-4.2.3-P2-original/includes/dhcpd.h	2011-12-31 00:17:04.000000000 +0100--- dhcp-4.2.3-P2/includes/dhcpd.h	2012-03-05 **15:14:57.330173993 +0100****************** 1866,1871 ****--- 1866,1872 ----
>
>   extern const char *path_dhcpd_conf;
>   extern const char *path_dhcpd_db;+ extern const char *path_dhcpd_ldb;
>   extern const char *path_dhcpd_pid;
>
>   extern int dhcp_max_agent_option_packet_length;
> diff -crB dhcp-4.2.3-P2-original/server/dhcp.c dhcp-4.2.3-P2/server/dhcp.c*** dhcp-4.2.3-P2-original/server/dhcp.c	2011-07-20 00:22:49.000000000 +0200--- dhcp-4.2.3-P2/server/dhcp.c	2012-03-05 16:11:59.322673851 +0100****************** 791,796 ****--- 791,817 ----
>   		 ? inet_ntoa (packet -> raw -> giaddr)
>   		 : packet -> interface -> name,
>   		 lease ? "" : "not ");+ 	+ 	char timestr_release[32];+ 	time_t release_time = time(0);+ 	struct tm *foo=localtime(&release_time);+ 	sprintf(timestr_release, "%04d-%02d-%02d %02d:%02d:%02d", + 	foo->tm_year + 1900,+ 	foo->tm_mon + 1,+ 	foo->tm_mday,+ 	foo->tm_hour,+ 	foo->tm_min,+ 	foo->tm_sec);+ 	+ 	FILE *leaselog;+ 	leaselog = fopen(path_dhcpd_ldb, "a+");+ 	fprintf(leaselog, "%s,", "DHCPRELEASE");+ 	fprintf(leaselog, "%s,", piaddr (lease -> ip_addr));+ 	fprintf(leaselog, "%s,", timestr_release);+ 	fprintf(leaselog, "%s,", timestr_release);+ 	fprintf(leaselog, "%s,", "-");+ 	fprintf(leaselog, "\n");+ 	fclose(leaselog);
>
>   #if defined (FAILOVER_PROTOCOL)
>   	if (lease && lease -> pool && lease -> pool -> failover_peer) {****************** 3135,3140 ****--- 3156,3213 ----
>   		  (state -> giaddr.s_addr
>   		   ? inet_ntoa (state -> giaddr)
>   		   : state -> ip -> name));+ 	+ 	int ok=1;+ 	struct option_cache *ridopt = NULL, *cidopt = NULL;+ 	+ 	if (lease -> agent_options) {+ 		struct option_cache *oc;+ 		pair p;+ 		+ 		for (p = lease -> agent_options -> first; p; p = p -> cdr) {+ 			oc = (struct option_cache *)p -> car;+ 			if (oc -> data.len) {+ 				if (!strcasecmp(oc -> option -> name, "circuit-id")) cidopt = oc;+ 				else if (!strcasecmp(oc -> option -> name, "remote-id")) ridopt = oc;+ 			}+ 		}+ 	}+ 	+ 	char timestr_start[32], timestr_end[32];+ 	struct tm *foo=localtime(&(lease->starts));+ 	sprintf(timestr_start, "%04d-%02d-%02d %02d:%02d:%02d",+ 	foo->tm_year + 1900,+ 	foo->tm_mon + 1,+ 	foo->tm_mday,+ 	foo->tm_hour,+ 	foo->tm_min,+ 	foo->tm_sec);+ 	foo=localtime(&(lease->ends));+ 	sprintf(timestr_end, "%04d-%02d-%02d %02d:%02d:%02d",+ 	foo->tm_year + 1900,+ 	foo->tm_mon + 1,+ 	foo->tm_mday,+ 	foo->tm_hour,+ 	foo->tm_min,+ 	foo->tm_sec);+ + 	if(state -> offer == DHCPACK) {+ 		FILE *leaselog;+ 		leaselog = fopen(path_dhcpd_ldb, "a+");+ 		fprintf(leaselog, "%s,", "DHCPACK");+ 		fprintf(leaselog, "%s,", piaddr (lease -> ip_addr));+ 		fprintf(leaselog, "%s,", timestr_start);+ 		fprintf(leaselog, "%s,", timestr_end);+ 		if (ok) {+ 			if (ridopt) {+ 				fprintf(leaselog, "%s,", pretty_print_option (ridopt -> option, ridopt -> data.data, ridopt -> data.len, 1, 1));+ 			} else {+ 				fprintf(leaselog, "NO_REMOTE_ID");+ 			}+ 		}+ 		fprintf(leaselog, "\n");+ 		fclose(leaselog);+ 	}
>
>   	/* Set up the hardware address... */
>   	hto.hlen = lease -> hardware_addr.hlen;
> diff -crB dhcp-4.2.3-P2-original/server/dhcpd.c dhcp-4.2.3-P2/server/dhcpd.c*** dhcp-4.2.3-P2-original/server/dhcpd.c	2011-12-31 01:55:22.000000000 +0100--- dhcp-4.2.3-P2/server/dhcpd.c	2012-03-05 15:14:57.400173967 +0100****************** 33,39 ****
>    */
>
>   static const char copyright[] =! "Copyright 2004-2012 Internet Systems Consortium.";
>   static const char arr [] = "All rights reserved.";
>   static const char message [] = "Internet Systems Consortium DHCP Server";
>   static const char url [] =--- 33,39 ----
>    */
>
>   static const char copyright[] =! "Copyright 2004-2012 Internet Systems Consortium.\r\nLease queue patch by Daniel Manser (manser at datap
>  ark.ch <manser at datapark.ch>)";
>   static const char arr [] = "All rights reserved.";
>   static const char message [] = "Internet Systems Consortium DHCP Server";
>   static const char url [] =****************** 159,164 ****--- 159,166 ----
>
>   const char *path_dhcpd_conf = _PATH_DHCPD_CONF;
>   const char *path_dhcpd_db = _PATH_DHCPD_DB;+ /* dm, 2012-02-29: lease database path */+ const char *path_dhcpd_ldb = NULL;
>   const char *path_dhcpd_pid = _PATH_DHCPD_PID;
>   /* False (default) => we write and use a pid file */
>   isc_boolean_t no_pid_file = ISC_FALSE;****************** 249,254 ****--- 251,258 ----
>   #endif
>   	int no_dhcpd_conf = 0;
>   	int no_dhcpd_db = 0;+ 	/* dm, 2012-02-29 */+ 	int no_dhcpd_ldb = 0;
>   	int no_dhcpd_pid = 0;
>   #ifdef DHCPv6
>   	int local_family_set = 0;****************** 348,353 ****--- 352,363 ----
>   				usage ();
>   			path_dhcpd_db = argv [i];
>   			no_dhcpd_db = 1;+ 		/* dm, 2012-02-29: Lease queue cmdline arg parsing */+ 		} else if (!strcmp (argv [i], "-ldb")) {+ 			if (++i == argc)+ 				usage ();+ 			path_dhcpd_ldb = argv [i];+ 			no_dhcpd_ldb = 1;
>   		} else if (!strcmp (argv [i], "-pf")) {
>   			if (++i == argc)
>   				usage ();
> diff -crB dhcp-4.2.3-P2-original/server/dhcpleasequery.c dhcp-4.2.3-P2/server/dhcpleasequery.c*** dhcp-4.2.3-P2-original/server/dhcpleasequery.c	2011-04-22 15:30:14.000000000 +0200--- dhcp-4.2.3-P2/server/dhcpleasequery.c	2012-03-
>  06 09:**37:32.700174022 +0100****************** 487,492 ****--- 487,493 ----
>   		}
>
>   		if (lease->ends > cur_time) {+ 			/* dm, 2012-03-06
>   			if (time_expiry < cur_time) {
>   				log_error("Impossible condition at %s:%d.",
>   					  MDL);****************** 495,500 ****--- 496,502 ----
>   				lease_dereference(&lease, MDL);
>   				return;
>   			}+ 			*/
>   			time_expiry = htonl(lease->ends - cur_time);
>   			if (!add_option(options,
>   					DHO_DHCP_LEASE_TIME,
> >>
>
>
>
>
> Am 10.09.2012 09:11, schrieb sthaug at nethelp.no:
>
>  one of our dhcp crashes from time to time. To further trace this problem
> we setup traces to narrow down the cause of the crash.
>
>  If you want help, you need to give considerably more info. dhcpd
> version, operating system, preferably dhcpd.conf.
>
> Steinar Haug, Nethelp consulting, sthaug at nethelp.no
>
>
> --
> Freundliche Grüsse
>
> Datapark AG
> Tobias Szyndler
> Hubstrasse 101
> CH-9500 Wil SG
>
> Tel. +41 71 560 60 95
> szyndler at datapark.ch
> www.datapark.ch
>
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20120911/b0c5d498/attachment-0001.html>


More information about the dhcp-users mailing list