From patchwork Wed Jun 2 20:17:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobrovolsky X-Patchwork-Id: 1486867 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=KR1/cYDX; 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=P7q2L3ab; 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 4FwL403QMPz9sCD for ; Thu, 3 Jun 2021 06:20:00 +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:References:In-Reply-To: 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: List-Owner; bh=kunWHEJ472cD+6oSL0RWW2YX/CmdQLTBUVWZVv9EH3E=; b=KR1/cYDXQTWkBL w15t3p40LEODBDCmia+3WhkRHOdGiHjDdeuEUDm9X20wBlwDlSZy9nAOJODtsbhL2OQkY7UHzUIvX Y9l6Wbxz7DDOS6om4iFfjCIqQ2KPzSxz/TD5bOCNWcObXaoTtJqciI5vTAUezFb2b6TUC7EKH1abj YW8UxbEgTsGypIMq0VWWSvjfP/m+tkLcfCgXvKsxsjc82nYlZgHQroFo1hPBD/Zg/7fPopQ9yv1I8 QMyo9unbQAT0Y3JdP17AnEceDwpT0N6OZd8dT0Z1heRDFjQZx4KJPHF/giB1DXohpnXWIAidjJoYV +Ege14cQXSZhu4mqFnMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loXJk-0068Bf-Ci; Wed, 02 Jun 2021 20:18:20 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loXJg-0068A2-Vn for openwrt-devel@lists.openwrt.org; Wed, 02 Jun 2021 20:18:18 +0000 Received: by mail-wm1-x333.google.com with SMTP id b145-20020a1c80970000b029019c8c824054so4510882wmd.5 for ; Wed, 02 Jun 2021 13:18:16 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=VInd11Y1gRWXi9T5Us3DE+bnfJedsABdD5J7XbGmWIk=; b=P7q2L3abR0NrMiOXmaRPd78DIF0z50NCmRajyGQoGIry0KJJjh+nCHfBAfTNo4WdTc /IYv0IKnJqIvd1nE3O2Xji57cftz2E6PfPH1oC6vRsg1z7GxXP9v5IHwfeDm4cWbVlFL PyTUsQ/Mz/XdDtoGBi0WPuDSKTc7KeECQN3/mxQfZcmsVOhNFyZm937i454D8tVl+fjF O6RXMaIp3E93Qp4uUFSs3seF8cFhxHCzBs0870mKcxDGCcX/nAhawcbCVVsu/bxAMG1m ZJacgoCCiyKKPKe6NgqSRRw7O8jiaHwRdLhz85iq/8WIW3yaljnABU/4vt6r53f0OEGz 961w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VInd11Y1gRWXi9T5Us3DE+bnfJedsABdD5J7XbGmWIk=; b=tUKQ5w/Nx4wKSArPnmOHOrMwoU2gVpiafT19xgvq44Wy5hkjfAJjSk7uHKBlJLMz9f 2ouX20EMNxu0w2BhN+DMlHwllBgWBqf4cfZY+lNYA7XHMedPsc7GEYumTFPtm/9ExjNE NQFTN0KRkiyfuyuNiLBdpScF9XhjruYw6c1mt52ew54BrrqiNTYh0jl7ga15cd/pYr1g 3oJkWRUSi/ezFIMBDiRfj5furcC9BCiXDyL4aMTRotBPfhuDhUzXoQe/vMg/4vlu1j5X i4K4tYucQm63q+7U2GbdFptujtz2VL5V4mgPMzZhtGCyyosd5wUTgLi9aUwBmetB2nPG Izbw== X-Gm-Message-State: AOAM531akwOLIMn1BUjzm2QfC2RjPsY8u/Xmff3QuWSngO1E1de22z/v 50frVICWQ/SDsk6yUGSh3AEPgo4ePlM= X-Google-Smtp-Source: ABdhPJwzXZqvYxbQW78+pCV0aZ5YIleak4qr/Ut+5r1e3/kSF9k/wHrpHfz9mn1SBk+m9y3s8JuLlA== X-Received: by 2002:a7b:c152:: with SMTP id z18mr33300417wmi.136.1622665095007; Wed, 02 Jun 2021 13:18:15 -0700 (PDT) Received: from localhost.localdomain ([176.195.60.126]) by smtp.gmail.com with ESMTPSA id o129sm3640502wmo.22.2021.06.02.13.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 13:18:14 -0700 (PDT) From: Alexey Dobrovolsky To: openwrt-devel@lists.openwrt.org Cc: Alexey Dobrovolsky Subject: [PATCH v2] busybox: sysntpd: add trigger to reload server Date: Wed, 2 Jun 2021 23:17:42 +0300 Message-Id: <20210602201742.3306-1-dobrovolskiy.alexey@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210529233909.1673-1-dobrovolskiy.alexey@gmail.com> References: <20210529233909.1673-1-dobrovolskiy.alexey@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_131817_101191_EB79D88E X-CRM114-Status: GOOD ( 12.48 ) 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 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:333 listed in] [list.dnswl.org] 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.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 --- Notes: Changes since v1: * variables are not sorted alphabetically 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..48d17b9992 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 script name use_dhcp enable_server interface 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 }