Zong-Zhe Yang [Thu, 7 Oct 2021 08:56:15 +0000 (16:56 +0800)]
iw: add set sar_specs command
Add set sar_specs command
usage: iw <phy> set sar_specs <sar type> <range index:sar power>*
e.g.
iw phy0 set sar_specs 0 0:100 1:90 2:80...
where sar type should correspond to wiphy's sar_capa,
and range index should be valid in wiphy's sar_capa.
For now, kernel sar type supports only 0 (NL80211_SAR_TYPE_POWER)
which means that the sar power limitation is specified in 0.25dBm unit.
Cc: Carl Huang <cjhuang@codeaurora.org> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://lore.kernel.org/r/20211007085615.40399-1-pkshih@realtek.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
It is noticed in Kernel version 5.14.0-rc4+, that when sending the NL cmd
NL80211_CMD_SET_TID_CONFIG with nested attrs under NL80211_ATTR_TID_CONFIG,
kernel returnes a response with the error "NLA_F_NESTED is missing".
$ sudo ./iw dev wlan0 set tidconf tids 0x1 ampdu on
kernel reports: NLA_F_NESTED is missing
command failed: Invalid argument (-22))
Fix this by setting NLA_F_NESTED flag everytime when using nla_nest_start()
library function. This is needed to make cfg80211 allow the nl80211 command
NL80211_ATTR_TID_CONFIG in the new kernel versions that enforce netlink
attribute policy validation.
iw: link: mention the need for MAC addr arg in link get_sta cmd usage menu
The usage menu shown when running the hidden "link get_sta" command is not
mentioning the need for the MAC address argument. Without this, the cmd is
always failing with the output shown below.
$ ./iw dev wlan0 link get_sta
Usage: ./iw [options] dev <devname> link get_sta
...
To avoid this, let the user know about the mandatory "MAC address" argument
like below.
$ ./iw dev wlan0 link get_sta
Usage: ./iw [options] dev <devname> link get_sta <mac-addr>
...
Johannes Berg [Wed, 8 Sep 2021 07:34:20 +0000 (09:34 +0200)]
iw: fix various sparse static warnings
The section macro must be non-static, but many of them
are not used outside a single file. Still declare all of
the sections so that the warnings go away.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Gokul Sivakumar [Thu, 5 Aug 2021 15:38:07 +0000 (21:08 +0530)]
iw: mesh: add new cmd to dump all the supported mesh config params at once
The function print_mesh_param_handler() already supports printing all the
mesh config params when not passing one specific parameter, so add a new
"mesh_param dump" command to help the user see all the parameters at once.
Gokul Sivakumar [Thu, 5 Aug 2021 15:38:06 +0000 (21:08 +0530)]
iw: mesh: fix crash when attempting to print the conf param "mesh_nolearn"
Even if iw did not receive some of the meshconf attributes in response to
NL80211_CMD_GET_MESH_PARAMS, it tries to print that param and gets crashed.
Fix this by adding a condition check before trying to access each of the
mesh conf params.
$ iw dev mesh0 get mesh_param mesh_nolearn
Segmentation fault (core dumped)
(gdb) bt
#0 0x00007f21f54660e9 in nla_get_u8 () from /lib/x86_64-linux-gnu/libnl-3.so.200
#1 0x0000562ba2f5d70d in _print_u8 (a=<optimized out>) at mesh.c:131
#2 0x0000562ba2f5d7ce in print_mesh_param_handler (msg=<optimized out>,
arg=0x562ba2f85758 <_mesh_param_descrs+1080>) at mesh.c:412
#3 0x00007f21f546db9c in nl_recvmsgs_report () from /lib/x86_64-linux-gnu/libnl-3.so.200
#4 0x00007f21f546e059 in nl_recvmsgs () from /lib/x86_64-linux-gnu/libnl-3.so.200
#5 0x0000562ba2f5bb3b in __handle_cmd (state=0x7ffe677bc510, idby=II_NETDEV, argc=<optimized out>,
argv=<optimized out>, cmdout=0x7ffe677bc508) at iw.c:541
#6 0x0000562ba2f4fe0c in __handle_cmd (cmdout=0x7ffe677bc508, argv=0x7ffe677bc658, argc=4, idby=II_NETDEV,
state=0x7ffe677bc510) at iw.c:613
#7 main (argc=4, argv=0x7ffe677bc658) at iw.c:613
(gdb) up 2
#2 0x0000562ba2f5d7ce in print_mesh_param_handler (msg=<optimized out>,
arg=0x562ba2f85758 <_mesh_param_descrs+1080>) at mesh.c:412
412 mdescr->nla_print_fn(mesh_params[mdescr->mesh_param_num]);
(gdb) i local
mdescr = 0x562ba2f85758 <_mesh_param_descrs+1080>
attrs = {0x0 <repeats 35 times>, 0x562ba4002a14, 0x0 <repeats 266 times>}
parent_attr = <optimized out>
mesh_params = {0x0, 0x562ba4002a20, 0x562ba4002a28, 0x562ba4002a30, 0x562ba4002a38, 0x562ba4002a40,
0x562ba4002a48, 0x562ba4002a58, 0x562ba4002a68, 0x562ba4002a70, 0x562ba4002a78, 0x562ba4002a80,
0x562ba4002a88, 0x562ba4002a98, 0x562ba4002aa0, 0x562ba4002a50, 0x562ba4002aa8, 0x562ba4002ab0,
0x562ba4002a90, 0x562ba4002ab8, 0x562ba4002ac0, 0x562ba4002a60, 0x562ba4002ac8, 0x562ba4002ad0,
0x562ba4002ad8, 0x562ba4002ae0, 0x562ba4002ae8, 0x562ba4002af0, 0x562ba4002af8, 0x562ba4002b00, 0x0, 0x0}
gnlh = 0x562ba4002a10
(gdb)
(gdb) p mesh_params[30]
$7 = (struct nlattr *) 0x0
(gdb)
Johannes Berg [Mon, 16 Nov 2020 09:43:12 +0000 (10:43 +0100)]
iw: allow specifying CFLAGS/LIBS externally
If CFLAGS or LIBS are specified on the make command line,
then the += doesn't do anything. Add "override" directives
to still add the necessary libnl flags/libs.
Change-Id: Icdc3d14ae3a6f01b827c76e753c93fe8eb8fcec2 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
On 32-bit architectures, time_t is 32-bit which causes overflows in the
arithmetic involving tv_sec, leading to invalid output. Fix this by
explicitly adding ULL suffixes to the constants used in those calculations.
ivan tkachenko [Wed, 25 Nov 2020 01:50:48 +0000 (04:50 +0300)]
man: update wikipage URL, reformat SEE ALSO section
groff_man(7) provides plenty of useful requests/macros, and one of
them is .UR/.UE for URL formatting.
Man pages should be formatted with paragraphs (.P or .PP) requests,
and source text should not contain empty lines -- use empty request
instead (literally, single dot on its own line).
without this 11s mesh could not be configured with bandwidth 80MHz
in 6G band using iw. Also, this will be required to set frequency
for 6GHz band in 80MHz.
Brian Norris [Tue, 3 Nov 2020 23:56:31 +0000 (15:56 -0800)]
iw: handle positive error codes gracefully
netlink(7) requires error codes to be negative, but since when does a
man page stop anyone? At a minimum, we shouldn't allow a non-conforming
vendor command to put us into an infinite loop in the below snippets
from __handle_cmd():
Johannes Berg [Thu, 27 Aug 2020 11:07:31 +0000 (13:07 +0200)]
iw: add support for vendor events
We can already drop in arbitrary files for vendor commands
as the build system picks those up, also add support for
vendor specific events in a similar fashion.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Ilan Peer [Sun, 19 Jul 2020 07:44:24 +0000 (10:44 +0300)]
reg: Fix getting PHY specific regulatory information
Commit 14ad75d3b4c3 ("iw: support multiple regdom print") added
support for dumping multiple regulatory domain, with the intent
that if a specific phy is given, only its regulatory information
would be fetched. However, the phy specific handling was ignored.
Fix it.
Change-Id: I647ef420741e528a4d6568a7d4518c9a561bd199 Signed-off-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Linus Lüssing [Wed, 17 Jun 2020 07:30:34 +0000 (09:30 +0200)]
iw: mesh: add mesh_param "mesh_nolearn" to skip path discovery
Currently, before being able to forward a packet between two 802.11s
nodes, both a PLINK handshake is performed upon receiving a beacon and
then later a PREQ/PREP exchange for path discovery is performed on
demand upon receiving a data frame to forward.
When running a mesh protocol on top of an 802.11s interface, like
batman-adv, we do not need the multi-hop mesh routing capabilities of
802.11s and usually set mesh_fwding=0. However, even with mesh_fwding=0
the PREQ/PREP path discovery is still performed on demand. Even though
in this scenario the next hop PREQ/PREP will determine is always the
direct 11s neighbor node.
The new mesh_nolearn parameter allows to skip the PREQ/PREP exchange in
this scenario, leading to a reduced delay, reduced packet buffering and
simplifies HWMP in general.
mesh_nolearn is still rather conservative in that if the packet destination
is not a direct 11s neighbor, it will fall back to PREQ/PREP path
discovery.
For normal, multi-hop 802.11s mesh routing it is usually not advisable
to enable mesh_nolearn as a transmission to a direct but distant neighbor
might be worse than reaching that same node via a more robust /
higher throughput etc. multi-hop path.
iw: sync frequency to channel mapping with kernel for 6GHz band
This enables support for channel to frequency conversion and vice versa
for 6GHz channels and frequencies. Channel numbers of 6GHz band might
overlap with those of 5G and 2G bands.
Use command NL80211_CMD_SET_TID_CONFIG to perform per-node TID specific
configuration. If peer is not specified, then configuration is applied
to all the peers. Currently kernel supports configuration of the
following parameters:
- short/long retry
- mpdu/msdu aggregation on/off
- rts/cts on/off
- noack on/off
Examples:
Apply configuration for specific peer and TIDs:
$ iw dev wlan0 set tidconf peer 1:2:3:4:5:6 tids 0x3 ampdu off tids 0x2 sretry 10 lretry 100
$ iw dev wlan0 set tidconf peer 1:2:3:4:5:6 tids 0x1 override ampdu off amsdu off
Apply configuration for all peers and all TIDs:
$ iw dev wlan0 set tidconf tids 0xff ampdu off amsdu off sretry 10 lretry 100 noack off
Apply configuration for all peers and specific TIDs:
$ iw dev wlan0 set tidconf peer 0xff:0xff:0xff:0xff:0xff:0xff tids 0x1 ampdu off amsdu off
Brian Norris [Tue, 31 Mar 2020 23:28:33 +0000 (16:28 -0700)]
iw: 'phy <name> reg get' shouldn't dump all domains
Right now, 'iw phy ... reg get' gets translated to NLM_F_DUMP, which
dumps all domains. But this command really is looking for non-DUMP
semantics -- it only wants the domain for the specified wiphy, or (per
the kernel's choice) the global, if the wiphy doesn't have its own.
We can achieve this by skipping the handle_reg_get() -> "reg dump"
indirection.
[ with a wiphy-specific domain ]
Before:
# iw phy phy0 reg get
global
country XX: DFS-YYY
[...]
phy#0
country AA: DFS-BBB
[...]
After:
# iw phy phy0 reg get
phy#0
country AA: DFS-BBB
[...]
[ without a wiphy-specific domain ]
Before and after (unchanged):
# iw phy phy0 reg get
global
country XX: DFS-YYY
[...]
Ilan Peer [Wed, 26 Feb 2020 11:31:48 +0000 (13:31 +0200)]
scan: Fix printing of unknown WPS vendor extension
When an unknown WPS vendor extension is encountered a '\t' was
inserted without a matching message with '\n'. This would impact
the output of following data. Fix it
Change-Id: I86c40c088592ecc7713b0793e0ac56e41d3607a3 Signed-off-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Markus Theil [Sun, 9 Feb 2020 16:58:56 +0000 (17:58 +0100)]
iw: scan: fix buffer over-read in print_ies()
This patch correctly checks, if enough data bytes for parsing IEs are
present (-2 in check for type and length). Furthermore, it adds a
nullptr and length check to ease future fuzzing.