dhcpd crashes from time to time

Tobias Szyndler szyndler at datapark.ch
Mon Sep 10 08:10:43 UTC 2012


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 -crBdhcp-4.2.3-P2-original/includes/dhcpd.hdhcp-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-0515: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 intdhcp_max_agent_option_packet_length;
diff -crBdhcp-4.2.3-P2-original/server/dhcp.cdhcp-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-0516: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 -crBdhcp-4.2.3-P2-original/server/dhcpd.cdhcp-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-0515:14:57.400173967  +0100
***************
***33,39  ****
    */
  
   static const char copyright[]  =
! "Copyright2004-2012  Internet Systems Consortium.";
   static const char arr[]  = "All rights reserved.";
   static const char message[]  = "Internet Systems ConsortiumDHCP  Server";
   static const char url[]  =
---33,39  ----
    */
  
   static const char copyright[]  =
! "Copyright2004-2012  Internet Systems Consortium.\r\nLease queue patch by Daniel Manser(manser at datapark.ch)";
   static const char arr[]  = "All rights reserved.";
   static const char message[]  = "Internet Systems ConsortiumDHCP  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;
   #ifdefDHCPv6
   	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 -crBdhcp-4.2.3-P2-original/server/dhcpleasequery.cdhcp-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 <mailto:szyndler at datapark.ch>
www.datapark.ch <http://www.datapark.ch>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20120910/c7d70e44/attachment-0001.html>


More information about the dhcp-users mailing list