dhcp: Revert "dhcp: enable gentle shutdown" and reset handler
PATCH 1/1 dhcp: Revert "dhcp: enable gentle shutdown" and reset handler
This reverts commit 4653fdd4b4cf13543e32fbcf09e50f60c1719a34
This patch is used to solve the problem in which dhcpd can not be killed by SIGINT and SIGTERM. But it seems not good to rely on ENABLE_GENTLE_SHUTDOWN, which is an "undesireable feature" and will release its address after receive both signal, accoring to the comment in "includes/site.h". Then there is no difference between "dhclient -x" and "dhclient -r". We can find following call trace from source code:
main() -> dhcp_context_create() -> isc_app_ctxstart() -> isc__app_ctxstart()
The root cause is that exit_action() is registered as the signal handler for SIGTERM and SIGINT, which do-nothing as the comment says.
To fix this problem, we could simply set the default action for these two signals if ENABLE_GENTLE_SHUTDOWN is not set.
--- ...et-default-handler-for-SIGTERM-and-SIGINT.patch | 63 ++++++++++++++++++++++ .../dhcp/0006-site.h-enable-gentle-shutdown.patch | 27 ---------- meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb | 2 +- 3 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 meta/recipes-connectivity/dhcp/dhcp/0001-dhcp-set-default-handler-for-SIGTERM-and-SIGINT.patch delete mode 100644 meta/recipes-connectivity/dhcp/dhcp/0006-site.h-enable-gentle-shutdown.patch
meta/recipes-connectivity/dhcp/dhcp/0001-dhcp-set-default-handler-for-SIGTERM-and-SIGINT.patch new file +63 -0
@@ -0,0 +1,63 @@ +From eaa74a4fd8ebcc031c63a8a39d20cd1ffe0eaf4f Mon Sep 17 00:00:00 2001 +From: Rui Wang <[email protected]> +Date: Tue, 7 May 2019 10:41:20 +0800 +Subject: [PATCH] dhcp: set default handler for SIGTERM and SIGINT + +dhcp uses function in bind to init it's state, which will block +signal SIGTERM and SIGINT by default. This causes dhclient not +able to be killed by those two signals if gentle-shutdown is +disabled. So reset their signal handler to default in such +situation. + +Signed-off-by: Rui Wang <[email protected]> +--- + client/dhclient.c | 3 +++ + relay/dhcrelay.c | 3 +++ + server/dhcpd.c | 3 +++ + 3 files changed, 9 insertions(+) + +diff --git a/client/dhclient.c b/client/dhclient.c +index 825ab00..159cf39 100644 +--- a/client/dhclient.c ++++ b/client/dhclient.c +@@ -971,6 +971,9 @@ main(int argc, char **argv) { + /* install signal handlers */ + signal(SIGINT, dhcp_signal_handler); /* control-c */ + signal(SIGTERM, dhcp_signal_handler); /* kill */ ++#else ++ signal(SIGINT, SIG_DFL); ++ signal(SIGTERM, SIG_DFL); + #endif + + /* If we're not supposed to wait before getting the address, +diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c +index d8caaaf..ec22385 100644 +--- a/relay/dhcrelay.c ++++ b/relay/dhcrelay.c +@@ -814,6 +814,9 @@ main(int argc, char **argv) { + /* install signal handlers */ + signal(SIGINT, dhcp_signal_handler); /* control-c */ + signal(SIGTERM, dhcp_signal_handler); /* kill */ ++#else ++ signal(SIGINT, SIG_DFL); ++ signal(SIGTERM, SIG_DFL); + #endif + + /* Start dispatching packets and timeouts... */ +diff --git a/server/dhcpd.c b/server/dhcpd.c +index 55ffae7..f5aced3 100644 +--- a/server/dhcpd.c ++++ b/server/dhcpd.c +@@ -1052,6 +1052,9 @@ main(int argc, char **argv) { + /* install signal handlers */ + signal(SIGINT, dhcp_signal_handler); /* control-c */ + signal(SIGTERM, dhcp_signal_handler); /* kill */ ++#else ++ signal(SIGINT, SIG_DFL); ++ signal(SIGTERM, SIG_DFL); + #endif + + /* Log that we are about to start working */ +-- +1.8.3.1 +
meta/recipes-connectivity/dhcp/dhcp/0006-site.h-enable-gentle-shutdown.patch deleted +0 -27
@@ -1,27 +0,0 @@ -From 01641d146e4e6bea954e4a4ee1f6230b822665b4 Mon Sep 17 00:00:00 2001 -From: Chen Qi <[email protected]> -Date: Tue, 15 Aug 2017 15:37:49 +0800 -Subject: [PATCH 06/11] site.h: enable gentle shutdown - -Upstream-Status: Inappropriate [configuration] -Signed-off-by: Chen Qi <[email protected]> - -Rebase to 4.3.6 -Signed-off-by: Hongxu Jia <[email protected]> ---- - includes/site.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -Index: dhcp-4.4.1/includes/site.h -=================================================================== ---- dhcp-4.4.1.orig/includes/site.h -+++ dhcp-4.4.1/includes/site.h -@@ -295,7 +295,7 @@ - situations. We plan to revisit this feature and may - make non-backwards compatible changes including the - removal of this define. Use at your own risk. */ --/* #define ENABLE_GENTLE_SHUTDOWN */ -+#define ENABLE_GENTLE_SHUTDOWN - - /* Include old error codes. This is provided in case you - are building an external program similar to omshell for
meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb +1 -1
@@ -5,12 +5,12 @@ SRC_URI += "file://0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.pat file://0003-link-with-lcrypto.patch \ file://0004-Fix-out-of-tree-builds.patch \ file://0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch \ - file://0006-site.h-enable-gentle-shutdown.patch \ file://0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch \ file://0009-remove-dhclient-script-bash-dependency.patch \ file://0012-dhcp-correct-the-intention-for-xml2-lib-search.patch \ file://0013-fixup_use_libbind.patch \ file://0001-master-Added-includes-of-new-BIND9-compatibility-hea.patch \ + file://0001-dhcp-set-default-handler-for-SIGTERM-and-SIGINT.patch \ " SRC_URI[md5sum] = "18c7f4dcbb0a63df25098216d47b1ede"
Signature · 1 line
1.8.3.1
Quoted 13 lines · Rui Wang
This reverts commit
4653fdd4b4cf13543e32fbcf09e50f60c1719a34This patch is used to solve the problem in which dhcpd can not be killed by SIGINT and SIGTERM. But it seems not good to rely on
ENABLE_GENTLE_SHUTDOWN, which is an "undesireable feature" and will release its address after receive both signal, accoring to the comment in "includes/site.h". Then there is no difference between "dhclient -x" and "dhclient -r". We can find following call trace from source code:
main()->dhcp_context_create()->isc_app_ctxstart()->isc__app_ctxstart()
Quoted 7 lines
The root cause is that
exit_action()is registered as the signal handler for SIGTERM and SIGINT, which do-nothing as the comment says.To fix this problem, we could simply set the default action for these two signals if
ENABLE_GENTLE_SHUTDOWNis not set.Signed-off-by Rui Wang <[email protected]>
The new patch is missing an Upstream-Status?
Cheers,
Richard