From patchwork Tue Jan 10 08:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1723835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.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=qrrN1SCe; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NrkDn6Nmdz23g8 for ; Tue, 10 Jan 2023 19:16:57 +1100 (AEDT) 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=/V3o4xnvF1kGrYOSCcethP661t7qm/RQUaSRzIbhCkE=; b=qrrN1SCehdRZj8 qynX/i3UE8cjkrg8sbQKXLEX9bUxKdcm8UZ1/aCLtpUWfH90+ICu7je4UpIA98zc4GcNXekHnHBDS qRIxPE3a+rbn4AMytSsnI/uEQKnoDI9553VfgJ+TT0SGwzsaA0UU+f79lXWfzT2YdVYGTwFcPOGoK 0gz95KcCrfG0pNLwPl5NFRG9TfMdbSrD5DMoF1c+51yvt8CGDchjhPqnM08hBr4i9YfIhwuz/nJhx 5q/ySRdY51D6QvPYhWOkH3aWoeCgUgdUXTtINUGgk11dLvNzZfogt8tyzlSTih64lBghIk/MpXzVk DxSmriQQKGeoYQkBKZzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pF9lC-005k5v-St; Tue, 10 Jan 2023 08:13:31 +0000 Received: from mxout70.expurgate.net ([91.198.224.70]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pF9l9-005k3d-7k for openwrt-devel@lists.openwrt.org; Tue, 10 Jan 2023 08:13:28 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1pF9l2-000GOX-Gr; Tue, 10 Jan 2023 09:13:20 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pF9l1-0009sD-Tl; Tue, 10 Jan 2023 09:13:19 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 8FDFB240049; Tue, 10 Jan 2023 09:13:19 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 2FF5D240040; Tue, 10 Jan 2023 09:13:19 +0100 (CET) Received: from localhost.localdomain (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id B53C62A29C; Tue, 10 Jan 2023 09:13:18 +0100 (CET) From: Florian Eckert To: nbd@nbd.name, hauke@hauke-m.de Cc: Eckert.Florian@googlemail.com, openwrt-devel@lists.openwrt.org Subject: [PATCH] netifd: add debug options to uci Date: Tue, 10 Jan 2023 09:13:15 +0100 Message-ID: <20230110081315.10834-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.30.2 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: clean X-purgate-type: clean X-purgate-ID: 151534::1673338400-47FF8EE8-DFF44257/0/0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_001327_465318_1D711CF3 X-CRM114-Status: GOOD ( 14.14 ) X-Spam-Score: -0.7 (/) 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: To simplify netifd development, the logging and debugging options should be configured via uci, so we could set this also during boot. New uci config options in '/etc/config/network': config globals 'globals' option mask '1' option level '3' Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.198.224.70 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 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 To simplify netifd development, the logging and debugging options should be configured via uci, so we could set this also during boot. New uci config options in '/etc/config/network': config globals 'globals' option mask '1' option level '3' The following options are available for the individual uci options and are given when the service is started. Option 'mask': This option specifies which messages are output on the stderr. * SYSTEM = 0 * DEVICE = 1 * INTERFACE = 2 * WIRELESS = 3 In order for the log messages to also appear in the syslog, the output of the stderr must be redirected by the netifd. Option 'level': * L_CRIT = 0 * L_WARNING = 1 * L_NOTICE = 2 * L_INFO = 3 * L_DEBUG = 4 With this option the loglevel of the netifd can be changed. If nothing is specified, the level is set to 'notice'. Signed-off-by: Florian Eckert --- .../network/config/netifd/files/etc/init.d/network | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network index dc208c4ce0..ffdf470e10 100755 --- a/package/network/config/netifd/files/etc/init.d/network +++ b/package/network/config/netifd/files/etc/init.d/network @@ -15,8 +15,19 @@ init_switch() { start_service() { init_switch + local mask level debug + + config_load network + config_get level "globals" level + config_get mask "globals" mask + procd_open_instance procd_set_param command /sbin/netifd + [ -z "${level}" ] || procd_append_param command -l "$level" + [ -z "${mask}" ] || { + procd_append_param command -d "$mask" + procd_set_param stderr 1 + } procd_set_param respawn procd_set_param watch network.interface [ -e /proc/sys/kernel/core_pattern ] && {