From patchwork Thu Dec 17 09:35:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1417557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=IfheeYIs; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxRkG0rPcz9sW0 for ; Thu, 17 Dec 2020 20:37:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=/89Kh5acX9tuY0DbtU8bKriKJw0RzAEuq6VuclFT2jI=; b=IfheeYIsU5LO5VtaM3IqWljQ1q t9Y4N8y1nSf80dzfjpxnfTOa8VNEltwHo9K/BbpSCnrbYeOk3YdNMPBBJOP9LiDntQ9iDy/91qLyY HMuZpmBleNMWIVJ1eGMKB7ChwGb6Wv0L/SD9kcSyDg54horWzA2B1OnXcVErYw36nUm5ZkS3g2DVu phEgyj0CA8z7fjDr/jk70iiHMXTSwq9RZF84MivxJY2OI2jyEgzPxggcEiT5VF2DdlzZgQ9uT3UqE Ve9HIBJwYShv1VMDORuCuZcVJjvyHnVoCwzzUHTpl9E6FaPWyza90T02QVBdvYr0bgYXQOqQFF8xv 5Hi+EpYg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphc-0002B4-Pp; Thu, 17 Dec 2020 09:36:04 +0000 Received: from mxout70.expurgate.net ([194.37.255.70]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphK-00024C-V2 for openwrt-devel@lists.openwrt.org; Thu, 17 Dec 2020 09:35:50 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kpphJ-0008Eq-7p; Thu, 17 Dec 2020 10:35:45 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90) (envelope-from ) id 1kpphI-0003xg-6m; Thu, 17 Dec 2020 10:35:44 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id D4E87240041; Thu, 17 Dec 2020 10:35:43 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 84C1D240040; Thu, 17 Dec 2020 10:35:43 +0100 (CET) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id D97B5207F4; Thu, 17 Dec 2020 10:35:42 +0100 (CET) From: Florian Eckert To: daniel@makrotopia.org, john@phrozen.org Subject: [PATCH v2 0/5] ubus: extend the service object with a restart method Date: Thu, 17 Dec 2020 10:35:32 +0100 Message-ID: <20201217093537.22653-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-type: clean X-purgate-ID: 151534::1608197744-0000767E-F9AC8C31/0/0 X-purgate: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_043547_849236_DD5A6C8F X-CRM114-Status: GOOD ( 14.17 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [194.37.255.70 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [194.37.255.70 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This patchset adds the new method "restart" to the ubus service object. This method is called on a service restart, if it is managed by procd. I have noticed that during a firewall restart the mwan3 rules have all disappeared and I have to restart my service as well. I did not expected this. So that I don't have to do this extra step, an event should be generated during a service restart, so other service could subscribe to this event. All services that want to react to this event can create a callback script. The same applies to a config change. As an example I used the firewall here, because I came across the problem here. So if the firewall gets restart, then a event es generated. Full discussion hat taken place at this URL. https://github.com/openwrt/packages/pull/13931 A pull request is already staged to use this new funcionality. https://github.com/openwrt/packages/pull/14215 v2: - As requested by John Chrispin, I wrapped the new `_procd_add_service_trigger` with the function `_procd_add_restart_service_trigger` to make it a one-liner to use this functionality. Florian Eckert (5): procd: add restart ubus call base-files: add restart function wrapper firewall: fix whitespace firewall: use new restart_service callback procd: add api wrapper package/base-files/files/etc/rc.common | 13 ++++ .../config/firewall/files/firewall.init | 4 +- package/system/procd/files/procd.sh | 33 ++++++++++ .../patches/0010-add-restart-event.patch | 64 +++++++++++++++++++ 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 package/system/procd/patches/0010-add-restart-event.patch