From patchwork Sat Oct 8 15:41:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 679910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3srrMp2g6Pz9s36 for ; Sun, 9 Oct 2016 02:46:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b=upO1pTgk; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bstlF-0005Zd-VO; Sat, 08 Oct 2016 15:42:05 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bstlB-0005Yu-0O for lede-dev@lists.infradead.org; Sat, 08 Oct 2016 15:42:02 +0000 Received: by mail-wm0-x241.google.com with SMTP id 123so7327133wmb.3 for ; Sat, 08 Oct 2016 08:41:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=AwDEzfiVyiy03q335b7dc+Bg+yElaGhCxeSSvhWMWVM=; b=upO1pTgkF2W+ek1eukSOQVtYf5vXWHv1rLDp821eN6dfcwV5wtrVLoMQYGiklEKLFQ HJDUCHExLrqDeudrfQhlylf1TU4O501qGkQFkXF/JKqR7/nImtHgYiVdHw4et8XsXMFw dTRk41mJ5AczUm/2Vj8eFZz7BI1+2QVcfveUhyyGQmYTe2Fsl6CQC8LdT0EX5RFNaTo6 PtMYeW2124ne4Syo5chK9fPAVygucipwB0MwowNrrONe+pgAM+1uIRfDB5BiRx3VBAVw 6M7uXgnSrR3Ju3SwHBpz+W9bi7SuWZhxJ5i5qaeGYVCVjUhUpqvG4wY1ygqwAeA5Z06R 9X0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=AwDEzfiVyiy03q335b7dc+Bg+yElaGhCxeSSvhWMWVM=; b=ZQjNxHxAQc4oRoDjB7HnlvaNiLHJQCvhszpvPXgXG+sqaVgO0qkAo/xQm1GKR/71hp iZiGUtc605+Tw8r8iUFLDHUvjZbJVvqaXsu7pZZfDijoskeLfldnGfq8Bs4KN0xog1Dx vb7/1+Q6rXE5zG1rkt5n2p/JPwUIgfZYOPs+EZvZL54yHDBGKVg5GNLmDixn081q8e9S T7VXamHZ/ZaJbNNioAR9mUIR7sn2iI1tOy7gbe/kphU3FY2sN1UhTCq8agOIhk/X26fu yzm9U4Wj//Fu7wx9QGy9qHS/87YhnjJskjml+BByHERC/QOWBOC97IV4vSCKwH4+vWge IOFQ== X-Gm-Message-State: AA6/9Rn9QJpkn9G3yzOf7R8/1WMp+sWzhBvNPDcP1tPb0wxkPpqlm/ZFzf7xUcqipy/Qpg== X-Received: by 10.28.138.140 with SMTP id m134mr3170882wmd.92.1475941297142; Sat, 08 Oct 2016 08:41:37 -0700 (PDT) Received: from debian64.daheim (p5B2E698F.dip0.t-ipconnect.de. [91.46.105.143]) by smtp.gmail.com with ESMTPSA id n131sm8902237wmd.3.2016.10.08.08.41.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Oct 2016 08:41:36 -0700 (PDT) From: Christian Lamparter X-Google-Original-From: Christian Lamparter Received: from localhost.daheim ([127.0.0.1] helo=debian64.localnet) by debian64.daheim with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.87) (envelope-from ) id 1bstkl-0002da-EN; Sat, 08 Oct 2016 17:41:35 +0200 To: Matthias Schiffer Date: Sat, 08 Oct 2016 17:41:35 +0200 Message-ID: <4038942.jtTkmrb9Ac@debian64> User-Agent: KMail/5.2.3 (Linux/4.8.0-wt+; KDE/5.26.0; x86_64; ; ) In-Reply-To: <93bf7bf8-f598-8280-84cc-d5a30af9c661@universe-factory.net> References: <603ea97d4ad981176885397894336312c2195597.1475863407.git.chunkeey@gmail.com> <93bf7bf8-f598-8280-84cc-d5a30af9c661@universe-factory.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161008_084201_288209_B2FA2FCC X-CRM114-Status: GOOD ( 18.92 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (chunkeey[at]googlemail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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 Subject: Re: [LEDE-DEV] [PATCH v1 1/2] base-files, mac80211, broadcom-wl: plug-and-play wifi detection X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sven Eckelmann , Jo-Philipp Wich , Martin Blumenstingl , lede-dev@lists.infradead.org, Mathias Kresin , Christian Lamparter Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello, On Friday, October 7, 2016 8:29:30 PM CEST Matthias Schiffer wrote: > On 10/07/2016 08:10 PM, Christian Lamparter wrote: > > Currently, the wifi detection script is executed as part of > > the (early) boot process. Pluggable wifi USB devices, which > > are inserted at a later time are not automatically > > detected and therefore they don't show up in LuCI. > > > > A user has to deal with wifi detection manually, or restart > > the router. > > > > [...] > > --- > > We would like to hear, if these changes work with broadcom-wl. > > (Felix removed the hostap, so this isn't included anymore). > > > > trap and lock are part of the default busybox setup. > > Hi, > it would be great to remove the direct write of /etc/config/wireless > completely, as it won't lock against other users of UCI that modify the > wireless config. IMO, it should just use UCI to modify the configuration as > everything else does. Well, What's the situation with ECE and configd? I didn't want to touch it since you plan to move away from the config files and replace them with json. Anyway, I attached two RFCs (one for broadcom, the other mac80211) that replaces the code with uci calls. One issue is that there's no longer the "# REMOVE THIS LINE TO ENABLE WIFI:" line and people might overlook the "disabled 1" setting. Note: the "> /dev/null" for uci calls were added just in case someone still has the old /etc/init.d/boot and to not write garbage into /e/c/wireless. Note2: I've also changed the "plug-and-play wifi" patch and removed the /tmp/wireless.tmp step. But we still need proper locking. (That said, I would like to move the locking to the mac80211.sh / broadcom.sh detect functions, is everyone fine with that?) --- mac80211: use uci to generate wireless config file Previously, wifi detect simply dumped its generated wireless configuration out to STDOUT. A second step was needed to append the configuration to /etc/config/wireless (or create it, if it didn't exist). With this patch, The wifi detection script will now use uci to update the wireless configuration directly. Signed-off-by: Christian Lamparter --- diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -92,7 +92,7 @@ detect_mac80211() { htmode="VHT80" } - [ -n $htmode ] && append ht_capab " option htmode $htmode" "$N" + [ -n $htmode ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode" if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then path="$(readlink -f /sys/class/ieee80211/${dev}/device)" @@ -104,30 +104,30 @@ detect_mac80211() { case "$path" in platform*/pci*) path="${path##platform/}";; esac - dev_id=" option path '$path'" + dev_id="set wireless.radio${devidx}.path='$path'" else - dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)" + dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" fi - cat < /dev/null <<-EOF + set wireless.radio${devidx}=wifi-device + set wireless.radio${devidx}.type=mac80211 + set wireless.radio${devidx}.channel=${channel} + set wireless.radio${devidx}.hwmode=11${mode_band} + ${dev_id} + ${ht_capab} + set wireless.radio${devidx}.disabled=1 + + add wireless wifi-iface + set wireless.@wifi-iface[-1]=wifi-iface + set wireless.@wifi-iface[-1].device=radio${devidx} + set wireless.@wifi-iface[-1].network=lan + set wireless.@wifi-iface[-1].mode=ap + set wireless.@wifi-iface[-1].ssid=LEDE + set wireless.@wifi-iface[-1].encryption=none EOF - devidx=$(($devidx + 1)) - done -} + uci commit &> /dev/null + devidx=$(($devidx + 1)) + done +} --- broadcom-wl: use uci to generate wireless config file Previously, wifi detect simply dumped its generated wireless configuration out to STDOUT. A second step was needed to append the configuration to /etc/config/wireless (or create it, if it didn't exist). With this patch, The wifi detection script will now use uci to update the wireless configuration directly. Signed-off-by: Christian Lamparter --- diff --git a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh --- a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh +++ b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh @@ -456,22 +456,23 @@ detect_broadcom() { config_get type wl${i} type [ "$type" = broadcom ] && continue channel=`wlc ifname wl${i} channel` - cat < /dev/null <<-EOF + set wireless.wl${i}=wifi-device + set wireless.wl${i}.type=broadcom + set wireless.wl${i}.channel=${channel:-11} + set wireless.wl${i}.txantenna=3 + set wireless.wl${i}.rxantenna=3 + set wireless.wl${i}.disabled=1 + + add wireless wifi-iface + set wireless.@wifi-iface[-1]=wifi-iface + set wireless.@wifi-iface[-1].device=wl${i} + set wireless.@wifi-iface[-1].network=lan + set wireless.@wifi-iface[-1].mode=ap + set wireless.@wifi-iface[-1].ssid=Lede${i#0} + set wireless.@wifi-iface[-1].encryption=none EOF + uci commit &> /dev/null done }