| Message ID | CAMcVZfs+oe9_uyjaYgupRhYw-BAFfi6PdbRkqjxV6EXAqWzE2Q@mail.gmail.com |
|---|---|
| State | New |
| Headers | show
Return-Path:
<openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org>
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=QDOVlqoM;
dkim=fail reason="signature verification failed" (2048-bit key;
unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
header.s=20230601 header.b=iFi5bRbE;
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 4ZcZSP5WdSz1yJH
for <incoming@patchwork.ozlabs.org>; Wed, 16 Apr 2025 05:47:33 +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:To:Subject:Message-ID:Date:From:
MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:
References:List-Owner; bh=fPYvPUK9GIOkc+AzRDcePeUZkTiAHNUFqeEPFroBfv0=; b=QDO
VlqoM1pz+BbK1LBgZDPy51Dsgwv03ua60m3OzhrcH4YuGkJT3c+SdLCoXuNYjlc4ufTGiDtcUJ9l8
kokHexSNL9OAtmuNA5g+ONc12O0AssXaD3Yp3PnN22uMXN0D3BZb6QOiNzYiXVBnMF2nbDoDIsH7l
vPvcLVaejR46AFTg4uBbJv9UL39+3fmM9BOaXld+48dIhD8fioHAADpCm+ja6mYdAJeRbBF6iKopi
uCx63acvcH9Ep67refP6xkdhVMgpYntcbneVaVC5eCpG6cbGoUSM0pQ1o+xqfYdNtGL7pCEq+D9qN
Qgxjte6DoNNnlBpU5kx32sF7cMs/qeQ==;
Received: from localhost ([::1] helo=bombadil.infradead.org)
by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))
id 1u4mEJ-00000006vu5-3X6t;
Tue, 15 Apr 2025 19:45:59 +0000
Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535])
by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))
id 1u4mEH-00000006vth-0LAD
for openwrt-devel@lists.openwrt.org;
Tue, 15 Apr 2025 19:45:58 +0000
Received: by mail-ed1-x535.google.com with SMTP id
4fb4d7f45d1cf-5e6f4b3ebe5so10456193a12.0
for <openwrt-devel@lists.openwrt.org>;
Tue, 15 Apr 2025 12:45:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1744746355; x=1745351155;
darn=lists.openwrt.org;
h=content-transfer-encoding:to:subject:message-id:date:from
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=qRh21ve/D16+ozANOsQL12Nc2Uizpby1MpdDG7+1Ams=;
b=iFi5bRbEgD6/LaQ+4S8c6cppsZfkMVG4+rBq01JvpHwgNyjLHJlYOYrO2tbzOgIl41
rwU91Ouj7RPabSQ+l4y2AhhDny7lMK/AtRormNami9FP0Y+NaRf5XcPZIp/7/zAn/xas
cPaVXST20h7eQuHOYPtLIKj48wYhNw7Ev/Q4EW6UEC6xPUcXv1DRRQfCEuWELEtImjjD
y3DoNsO3JCF71tjMNI/jXD+aA67qOwC8fkXa58txEVqNA6xkA/sstoRe5DjsucOFiSNn
87oYjptcO9Rk1lAIIjIf6BYJW1wrLj5uh15hDwErsRAoNPopOpjvIbow3UzjUaReb+Lr
Sxvg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1744746355; x=1745351155;
h=content-transfer-encoding:to:subject:message-id:date:from
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=qRh21ve/D16+ozANOsQL12Nc2Uizpby1MpdDG7+1Ams=;
b=O0L8FK+C3DIdJoLaD5WLoYCPb0KD5TbBl79KL0If675CJFdoHr24wOyMNFJorXEJmT
vuCbiUe4FK7qcmOJsToIIWbtdYSNFhyK244I1R3oy/Xf6ykPOjoLi8WdkxqdLaVN76PV
wREjRU0I1SUflj9tniyZ3q5vb70yR3KOyefA/w40bcYjR3Alxxr3PiHgz5PJQJ548YGq
pUUSFuN6LsiNSXppTiZLBqpd+tCcQ1mGVnnEfRNjJORa+z09Fw1CQfB61O3uQW76GN2I
VDl8WdHPztBmuyRcQEuob8HgTH/G097OOJUZxe7nF7fMXJChWUR+5u1p6cRKZXq2MODP
20Nw==
X-Gm-Message-State: AOJu0YwJKH/2SoS4OkasT1siXlC/Bx/W+4/FPJ6rpLVyhnMJkp+St41H
t19LQlthyfk+pPNVEGzL8WIpNhK8iGxP5V8IS7YhwygIZvM0fjj71Fq1psVCS9R2AtQaPmC7+uD
iCAuHZwsBomEeWLvIDsgDTdjDz8DiyT09H+0=
X-Gm-Gg: ASbGncu/tYjGNVjhG3I+3JcqlJa1c2Qz02neOlsiIWcCt1/x10IFhqtT2JKaPIXx7pO
qPcpEaz8RFWttrjK94MlsY3dd1ENdVy8eq/QYUGJLnB5UTx3fqpSzRtYrT5ZFUOFAU1MIF9VqxG
mTTbbDYzbXYsR/Cj5+J91y
X-Google-Smtp-Source:
AGHT+IHr3rtuacwuGuBVlNN/CiTd68APG3EoHVdT2AB3Z8d/emJ0DAF/4gpVdVjOHhCl83WHqxC5r2La6ySbII7fhvs=
X-Received: by 2002:a05:6402:13c7:b0:5f4:5df6:83bc with SMTP id
4fb4d7f45d1cf-5f49a17695emr314260a12.5.1744746354715; Tue, 15 Apr 2025
12:45:54 -0700 (PDT)
MIME-Version: 1.0
From: Valeriy Kosikhin <vkosikhin@gmail.com>
Date: Tue, 15 Apr 2025 22:45:43 +0300
X-Gm-Features: ATxdqUG1qP8k3_LU4AXFO77g0B2bJA3L_dwmZiFGzyJDnIPnFwYFTn0F3NeBymY
Message-ID:
<CAMcVZfs+oe9_uyjaYgupRhYw-BAFfi6PdbRkqjxV6EXAqWzE2Q@mail.gmail.com>
Subject: [PATCH] package: libiwinfo: fix noise reading for radios sharing a
wiphy
To: openwrt-devel@lists.openwrt.org
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20250415_124557_119182_18FB34E1
X-CRM114-Status: GOOD ( 13.63 )
X-Spam-Score: -2.1 (--)
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: On some devices (e.g., the Banana Pi BPI-R4),
the driver registers
multiple radios under a single wiphy. As a result, the NL80211 survey dump
returns the same data set regardless of which interface is [...]
Content analysis details: (-2.1 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:535 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.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_AU Message has a valid DKIM or DK signature from
author's
domain
-0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from
envelope-from domain
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
provider
[vkosikhin(at)gmail.com]
X-BeenThere: openwrt-devel@lists.openwrt.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: OpenWrt Development List <openwrt-devel.lists.openwrt.org>
List-Unsubscribe: <https://lists.openwrt.org/mailman/options/openwrt-devel>,
<mailto:openwrt-devel-request@lists.openwrt.org?subject=unsubscribe>
List-Archive: <http://lists.openwrt.org/pipermail/openwrt-devel/>
List-Post: <mailto:openwrt-devel@lists.openwrt.org>
List-Help: <mailto:openwrt-devel-request@lists.openwrt.org?subject=help>
List-Subscribe: <https://lists.openwrt.org/mailman/listinfo/openwrt-devel>,
<mailto:openwrt-devel-request@lists.openwrt.org?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Sender: "openwrt-devel" <openwrt-devel-bounces@lists.openwrt.org>
Errors-To:
openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org
|
| Series |
package: libiwinfo: fix noise reading for radios sharing a wiphy
|
expand
|
diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index dc4ff93..c530a35 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -1660,7 +1660,11 @@ static int nl80211_get_signal(const char *ifname, int *buf) static int nl80211_get_noise_cb(struct nl_msg *msg, void *arg) { - int8_t *noise = arg; + struct { + int8_t *noise; + int *freq; + } *args = arg; + struct nlattr **tb = nl80211_parse(msg); struct nlattr *si[NL80211_SURVEY_INFO_MAX + 1];
On some devices (e.g., the Banana Pi BPI-R4), the driver registers multiple radios under a single wiphy. As a result, the NL80211 survey dump returns the same data set regardless of which interface is queried. Currently, libiwinfo determines the noise value by selecting the entry marked with the IN_USE flag. However, when multiple interfaces share a wiphy, several entries may simultaneously have this flag set. This causes libiwinfo to return the same noise value for all interfaces, typically corresponding to the highest frequency in use. This patch adds a frequency match check to ensure the noise value corresponds to the interface’s actual frequency. The existing IN_USE check is retained as a fallback. Signed-off-by: Valeriy Kosikhin <vkosikhin@gmail.com> --- iwinfo_nl80211.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) @@ -1676,22 +1680,33 @@ static int nl80211_get_noise_cb(struct nl_msg *msg, void *arg) tb[NL80211_ATTR_SURVEY_INFO], sp)) return NL_SKIP; - if (!si[NL80211_SURVEY_INFO_NOISE]) + if (!si[NL80211_SURVEY_INFO_NOISE] || !si[NL80211_SURVEY_INFO_FREQUENCY]) return NL_SKIP; - if (!*noise || si[NL80211_SURVEY_INFO_IN_USE]) - *noise = (int8_t)nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]); + if (!*args->noise || + (nla_get_u32(si[NL80211_SURVEY_INFO_FREQUENCY]) == *args->freq && + si[NL80211_SURVEY_INFO_IN_USE])) { + *args->noise = (int8_t)nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]); + } return NL_SKIP; } - static int nl80211_get_noise(const char *ifname, int *buf) { int8_t noise = 0; + int freq = 0; + + struct { + int8_t *noise; + int *freq; + } args = { .noise = &noise, .freq = &freq }; + + if (nl80211_get_frequency(ifname, &freq) < 0) + goto out; if (nl80211_request(ifname, NL80211_CMD_GET_SURVEY, NLM_F_DUMP, - nl80211_get_noise_cb, &noise)) + nl80211_get_noise_cb, &args)) goto out; *buf = noise;