NetBSD Problem Report #23949

Received: (qmail 21490 invoked by uid 605); 2 Jan 2004 15:29:28 -0000
Message-Id: <20040102152925.8AAA422E6@fnord.ir.bbn.com>
Date: Fri,  2 Jan 2004 10:29:25 -0500 (EST)
From: gdt@ir.bbn.com
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: gdt@ir.bbn.com
To: gnats-bugs@gnats.netbsd.org
Subject: dhclient fails to release leases when sent SIGTERM
X-Send-Pr-Version: 3.95

>Number:         23949
>Category:       bin
>Synopsis:       dhclient fails to release leases when sent SIGTERM
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 02 15:30:00 +0000 2004
>Closed-Date:    Sun Sep 23 13:55:01 +0000 2018
>Last-Modified:  Sun Sep 23 13:55:01 +0000 2018
>Originator:     Greg Troxel
>Release:        NetBSD 1.6.1_STABLE
>Organization:
        Greg Troxel <gdt@ir.bbn.com>
>Environment:


System: NetBSD fnord.ir.bbn.com 1.6.1_STABLE NetBSD 1.6.1_STABLE (FNORD) #7: Mon Oct 6 15:46:22 EDT 2003 root@fnord.ir.bbn.com:/home/gdt/QUIST-current/netbsd/src/sys/arch/i386/compile/FNORD i386
Architecture: i386
Machine: i386
>Description:
dhclient does not release leases when sent SIGTERM.
It does have code to clean up (release lease with server, unconfigure
address, restore resolv.conf, etc., which is invoked if it is shut
down via OMAPI).

>How-To-Repeat:

Run dhclient.  'pkill dhclient'.  Observe that the server did not get
a DHCPRELEASE, and that the interface is still configured.

>Fix:

Call the cleanup code when catching a signal.

I have been running with this for over a month with no observed ill effects.

Index: dist/dhcp/client/dhclient.c
===================================================================
RCS file: /QUIST-CVS/netbsd/src/dist/dhcp/client/dhclient.c,v
retrieving revision 1.1.1.4
retrieving revision 1.3
diff -u -r1.1.1.4 -r1.3
--- dist/dhcp/client/dhclient.c	2 Dec 2003 15:14:22 -0000	1.1.1.4
+++ dist/dhcp/client/dhclient.c	2 Dec 2003 17:20:39 -0000	1.3
@@ -87,6 +87,7 @@

 static void usage PROTO ((void));

+static void catch_sigterm(int x);
 void do_release(struct client_state *);

 int main (argc, argv, envp)
@@ -272,6 +273,9 @@
 	} else
 		log_perror = 0;

+	/* Set up SIGTERM handler to clean up state. */
+	signal(SIGTERM, &catch_sigterm);
+
 	/* If we're given a relay agent address to insert, for testing
 	   purposes, figure out what it is. */
 	if (relay) {
@@ -2931,6 +2935,12 @@
 static void shutdown_exit (void *foo)
 {
 	exit (0);
+}
+
+static void catch_sigterm(int x)
+{
+	/* undo resolv.conf, release leases, unconfigure interface */
+	dhcp_set_control_state(0 /* XXX unused */, server_shutdown);
 }

 isc_result_t dhcp_set_control_state (control_object_state_t oldstate,

>Release-Note:
>Audit-Trail:

From: itojun@itojun.org (Jun-ichiro itojun Hagino)
To: gdt@ir.bbn.com
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/23949: dhclient fails to release leases when sent SIGTERM
Date: Sat,  3 Jan 2004 05:50:40 +0900 (JST)

 > >Synopsis:       dhclient fails to release leases when sent SIGTERM

 	i guess it's best if it is sent to ISC.

 itojun

From: Christian Biere <christianbiere@gmx.de>
To: gdt@ir.bbn.com
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/23949: dhclient fails to release leases when sent SIGTERM
Date: Sat, 3 Jan 2004 14:25:00 +0100

 gdt@ir.bbn.com wrote:
 > Call the cleanup code when catching a signal.

 You can't do this directly in the signal handler. If you used
 sigsetjmp() and siglongjmp() it should be safe (AFAIK).

 -- 
 Christian
State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 23 Sep 2018 13:55:01 +0000
State-Changed-Why:
dhclient removed. sorry your bug was not answered at the time.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.