From patchwork Mon Jan 30 18:57:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 1734338 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=dxP+9vnw; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=lm84jQu6; 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 4P5HcV1mRSz23hS for ; Tue, 31 Jan 2023 06:02:33 +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=j/Z4FB08KWrDYMhua9DMa2ixD4DrPPFuSF0t9CamPVg=; b=dxP+9vnwzJU1bl FDqZXH+jHS0DIWrArz9ndQDmgz5BB0uHhqPxcnaY+8RKyTHrImuuRbxGLmQmYVlR+rfGO6RGOc6gF ThTsH5mKga2Gx9G9NFjt7M/MjmZ/13t/P/AkualIZ9ji2tisLO8Sgu82DE5IYdI85OTtzg8sLJ6dC WH3VjdgSD3DC3npe3jaS8pUWdXv+9iccOWt8wyGkrsc0KfUtOdjk2H+mE1kfqZMzFQFMYUFmS1dIh 8LGavbk96cWSjFg2ZRrK1sqGMmDsuDxuiVIwtoclGoWQs+QTfRS62ad/by+rUPYpLUSZelkcRdNmL 6752EU+jR8bDwbwBpyYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMZM0-0058Oc-Sk; Mon, 30 Jan 2023 18:58:09 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMZLu-0058O7-Ve for openwrt-devel@lists.openwrt.org; Mon, 30 Jan 2023 18:58:04 +0000 Received: by mail-ej1-x632.google.com with SMTP id me3so34649589ejb.7 for ; Mon, 30 Jan 2023 10:58:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nQumuA8COlDyVX4txQXVFuJP2MWmW4U37lAshaUPFK4=; b=lm84jQu6hCSq73mTUE74zLjVcdXN+iFT7Oh9gbQ2UsVhVJl//98Wp2hbkX5suxDssX dV4Wpek0xVG2mMpG6Zf+8NPwHePZjtXwqCgNrdfdSCTLJdfaPcoLzXkHsVaO4EEyQl7w HtrGehlrw2Xd068jWtaIR4wVssIwf8tWy3seThZJCAmtSqfSnMctJfoKFwHVkIV8lHEO QXx+74h6AsdCsq6t+uRitbi4fibM9OkNTaJuVI5jgexh9p3/MgnTNxnMoaPbJYFtiqly 3C4b3sT15UU+my6cfBRyLyoqdse4qiW09mN9OqFrW4fFN7n/SrVf58Yc6cGjNbYMSMFJ k2gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nQumuA8COlDyVX4txQXVFuJP2MWmW4U37lAshaUPFK4=; b=1NE2WSw259TmyYzEVn2aVbZsNTLP42D3+HMzD2b1hncZ+KIAAetmlStbEdSuY5HFN7 Rkjq0M5ODt2xCxyOZDv/ZB58ucioiYqDp5q/uL08Q1UCwQc4ZTB9chWGJoyVuj8Q3MLG ed98LPPG40f3onAEfig6MNDEc6TRNGi9agg/5zr1TSTJC8UxKa15BOtq8loZWRqEu69k 3PGE7cH2rIMAxwOvm/HaPNOgWLXoD76TNiBbZWynKKpyFrmeyNpsjXJnJfH2TCgZftiU EdGzcwNY2tVeSG+0AHtd5fYjwadxkBX/5NEGEkskpeNu2UhaJXRwK2ZqR6yU/edhUirD N/nw== X-Gm-Message-State: AO0yUKXaeHDxcJf1bRT/sDIY8wet9PCZgMnqA95oBJbIU8ZQWbJ90I39 151KhE38v1++Dhsw43Zg25qKI+FeYHs= X-Google-Smtp-Source: AK7set80GI7HM+mBppNWKtpfHvhUi4+pYPm7WEDwqUqLPSdqvsarUOfaZjg9UgISpTAGXtSFkdGi8A== X-Received: by 2002:a17:907:7671:b0:878:60da:1f63 with SMTP id kk17-20020a170907767100b0087860da1f63mr18125209ejc.43.1675105080472; Mon, 30 Jan 2023 10:58:00 -0800 (PST) Received: from bcbook.internal (a89-182-217-236.net-htp.de. [89.182.217.236]) by smtp.gmail.com with ESMTPSA id gz2-20020a170907a04200b0087bdc4a46c0sm5571895ejc.19.2023.01.30.10.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 10:57:59 -0800 (PST) From: Andre Heider To: openwrt-devel@lists.openwrt.org Cc: Olcay Korkmaz Subject: [PATCH iwinfo] nl80211: restore iterating over all devices in nl80211_phy2ifname() Date: Mon, 30 Jan 2023 19:57:57 +0100 Message-Id: <20230130185757.9512-1-a.heider@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230130_105803_033530_121F7804 X-CRM114-Status: UNSURE ( 8.08 ) X-CRM114-Notice: Please train this message. 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: This reverts to the earlier behaviour, because: * phys can be renamed, which breaks hardcoding "phy%d" * /sys/class/ieee80211/*/device can return networks of other phys, since "device" is a symlink wh [...] 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:632 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [a.heider[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 This reverts to the earlier behaviour, because: * phys can be renamed, which breaks hardcoding "phy%d" * /sys/class/ieee80211/*/device can return networks of other phys, since "device" is a symlink which can have multiple phys The earlier behaviour fixes both points. Fixes: 6194aaf0 "nl80211: simplify iterating over phy's devices" Fixes: #11902 Signed-off-by: Andre Heider Tested-by: Olcay Korkmaz --- iwinfo_nl80211.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 5bc2f51..50bb8f0 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -825,13 +825,15 @@ static char * nl80211_phy2ifname(const char *ifname) memset(nif, 0, sizeof(nif)); - snprintf(buffer, sizeof(buffer), - "/sys/class/ieee80211/phy%d/device/net", phyidx); - - if ((d = opendir(buffer)) != NULL) + if ((d = opendir("/sys/class/net")) != NULL) { while ((e = readdir(d)) != NULL) { + snprintf(buffer, sizeof(buffer), + "/sys/class/net/%s/phy80211/index", e->d_name); + if (nl80211_readint(buffer) != phyidx) + continue; + snprintf(buffer, sizeof(buffer), "/sys/class/net/%s/ifindex", e->d_name); cifidx = nl80211_readint(buffer);