From patchwork Sat May 29 23:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobrovolsky X-Patchwork-Id: 1485420 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=D7fwsuTZ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=aX+0KXKF; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FsynL2B0cz9sVv for ; Sun, 30 May 2021 09:44:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=xi3QtL9/fu04jHdkkm1/jPLyP/3uECNu5NKn38uIiYU=; b=D7fwsuTZP1ae5v e/bBJlQVh5EpRgtGDTMyWkJXJumQdZiGA9jFks7kKjszGtXpGwu/pFlv/B5aT5Y8f93gNXRq1yh5i WcniV8j7OzhvFnTM+Rp2hYuP+9p7qiAluLC66C9ci6XkiWvJmig63IwCms7TQYiFkx9zU0cNCBZt4 bDxJzlA1OalDA/qeFsY/ha4Y7oi99iiKAogY3yH59ruPbQUYgm8L/ZGk3ccI5A8qW1boUCZdUok7P dcY/pxXH+fd/6J7Co8ONRI6diCP14ixROckEfD2dLtq7ZPQO3wjJu6IGx/KCY1ovQG3TVHmzUrqdK l8pSOxJqr77zO0MsgUaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ln8Yn-008bBe-Il; Sat, 29 May 2021 23:40:05 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ln8Yi-008bB5-Kn for openwrt-devel@lists.openwrt.org; Sat, 29 May 2021 23:40:03 +0000 Received: by mail-ed1-x531.google.com with SMTP id r11so9069115edt.13 for ; Sat, 29 May 2021 16:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MgUdx4ZwU5LOAO1l/KPFo3Fyb2YcSofa2qP0o53qfBM=; b=aX+0KXKFHwPtKDbzXnkXVEKoD6NuIr5bLPt3d2ovouiJCslFFuhOli7gy1o3l0VDDP hwQJzXS1OIHChNlf3sofFBAWVVsA35hib7ASzn0lvepA0hVdEDxJEL/3TpvVzT4GMAlO xVvss+3QDOgRHxJrZDJS9m3nfe77z2l8VMQNBDikB9HMs6x9wv5GxlcmycknUu1prc3j AUO84DgOGafEHgvGwSKmfutQyQxgJYAeWl2cgP2Scqj7IPeyTBzYHq48bQ3j5x57qpr1 PnGxEc+sfudF2EZKInMNm14/TXQl4+vLY+gZ32UdIE1hgr8cytykpbVlFD8L+/erd0PL z/jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MgUdx4ZwU5LOAO1l/KPFo3Fyb2YcSofa2qP0o53qfBM=; b=U0rrISHcgphKhnh4heLKgDrWGwRDFytCZk2utPRNwoFDrFRjtDaTSKxXy6Li+a9rgf 7kC7iWvOjqNuwaWp0pVaxluUnH7hSR6lCPkIMi6OzPC0VRdNydE4FpZ/LxxUixbDXXPt Cxlyw8fpR4sY2XuNrYqJxGkBq5Xk0mhxbh9oYxuIG97xFXqkjfhBmBSyWhJ2bxIRCBNs tRFKD/tABikSBgxjOvwiZ167C3L+Fiikfk+K2xfROy5z21kPp9ZpHvqBW+yYXE5IrTRI D7wz5O9dC+FzIJLzT3uIuEtnFLgxbm8vieg5/bIPrm3QGyboZRl7YmLrPe4B0GeipJRo j3Sg== X-Gm-Message-State: AOAM5332VgPyS5WScA5VAn1VXFTohwimyao7UCKRs96sGb9ew0UGo7MD k1BUO8nGFpXGzu+AyWBcWIiMXOsTkyImNA== X-Google-Smtp-Source: ABdhPJwRey8FNo19nbnTMHzYoPimJZ0RksytkS82L6j/g31TqwywxHy7pGFrTL+biTt3FT1dtLRvkg== X-Received: by 2002:a05:6402:7d7:: with SMTP id u23mr17693299edy.196.1622331596171; Sat, 29 May 2021 16:39:56 -0700 (PDT) Received: from localhost.localdomain ([176.195.60.126]) by smtp.gmail.com with ESMTPSA id gz5sm2409365ejb.113.2021.05.29.16.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 May 2021 16:39:55 -0700 (PDT) From: Alexey Dobrovolsky To: openwrt-devel@lists.openwrt.org Cc: Alexey Dobrovolsky Subject: [PATCH] busybox: sysntpd: add trigger to reload server Date: Sun, 30 May 2021 02:39:09 +0300 Message-Id: <20210529233909.1673-1-dobrovolskiy.alexey@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210529_164000_707262_4A9BCF80 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", 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: sysntpd server becomes unavailable if the index of the bound interface changes. So let's add an interface trigger to reload sysntpd. This patch also adds the ability for the sysntpd script to handle uci interface name from configuration. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [dobrovolskiy.alexey[at]gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:531 listed in] [list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org sysntpd server becomes unavailable if the index of the bound interface changes. So let's add an interface trigger to reload sysntpd. This patch also adds the ability for the sysntpd script to handle uci interface name from configuration. Fixes: 4da60500ebd2 ("busybox: sysntpd: option to bind server to iface") Signed-off-by: Alexey Dobrovolsky --- package/utils/busybox/files/sysntpd | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/package/utils/busybox/files/sysntpd b/package/utils/busybox/files/sysntpd index c4c311c242..e1c9e0cdca 100755 --- a/package/utils/busybox/files/sysntpd +++ b/package/utils/busybox/files/sysntpd @@ -56,7 +56,14 @@ start_ntpd_instance() { procd_set_param command "$PROG" -n -N if [ "$enable_server" = "1" ]; then procd_append_param command -l - [ -n "$interface" ] && procd_append_param command -I $interface + [ -n "$interface" ] && { + local ifname + + network_get_device ifname "$interface" || \ + ifname="$interface" + procd_append_param command -I "$ifname" + procd_append_param netdev "$ifname" + } fi [ -x "$HOTPLUG_SCRIPT" ] && procd_append_param command -S "$HOTPLUG_SCRIPT" for peer in $server; do @@ -79,11 +86,12 @@ start_ntpd_instance() { } start_service() { + . /lib/functions/network.sh validate_ntp_section ntp start_ntpd_instance } service_triggers() { - local script name use_dhcp + local enable_server interface name script use_dhcp script=$(readlink -f "$initscript") name=$(basename ${script:-$initscript}) @@ -106,5 +114,17 @@ service_triggers() { fi } + config_get enable_server ntp enable_server + config_get interface ntp interface + + [ "$enable_server" = "1" ] && [ -n "$interface" ] && { + local ifname + + network_get_device ifname "$interface" || \ + ifname="$interface" + procd_add_interface_trigger "interface.*" "$ifname" \ + /etc/init.d/"$name" reload + } + procd_add_validation validate_ntp_section }