From patchwork Thu Sep 5 12:42:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1981233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=aYUxDXKJ; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzzZW5Tsbz1yfv for ; Thu, 5 Sep 2024 22:44:19 +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=MHz53lup7mI0JoW6rwL08QFsHz1HGcRx+s90nwgifDo=; b=aYUxDXKJ5O9h6W /qg0sUh6NEylIS65H/EdMwkZ0W63XP0Cj+JNmXDvdMiswTFlS4kYjGYyT3w5s2qDVl+eN8RcOK7SD lrvMsx41FeqRyiB2yZ4fPrWmuRmvrkYaJwpcCmoB6krymH84+BeFVG90ExJ67lXi+cNYhlMfwMSYM GmhTRUTlVJiE5UVDZ5h0VE+tyTRTu9ZnR3Js8xFkzs//MPI3p+96rKvq2DGvOFFgcGubZn+ZTOfnq ViPQrczTvmALKswqJ8TFtwmXLLzzBnx/q6C9vxgQL2t+qeNrZUb0NYDNxSLnE0llRf710aAtMhklU JWdeBNmhQAUAH8WE6CEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smBov-00000008N10-1xrg; Thu, 05 Sep 2024 12:42:41 +0000 Received: from mxout70.expurgate.net ([194.37.255.70]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smBoo-00000008Mw3-4A47 for openwrt-devel@lists.openwrt.org; Thu, 05 Sep 2024 12:42:37 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1smBoh-004JVV-TB; Thu, 05 Sep 2024 14:42:27 +0200 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 1smBoh-004deW-4B; Thu, 05 Sep 2024 14:42:27 +0200 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id CB74F240040; Thu, 5 Sep 2024 14:42:26 +0200 (CEST) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id C379A240036; Thu, 5 Sep 2024 14:42:26 +0200 (CEST) Received: from localhost.localdomain (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 5453F39F7E; Thu, 5 Sep 2024 14:42:26 +0200 (CEST) From: Florian Eckert To: nbd@nbd.name Cc: Eckert.Florian@googlemail.com, leon@georgemail.eu, openwrt-devel@lists.openwrt.org Subject: [PATCH 1/2] base-files: move config_generate to preinit Date: Thu, 5 Sep 2024 14:42:17 +0200 Message-ID: <20240905124218.703140-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,URIBL_ZEN_BLOCKED_OPENDNS 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::1725540147-1E4DC522-B6386D2C/0/0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_054235_207961_C19FDCF6 X-CRM114-Status: GOOD ( 18.86 ) X-Spam-Score: -1.9 (-) 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: The mutex file via '/tmp/.config_pending' should prevent the command '/sbin/wifi config' from being called in the ieee80211 hotplug when loading the kernel modules [1]. Since the file '/etc/board.json [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [194.37.255.70 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [194.37.255.70 listed in sa-trusted.bondedsender.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [194.37.255.70 listed in list.dnswl.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [194.37.255.70 listed in bl.score.senderscore.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 The mutex file via '/tmp/.config_pending' should prevent the command '/sbin/wifi config' from being called in the ieee80211 hotplug when loading the kernel modules [1]. Since the file '/etc/board.json' does not yet exist and could be incomplete. The '/etc/board.json' file is modified in the '/sbin/wifi config' script. This is only generated during the first boot when '/bin/config_generate' is called. This whole handling is unclean. Therefore the creation of the default configuration (/etc/config/network and /etc/config/system) and the '/etc/board.json' via '/sbin/config_generate' is moved to the preinit phase after the rootfile system has been mounted The advantage now is that on an ieee80211 hotplug event, the '/etc/board.json' is already present which simplifies the whole thing. [1] https://github.com/openwrt/openwrt/blob/main/package/network/config/wifi-scripts/files/etc/hotplug.d/ieee80211/10-wifi-detect Fixes: b993a00b82b1 ("base-files: fix duplicate wifi radio sections when using phy renaming") Signed-off-by: Florian Eckert --- package/base-files/files/etc/init.d/boot | 15 +++++---------- .../files/lib/preinit/82_config_generate | 12 ++++++++++++ .../files/etc/hotplug.d/ieee80211/10-wifi-detect | 2 +- .../network/config/wifi-scripts/files/sbin/wifi | 1 - 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 package/base-files/files/lib/preinit/82_config_generate diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index d17754d087..4278cd99bc 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -39,20 +39,15 @@ boot() { grep -q pstore /proc/filesystems && /bin/mount -o noatime -t pstore pstore /sys/fs/pstore [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe - touch /tmp/.config_pending - /sbin/kmodloader + # update wifi config before additional ieee80211 hotplug events + # get executed because of '/sbin/kmodloader' kmod loading. + [ -f /etc/board.json ] && /sbin/wifi config - [ ! -f /etc/config/wireless ] && { - # compat for bcm47xx and mvebu - sleep 1 - } + /sbin/kmodloader - /bin/config_generate - rm -f /tmp/.config_pending - /sbin/wifi config uci_apply_defaults sync - + # temporary hack until configd exists /sbin/reload_config } diff --git a/package/base-files/files/lib/preinit/82_config_generate b/package/base-files/files/lib/preinit/82_config_generate new file mode 100644 index 0000000000..61b0d137b1 --- /dev/null +++ b/package/base-files/files/lib/preinit/82_config_generate @@ -0,0 +1,12 @@ +do_config_generate() { + [ -f /etc/board.json ] || { + echo "- generating board file -" + /bin/board_detect /tmp/board.json + mv /tmp/board.json /etc/board.json + + /bin/config_generate > /dev/null + } +} + +boot_hook_add preinit_main do_config_generate +boot_hook_add initramfs do_config_generate diff --git a/package/network/config/wifi-scripts/files/etc/hotplug.d/ieee80211/10-wifi-detect b/package/network/config/wifi-scripts/files/etc/hotplug.d/ieee80211/10-wifi-detect index b865552661..dc1b657af8 100644 --- a/package/network/config/wifi-scripts/files/etc/hotplug.d/ieee80211/10-wifi-detect +++ b/package/network/config/wifi-scripts/files/etc/hotplug.d/ieee80211/10-wifi-detect @@ -1,5 +1,5 @@ #!/bin/sh [ "${ACTION}" = "add" ] && { - /sbin/wifi config + [ -f /etc/board.json ] && /sbin/wifi config } diff --git a/package/network/config/wifi-scripts/files/sbin/wifi b/package/network/config/wifi-scripts/files/sbin/wifi index f937dba7e6..e4554c451d 100755 --- a/package/network/config/wifi-scripts/files/sbin/wifi +++ b/package/network/config/wifi-scripts/files/sbin/wifi @@ -175,7 +175,6 @@ wifi_detect_notice() { } wifi_config() { - [ -e /tmp/.config_pending ] && return ucode /usr/share/hostap/wifi-detect.uc [ ! -f /etc/config/wireless ] && touch /etc/config/wireless ucode /lib/wifi/mac80211.uc | uci -q batch