[Openvpn-devel] Change explicit exit notification to be a SIGUSR1 instead of a SIGTERM signal
| Message ID | 20221011110126.1798114-1-arne@rfc2549.org |
|---|---|
| State | Superseded |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id KFfLN1ZNRWPTOgAAIUCqbw (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Tue, 11 Oct 2022 07:02:46 -0400 Received: from proxy6.mail.iad3b.rsapps.net ([172.31.255.6]) by director7.mail.ord1d.rsapps.net with LMTP id SOfAN1ZNRWMKLgAAovjBpQ (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Tue, 11 Oct 2022 07:02:46 -0400 Received: from smtp18.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy6.mail.iad3b.rsapps.net with LMTPS id AIQ1MlZNRWP1EQAARawThA (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Tue, 11 Oct 2022 07:02:46 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp18.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 3c1f1daa-4954-11ed-b57f-5254009ad1d4-1-1 Received: from [216.105.38.7] ([216.105.38.7:50184] helo=lists.sourceforge.net) by smtp18.gate.iad3b.rsapps.net (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 5B/2F-18652-55D45436; Tue, 11 Oct 2022 07:02:46 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) id 1oiD1C-0006F6-Mv; Tue, 11 Oct 2022 11:01:50 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from <arne@kamera.blinkt.de>) id 1oiD0x-0006Eu-CD for openvpn-devel@lists.sourceforge.net; Tue, 11 Oct 2022 11:01:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BXRcUZXLVw0U0wAs9YBVRfJMEUyvWEvHYHjiQpLKc4o=; b=Gp8mXv7W7VaV3d6tivmRTFw+FZ lPn5wFfaaNp6UtB7ymE0oTBYU6D3NsDTlbqbpEOVayPH+Hx8Z6vfM/HWi76sMFXyp8MnWxgfNrV7F aLtgvkcGUSBmeH/eeBH+9YSpxJXMHtuyp1Wz2skUlO3pCzRjFfpSUA/xXBzMIEh18sVU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BXRcUZXLVw0U0wAs9YBVRfJMEUyvWEvHYHjiQpLKc4o=; b=ejq+1timKA+RkZEVE8HCSrP3p9 XCE7VPuWmXRYeJ5E5azPGzEG6M3zZ+YYJj6SiriT2gYB17K2zGRcP4Xt+0RHnQ1hFYAr+JU5qIRMb pLp4l4r24ybWjvlvkPcpDA9mjAxPgrRj4qhvTpJ4bBGM/Tusgw8nq/7YiTPNiGv1FJvE=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1oiD0v-0003BU-Kl for openvpn-devel@lists.sourceforge.net; Tue, 11 Oct 2022 11:01:35 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from <arne@kamera.blinkt.de>) id 1oiD0o-000KLa-64 for openvpn-devel@lists.sourceforge.net; Tue, 11 Oct 2022 13:01:26 +0200 Received: (nullmailer pid 1798160 invoked by uid 10006); Tue, 11 Oct 2022 11:01:26 -0000 From: Arne Schwabe <arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Tue, 11 Oct 2022 13:01:26 +0200 Message-Id: <20221011110126.1798114-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <YydCIP5l0WwH5OX+@greenie.muc.de> References: <YydCIP5l0WwH5OX+@greenie.muc.de> MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From the implemention and the fact that it is a an OCC message (basically the rudimentary predecessor to control channel), this message is very old. I think in the past this feature fit nicely to the weird inetd + openvpn mode that seems to have far to many hacks still left in our code. With inetd, it made sense that the server instance quits if y [...] Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-Headers-End: 1oiD0v-0003BU-Kl Subject: [Openvpn-devel] [PATCH] Change explicit exit notification to be a SIGUSR1 instead of a SIGTERM signal X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] Change explicit exit notification to be a SIGUSR1 instead of a SIGTERM signal
|
|
Commit Message
Arne Schwabe
Oct. 11, 2022, 12:01 a.m. UTC
From the implemention and the fact that it is a an OCC message
(basically the rudimentary predecessor to control channel),
this message is very old.
I think in the past this feature fit nicely to the weird inetd + openvpn mode
that seems to have far to many hacks still left in our code. With inetd,
it made sense that the server instance quits if you press C-c on the client.
In our current state where inetd is no longer supported, this behaviour
to exit makes little sense and this patch changes the behaviour to SIGUSR1.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
src/openvpn/occ.c | 2 +-
src/openvpn/push.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Comments
Hi, On Tue, Oct 11, 2022 at 01:01:26PM +0200, Arne Schwabe wrote: > From the implemention and the fact that it is a an OCC message > (basically the rudimentary predecessor to control channel), > this message is very old. > > I think in the past this feature fit nicely to the weird inetd + openvpn mode > that seems to have far to many hacks still left in our code. With inetd, > it made sense that the server instance quits if you press C-c on the client. > > In our current state where inetd is no longer supported, this behaviour > to exit makes little sense and this patch changes the behaviour to SIGUSR1. I am very confused about v2 of this patch - and would be happy to ACK v1. I have applied v1, and tested - p2p without the patch -> client sends EEN -> server exits 2022-10-14 16:56:56 us=334517 Exit message received by peer 2022-10-14 16:56:56 us=334753 TCP/UDP: Closing socket 2022-10-14 16:56:56 us=334814 Closing TUN/TAP interface 2022-10-14 16:56:56 us=334836 net_addr_v4_del: 10.204.11.1 dev tun11 2022-10-14 16:56:56 us=334987 net_addr_v6_del: fd00:abcd:204:11::1/64 dev tun11 2022-10-14 16:56:56 us=342133 SIGTERM[soft,remote-exit] received, process exiting - p2p with the v1 patch -> client sends EEN -> server logs, and restarts 2022-10-14 16:57:30 us=151079 Exit message received by peer 2022-10-14 16:57:30 us=151254 TCP/UDP: Closing socket 2022-10-14 16:57:30 us=151316 Closing TUN/TAP interface 2022-10-14 16:57:30 us=151343 net_addr_v4_del: 10.204.11.1 dev tun11 2022-10-14 16:57:30 us=151465 net_addr_v6_del: fd00:abcd:204:11::1/64 dev tun11 2022-10-14 16:57:30 us=155086 SIGUSR1[soft,remote-exit] received, process restarting 2022-10-14 16:57:30 us=155149 Restart pause, 5 second(s) (and then it rearms itself and is ready to server another p2p client) - p2mp server without patch -> client sends EEN -> server logs, and terminates the instance 2022-10-14 16:58:26 us=544309 cron2-freebsd-tc-amd64/194.97.140.21:17570 Exit message received by peer 2022-10-14 16:58:26 us=544365 cron2-freebsd-tc-amd64/194.97.140.21:17570 SIGTERM[soft,remote-exit] received, client-instance exiting - p2mp server with the v1 patch -> client sends EEN -> server logs, and says it will "restart" the instance 2022-10-14 16:59:02 us=113506 cron2-freebsd-tc-amd64/194.97.140.21:41691 Exit message received by peer 2022-10-14 16:59:02 us=113573 cron2-freebsd-tc-amd64/194.97.140.21:41691 SIGUSR1[soft,remote-exit] received, client-instance restarting - with a 2.4 client, it has no "Exit message recived by peer" (because that is the new control channel thing), and just logs 2022-10-14 17:03:47 us=455929 cron2-freebsd-tc-amd64/194.97.140.21:13152 SIGUSR1[soft,remote-exit] received, client-instance restarting Trying to understand the code is an interesting maze... that message above comes from sig.c::print_signal(), which is called from "multi::multi_close_instance_on_signal()". *That* one is called (mostly) from multi_process_post(), which says " * Also close context on signal." and basically does if (IS_SIG(&mi->context)) { if (flags & MPP_CLOSE_ON_SIGNAL) { multi_close_instance_on_signal(m, mi); ret = false; } } ... so, the nature of the (soft) signal raised does not seem to play any role to the instance - "if signal, then close instance". Just the logging is a bit off now ("restarting" vs. "exiting"). If we care about logging, I think we should do the signal remap in multi_close_instance_on_signal() (... which already remaps SIGUSR1 by means of remap_signal(), but only if c->options.remap_sigusr1 is set). OTOH, maybe it should just *not* call remap_signal(), as the per-instance signals and the global signals do different things, and always remap SIGUSR1-in-instance to SIGTERM... What I do not think will make us happy in future is the extra conditionals in v2... gert
> > If we care about logging, I think we should do the signal remap in > multi_close_instance_on_signal() (... which already remaps SIGUSR1 > by means of remap_signal(), but only if c->options.remap_sigusr1 is > set). > > OTOH, maybe it should just *not* call remap_signal(), as the per-instance > signals and the global signals do different things, and always remap > SIGUSR1-in-instance to SIGTERM... > > > What I do not think will make us happy in future is the extra > conditionals in v2... A completely different effect screwed up my testing and lead to believe that signals are handled different in p2p and p2mp. There is different behaviour in p2p and p2mp but it is triggered by the HMAC cookie approach that only p2mp has. Detailed explaination is in the code in patch v3. Arne
diff --git a/src/openvpn/occ.c b/src/openvpn/occ.c index 1ed0d3771..eb1f2fae7 100644 --- a/src/openvpn/occ.c +++ b/src/openvpn/occ.c @@ -431,7 +431,7 @@ process_received_occ_msg(struct context *c) case OCC_EXIT: dmsg(D_PACKET_CONTENT, "RECEIVED OCC_EXIT"); - c->sig->signal_received = SIGTERM; + c->sig->signal_received = SIGUSR1; c->sig->signal_text = "remote-exit"; break; } diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 26259c6b8..da8c456b1 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -193,7 +193,7 @@ void receive_exit_message(struct context *c) { dmsg(D_STREAM_ERRORS, "Exit message received by peer"); - c->sig->signal_received = SIGTERM; + c->sig->signal_received = SIGUSR1; c->sig->signal_text = "remote-exit"; #ifdef ENABLE_MANAGEMENT if (management)