summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorOvidiu Panait <ovidiu.panait@windriver.com>2020-02-27 13:45:49 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-16 16:44:53 +0000
commitae1001ab3a82de100619878644ff5e20d276eb6c (patch)
tree0cfb2de9e93bf7bc5156a582d5c24f922a2b7b4a /meta
parentf4f272f72c71fe1056f7658b767225139e797b27 (diff)
downloadpoky-ae1001ab3a82de100619878644ff5e20d276eb6c.tar.gz
dhcp: Fix REQUIRE(ctx->running) assertion triggered on SIGTERM/SIGINT
Closed a small window of time between the installation of graceful shutdown signal handlers and application context startup, during which the receipt of shutdown signal would cause a REQUIRE() assertion to occur. Note this issue is only visible when compiling with ENABLE_GENTLE_SHUTDOWN defined. Reference: https://gitlab.isc.org/isc-projects/dhcp/issues/53 Upstream patches: https://gitlab.isc.org/isc-projects/dhcp/commit/ce117de7a1ed3c4911b4009c1cc23fba85370a26 https://gitlab.isc.org/isc-projects/dhcp/commit/dbd36dfa82956b53683462afadfabb1b33fa3dd1 https://gitlab.isc.org/isc-projects/dhcp/commit/95944cab6035d20be270eec01254c7bb867ec705 (From OE-Core rev: 7235c62727e48415c4e81f852607311ec31b6e41) Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-connectivity/dhcp/dhcp/0001-Ensure-context-is-running-prior-to-calling-isc_app_c.patch165
-rw-r--r--meta/recipes-connectivity/dhcp/dhcp/0002-Added-shutdown-log-statment-to-dhcrelay.patch29
-rw-r--r--meta/recipes-connectivity/dhcp/dhcp/0003-Addressed-review-comment.patch31
-rw-r--r--meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb3
4 files changed, 228 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/dhcp/dhcp/0001-Ensure-context-is-running-prior-to-calling-isc_app_c.patch b/meta/recipes-connectivity/dhcp/dhcp/0001-Ensure-context-is-running-prior-to-calling-isc_app_c.patch
new file mode 100644
index 0000000000..34b2ae1e5c
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/dhcp/0001-Ensure-context-is-running-prior-to-calling-isc_app_c.patch
@@ -0,0 +1,165 @@
1From f369dbb9e67eb5ef336944af63039b6d8f838384 Mon Sep 17 00:00:00 2001
2From: Thomas Markwalder <tmark@isc.org>
3Date: Thu, 12 Sep 2019 10:35:46 -0400
4Subject: [PATCH 1/3] Ensure context is running prior to calling
5 isc_app_ctxsuspend
6
7Add a release note.
8
9includes/omapip/isclib.h
10 Added actx_running flag to global context, dhcp_gbl_ctx
11
12omapip/isclib.c
13 set_ctx_running() - new function used as the ctxonrun callback
14
15 dhcp_context_create() - installs set_ctx_running callback
16
17 dhcp_signal_handler() - modified to use act_running flag to
18 determine is context is running and should be suspended
19
20Upstream-Status: Backport [https://gitlab.isc.org/isc-projects/dhcp.git]
21
22Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
23---
24 RELNOTES | 7 +++++
25 includes/omapip/isclib.h | 3 ++-
26 omapip/isclib.c | 57 +++++++++++++++++++++++++++++++++-------
27 3 files changed, 57 insertions(+), 10 deletions(-)
28
29diff --git a/RELNOTES b/RELNOTES
30index f10305d..1730473 100644
31--- a/RELNOTES
32+++ b/RELNOTES
33@@ -6,6 +6,13 @@
34
35 NEW FEATURES
36
37+- Closed a small window of time between the installation of graceful
38+ shutdown signal handlers and application context startup, during which
39+ the receipt of shutdown signal would cause a REQUIRE() assertion to
40+ occur. Note this issue is only visible when compiling with
41+ ENABLE_GENTLE_SHUTDOWN defined.
42+ [Gitlab #53,!18 git TBD]
43+
44 Please note that that ISC DHCP is now licensed under the Mozilla Public License,
45 MPL 2.0. Please see https://www.mozilla.org/en-US/MPL/2.0/ to read the MPL 2.0
46 license terms.
47diff --git a/includes/omapip/isclib.h b/includes/omapip/isclib.h
48index 6c20584..af6a6fc 100644
49--- a/includes/omapip/isclib.h
50+++ b/includes/omapip/isclib.h
51@@ -94,7 +94,8 @@
52 typedef struct dhcp_context {
53 isc_mem_t *mctx;
54 isc_appctx_t *actx;
55- int actx_started;
56+ int actx_started; // ISC_TRUE if ctxstart has been called
57+ int actx_running; // ISC_TRUE if ctxrun has been called
58 isc_taskmgr_t *taskmgr;
59 isc_task_t *task;
60 isc_socketmgr_t *socketmgr;
61diff --git a/omapip/isclib.c b/omapip/isclib.c
62index ce4b4a1..73e017c 100644
63--- a/omapip/isclib.c
64+++ b/omapip/isclib.c
65@@ -134,6 +134,35 @@ handle_signal(int sig, void (*handler)(int)) {
66 }
67 }
68
69+/* Callback passed to isc_app_ctxonrun
70+ *
71+ * BIND9 context code will invoke this handler once the context has
72+ * entered the running state. We use it to set a global marker so that
73+ * we can tell if the context is running. Several of the isc_app_
74+ * calls REQUIRE that the context is running and we need a way to
75+ * know that.
76+ *
77+ * We also check to see if we received a shutdown signal prior to
78+ * the context entering the run state. If we did, then we can just
79+ * simply shut the context down now. This closes the relatively
80+ * small window between start up and entering run via the call
81+ * to dispatch().
82+ *
83+ */
84+static void
85+set_ctx_running(isc_task_t *task, isc_event_t *event) {
86+ task = task; // unused;
87+ dhcp_gbl_ctx.actx_running = ISC_TRUE;
88+
89+ if (shutdown_signal) {
90+ // We got signaled shutdown before we entered running state.
91+ // Now that we've reached running state, shut'er down.
92+ isc_app_ctxsuspend(dhcp_gbl_ctx.actx);
93+ }
94+
95+ isc_event_free(&event);
96+}
97+
98 isc_result_t
99 dhcp_context_create(int flags,
100 struct in_addr *local4,
101@@ -141,6 +170,9 @@ dhcp_context_create(int flags,
102 isc_result_t result;
103
104 if ((flags & DHCP_CONTEXT_PRE_DB) != 0) {
105+ dhcp_gbl_ctx.actx_started = ISC_FALSE;
106+ dhcp_gbl_ctx.actx_running = ISC_FALSE;
107+
108 /*
109 * Set up the error messages, this isn't the right place
110 * for this call but it is convienent for now.
111@@ -204,15 +236,24 @@ dhcp_context_create(int flags,
112 if (result != ISC_R_SUCCESS)
113 goto cleanup;
114
115- result = isc_task_create(dhcp_gbl_ctx.taskmgr, 0, &dhcp_gbl_ctx.task);
116+ result = isc_task_create(dhcp_gbl_ctx.taskmgr, 0,
117+ &dhcp_gbl_ctx.task);
118 if (result != ISC_R_SUCCESS)
119 goto cleanup;
120
121 result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
122 if (result != ISC_R_SUCCESS)
123- return (result);
124+ goto cleanup;
125+
126 dhcp_gbl_ctx.actx_started = ISC_TRUE;
127
128+ // Install the onrun callback.
129+ result = isc_app_ctxonrun(dhcp_gbl_ctx.actx, dhcp_gbl_ctx.mctx,
130+ dhcp_gbl_ctx.task, set_ctx_running,
131+ dhcp_gbl_ctx.actx);
132+ if (result != ISC_R_SUCCESS)
133+ goto cleanup;
134+
135 /* Not all OSs support suppressing SIGPIPE through socket
136 * options, so set the sigal action to be ignore. This allows
137 * broken connections to fail gracefully with EPIPE on writes */
138@@ -335,19 +376,17 @@ isclib_make_dst_key(char *inname,
139 * @param signal signal code that we received
140 */
141 void dhcp_signal_handler(int signal) {
142- isc_appctx_t *ctx = dhcp_gbl_ctx.actx;
143- int prev = shutdown_signal;
144-
145- if (prev != 0) {
146+ if (shutdown_signal != 0) {
147 /* Already in shutdown. */
148 return;
149 }
150+
151 /* Possible race but does it matter? */
152 shutdown_signal = signal;
153
154- /* Use reload (aka suspend) for easier dispatch() reenter. */
155- if (ctx && ctx->methods && ctx->methods->ctxsuspend) {
156- (void) isc_app_ctxsuspend(ctx);
157+ /* If the application context is running tell it to shut down */
158+ if (dhcp_gbl_ctx.actx_running == ISC_TRUE) {
159+ (void) isc_app_ctxsuspend(dhcp_gbl_ctx.actx);
160 }
161 }
162
163--
1642.23.0
165
diff --git a/meta/recipes-connectivity/dhcp/dhcp/0002-Added-shutdown-log-statment-to-dhcrelay.patch b/meta/recipes-connectivity/dhcp/dhcp/0002-Added-shutdown-log-statment-to-dhcrelay.patch
new file mode 100644
index 0000000000..78b2b74f45
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/dhcp/0002-Added-shutdown-log-statment-to-dhcrelay.patch
@@ -0,0 +1,29 @@
1From adcd34ae1f56b16d7e9696d980332b4cf6c7ce91 Mon Sep 17 00:00:00 2001
2From: Thomas Markwalder <tmark@isc.org>
3Date: Fri, 13 Sep 2019 15:03:31 -0400
4Subject: [PATCH 2/3] Added shutdown log statment to dhcrelay
5
6Upstream-Status: Backport [https://gitlab.isc.org/isc-projects/dhcp.git]
7
8Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
9---
10 relay/dhcrelay.c | 3 +++
11 1 file changed, 3 insertions(+)
12
13diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
14index d8caaaf..4bd1d47 100644
15--- a/relay/dhcrelay.c
16+++ b/relay/dhcrelay.c
17@@ -2076,6 +2076,9 @@ dhcp_set_control_state(control_object_state_t oldstate,
18 if (newstate != server_shutdown)
19 return ISC_R_SUCCESS;
20
21+ /* Log shutdown on signal. */
22+ log_info("Received signal %d, initiating shutdown.", shutdown_signal);
23+
24 if (no_pid_file == ISC_FALSE)
25 (void) unlink(path_dhcrelay_pid);
26
27--
282.23.0
29
diff --git a/meta/recipes-connectivity/dhcp/dhcp/0003-Addressed-review-comment.patch b/meta/recipes-connectivity/dhcp/dhcp/0003-Addressed-review-comment.patch
new file mode 100644
index 0000000000..a51b6cf526
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/dhcp/0003-Addressed-review-comment.patch
@@ -0,0 +1,31 @@
1From e4b54b4d676783152d487103714cba2913661ef8 Mon Sep 17 00:00:00 2001
2From: Thomas Markwalder <tmark@isc.org>
3Date: Wed, 6 Nov 2019 15:53:50 -0500
4Subject: [PATCH 3/3] Addressed review comment.
5
6omapip/isclib.c
7 Added use of IGNORE_UNUSED()
8
9Upstream-Status: Backport [https://gitlab.isc.org/isc-projects/dhcp.git]
10
11Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
12---
13 omapip/isclib.c | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/omapip/isclib.c b/omapip/isclib.c
17index 73e017c..1d52463 100644
18--- a/omapip/isclib.c
19+++ b/omapip/isclib.c
20@@ -151,7 +151,7 @@ handle_signal(int sig, void (*handler)(int)) {
21 */
22 static void
23 set_ctx_running(isc_task_t *task, isc_event_t *event) {
24- task = task; // unused;
25+ IGNORE_UNUSED(task);
26 dhcp_gbl_ctx.actx_running = ISC_TRUE;
27
28 if (shutdown_signal) {
29--
302.23.0
31
diff --git a/meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb b/meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb
index 275961a603..ddc8b60254 100644
--- a/meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb
+++ b/meta/recipes-connectivity/dhcp/dhcp_4.4.1.bb
@@ -11,6 +11,9 @@ SRC_URI += "file://0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.pat
11 file://0013-fixup_use_libbind.patch \ 11 file://0013-fixup_use_libbind.patch \
12 file://0001-master-Added-includes-of-new-BIND9-compatibility-hea.patch \ 12 file://0001-master-Added-includes-of-new-BIND9-compatibility-hea.patch \
13 file://0001-Fix-a-NSUPDATE-compiling-issue.patch \ 13 file://0001-Fix-a-NSUPDATE-compiling-issue.patch \
14 file://0001-Ensure-context-is-running-prior-to-calling-isc_app_c.patch \
15 file://0002-Added-shutdown-log-statment-to-dhcrelay.patch \
16 file://0003-Addressed-review-comment.patch \
14" 17"
15 18
16SRC_URI[md5sum] = "18c7f4dcbb0a63df25098216d47b1ede" 19SRC_URI[md5sum] = "18c7f4dcbb0a63df25098216d47b1ede"