2021-09-10 14:18:56

by Gokul Sivakumar

[permalink] [raw]
Subject: [PATCH iw 1/4] 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.

Signed-off-by: Gokul Sivakumar <[email protected]>
---
iw.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/iw.h b/iw.h
index a118f5b..545fd0e 100644
--- a/iw.h
+++ b/iw.h
@@ -11,6 +11,11 @@
#include "nl80211.h"
#include "ieee80211.h"

+#ifndef NL_CAPABILITY_VERSION_3_5_0
+#define nla_nest_start(msg, attrtype) \
+ nla_nest_start(msg, NLA_F_NESTED | (attrtype))
+#endif
+
/* support for extack if compilation headers are too old */
#ifndef NETLINK_EXT_ACK
#define NETLINK_EXT_ACK 11
--
2.25.1


2021-09-10 14:19:21

by Gokul Sivakumar

[permalink] [raw]
Subject: [PATCH iw 4/4] iw: mesh: add comments in the mesh confguration parameter printing sections

Signed-off-by: Gokul Sivakumar <[email protected]>
---
mesh.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mesh.c b/mesh.c
index 943edf5..0fb98a3 100644
--- a/mesh.c
+++ b/mesh.c
@@ -400,6 +400,7 @@ static int print_mesh_param_handler(struct nl_msg *msg, void *arg)
if (!mdescr) {
unsigned int i;

+ /* print out all the supported mesh parameters */
for (i = 0; i < ARRAY_SIZE(_mesh_param_descrs); i++) {
mdescr = &_mesh_param_descrs[i];
if (mesh_params[mdescr->mesh_param_num]) {
@@ -411,7 +412,7 @@ static int print_mesh_param_handler(struct nl_msg *msg, void *arg)
return NL_SKIP;
}

- /* print out the mesh parameter */
+ /* print out the requested mesh parameter */
if (mesh_params[mdescr->mesh_param_num]) {
mdescr->nla_print_fn(mesh_params[mdescr->mesh_param_num]);
printf("\n");
--
2.25.1

2021-09-10 14:19:22

by Gokul Sivakumar

[permalink] [raw]
Subject: [PATCH iw 3/4] iw: event: add the missing time display format in the "iw event" help menu

The option used to print the events with timestamp in Human readable format
is not listed in the "$ iw event -h" output.

$ ./iw event -h
Usage: ./iw [options] event [-t|-r] [-f] [-n]
...

So add "-T" option to the help menu.

$ ./iw event -h
Usage: ./iw [options] event [-t|-T|-r] [-f] [-n]
...

Signed-off-by: Gokul Sivakumar <[email protected]>
---
event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/event.c b/event.c
index 14f101b..e0908dd 100644
--- a/event.c
+++ b/event.c
@@ -1457,7 +1457,7 @@ static int print_events(struct nl80211_state *state,

return __do_listen_events(state, 0, NULL, 0, NULL, &args);
}
-TOPLEVEL(event, "[-t|-r] [-f]", 0, 0, CIB_NONE, print_events,
+TOPLEVEL(event, "[-t|-T|-r] [-f]", 0, 0, CIB_NONE, print_events,
"Monitor events from the kernel.\n"
"-t - print timestamp\n"
"-T - print absolute, human-readable timestamp\n"
--
2.25.1

2021-09-23 11:38:51

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions

Applied 2-4, but

>
> +#ifndef NL_CAPABILITY_VERSION_3_5_0

I can find no evidence of that symbol ever existing anywhere?

johannes

2021-09-23 15:55:12

by Gokul Sivakumar

[permalink] [raw]
Subject: Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions

On Thu, Sep 23, 2021 at 01:36:01PM +0200, Johannes Berg wrote:
> Applied 2-4, but
>
> >
> > +#ifndef NL_CAPABILITY_VERSION_3_5_0
>
> I can find no evidence of that symbol ever existing anywhere?
>
> johannes
>

The symbol NL_CAPABILITY_VERSION_3_5_0 is part of the libnl library and
this will be defined when using the libnl library version >= 3.5.0.
From libnl 3.5.0, the library itself handles setting NLA_F_NESTED flag
when using nla_nest_start() lib function. Please refer the
commit 7de65a0 ("attr: mark nested attributes as NLA_F_NESTED") in libnl
gitub tree (https://github.com/thom311/libnl/commit/7de65a0).

With this new code changes in iw.h, it will helpful if "iw" uses older
(< 3.5.0) libnl versions. In such cases NL_CAPABILITY_VERSION_3_5_0 will
not be defined in libnl and so iw itself will set the NLA_F_NESTED flag
when invoking the lib function nla_nest_start().

And hostapd/supplicant already started following the same approach.

Gokul

2021-09-23 15:59:48

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions

On Thu, 2021-09-23 at 21:23 +0530, Gokul Sivakumar wrote:
> The symbol NL_CAPABILITY_VERSION_3_5_0 is part of the libnl library and
> this will be defined when using the libnl library version >= 3.5.0.
> From libnl 3.5.0, the library itself handles setting NLA_F_NESTED flag
> when using nla_nest_start() lib function. Please refer the
> commit 7de65a0 ("attr: mark nested attributes as NLA_F_NESTED") in libnl
> gitub tree (https://github.com/thom311/libnl/commit/7de65a0).
>

Huh ok, I guess I missed the memo on the (official?) tree moving ...

johannes

2021-09-23 16:25:55

by Gokul Sivakumar

[permalink] [raw]
Subject: Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions

On Thu, Sep 23, 2021 at 05:56:40PM +0200, Johannes Berg wrote:
> On Thu, 2021-09-23 at 21:23 +0530, Gokul Sivakumar wrote:
> > The symbol NL_CAPABILITY_VERSION_3_5_0 is part of the libnl library and
> > this will be defined when using the libnl library version >= 3.5.0.
> > From libnl 3.5.0, the library itself handles setting NLA_F_NESTED flag
> > when using nla_nest_start() lib function. Please refer the
> > commit 7de65a0 ("attr: mark nested attributes as NLA_F_NESTED") in libnl
> > gitub tree (https://github.com/thom311/libnl/commit/7de65a0).
> >
>
> Huh ok, I guess I missed the memo on the (official?) tree moving ...
>
> johannes
>

I beleive https://github.com/thom311/libnl/ is the official tree for libnl
and I see Pull Requests are getting accepted in Github. Others can confirm!

The git tree git://git.infradead.org/users/tgr/libnl.git mentioned in
https://www.infradead.org/~tgr/libnl/ doesn't seem to be accessible.

Gokul

2021-09-23 16:28:53

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions

On Thu, 2021-09-23 at 21:53 +0530, Gokul Sivakumar wrote:
> On Thu, Sep 23, 2021 at 05:56:40PM +0200, Johannes Berg wrote:
> > On Thu, 2021-09-23 at 21:23 +0530, Gokul Sivakumar wrote:
> > > The symbol NL_CAPABILITY_VERSION_3_5_0 is part of the libnl library and
> > > this will be defined when using the libnl library version >= 3.5.0.
> > > From libnl 3.5.0, the library itself handles setting NLA_F_NESTED flag
> > > when using nla_nest_start() lib function. Please refer the
> > > commit 7de65a0 ("attr: mark nested attributes as NLA_F_NESTED") in libnl
> > > gitub tree (https://github.com/thom311/libnl/commit/7de65a0).
> > >
> >
> > Huh ok, I guess I missed the memo on the (official?) tree moving ...
> >
> > johannes
> >
>
> I beleive https://github.com/thom311/libnl/ is the official tree for libnl
> and I see Pull Requests are getting accepted in Github. Others can confirm!

Yeah, debian seems to be shipping from that tree too.

johannes