All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
@ 2021-09-10 14:16 Gokul Sivakumar
  2021-09-10 14:16 ` [PATCH iw 2/4] iw: link: mention the need for MAC addr arg in link get_sta cmd usage menu Gokul Sivakumar
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Gokul Sivakumar @ 2021-09-10 14:16 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Gokul Sivakumar, linux-wireless

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 <gokulkumar792@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH iw 2/4] iw: link: mention the need for MAC addr arg in link get_sta cmd usage menu
  2021-09-10 14:16 [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Gokul Sivakumar
@ 2021-09-10 14:16 ` Gokul Sivakumar
  2021-09-10 14:16 ` [PATCH iw 3/4] iw: event: add the missing time display format in the "iw event" help menu Gokul Sivakumar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Gokul Sivakumar @ 2021-09-10 14:16 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Gokul Sivakumar, linux-wireless

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>
 ...

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
---
 link.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/link.c b/link.c
index 1ed7f63..2074488 100644
--- a/link.c
+++ b/link.c
@@ -273,7 +273,7 @@ static int handle_link(struct nl80211_state *state,
 }
 TOPLEVEL(link, NULL, 0, 0, CIB_NETDEV, handle_link,
 	 "Print information about the current link, if any.");
-HIDDEN(link, get_sta, "", NL80211_CMD_GET_STATION, 0,
+HIDDEN(link, get_sta, "<mac-addr>", NL80211_CMD_GET_STATION, 0,
 	CIB_NETDEV, handle_link_sta);
 HIDDEN(link, get_bss, NULL, NL80211_CMD_GET_SCAN, NLM_F_DUMP,
 	CIB_NETDEV, handle_scan_for_link);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH iw 3/4] iw: event: add the missing time display format in the "iw event" help menu
  2021-09-10 14:16 [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Gokul Sivakumar
  2021-09-10 14:16 ` [PATCH iw 2/4] iw: link: mention the need for MAC addr arg in link get_sta cmd usage menu Gokul Sivakumar
@ 2021-09-10 14:16 ` Gokul Sivakumar
  2021-09-10 14:16 ` [PATCH iw 4/4] iw: mesh: add comments in the mesh confguration parameter printing sections Gokul Sivakumar
  2021-09-23 11:36 ` [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Johannes Berg
  3 siblings, 0 replies; 9+ messages in thread
From: Gokul Sivakumar @ 2021-09-10 14:16 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Gokul Sivakumar, linux-wireless

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 <gokulkumar792@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH iw 4/4] iw: mesh: add comments in the mesh confguration parameter printing sections
  2021-09-10 14:16 [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Gokul Sivakumar
  2021-09-10 14:16 ` [PATCH iw 2/4] iw: link: mention the need for MAC addr arg in link get_sta cmd usage menu Gokul Sivakumar
  2021-09-10 14:16 ` [PATCH iw 3/4] iw: event: add the missing time display format in the "iw event" help menu Gokul Sivakumar
@ 2021-09-10 14:16 ` Gokul Sivakumar
  2021-09-23 11:36 ` [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Johannes Berg
  3 siblings, 0 replies; 9+ messages in thread
From: Gokul Sivakumar @ 2021-09-10 14:16 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Gokul Sivakumar, linux-wireless

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
  2021-09-10 14:16 [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Gokul Sivakumar
                   ` (2 preceding siblings ...)
  2021-09-10 14:16 ` [PATCH iw 4/4] iw: mesh: add comments in the mesh confguration parameter printing sections Gokul Sivakumar
@ 2021-09-23 11:36 ` Johannes Berg
  2021-09-23 15:53   ` Gokul Sivakumar
  3 siblings, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2021-09-23 11:36 UTC (permalink / raw)
  To: Gokul Sivakumar; +Cc: linux-wireless

Applied 2-4, but

> 
> +#ifndef NL_CAPABILITY_VERSION_3_5_0

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

johannes


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
  2021-09-23 11:36 ` [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Johannes Berg
@ 2021-09-23 15:53   ` Gokul Sivakumar
  2021-09-23 15:56     ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Gokul Sivakumar @ 2021-09-23 15:53 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
  2021-09-23 15:53   ` Gokul Sivakumar
@ 2021-09-23 15:56     ` Johannes Berg
  2021-09-23 16:23       ` Gokul Sivakumar
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2021-09-23 15:56 UTC (permalink / raw)
  To: Gokul Sivakumar; +Cc: linux-wireless

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
  2021-09-23 15:56     ` Johannes Berg
@ 2021-09-23 16:23       ` Gokul Sivakumar
  2021-09-23 16:25         ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Gokul Sivakumar @ 2021-09-23 16:23 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions
  2021-09-23 16:23       ` Gokul Sivakumar
@ 2021-09-23 16:25         ` Johannes Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Berg @ 2021-09-23 16:25 UTC (permalink / raw)
  To: Gokul Sivakumar; +Cc: linux-wireless

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-23 16:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 14:16 [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Gokul Sivakumar
2021-09-10 14:16 ` [PATCH iw 2/4] iw: link: mention the need for MAC addr arg in link get_sta cmd usage menu Gokul Sivakumar
2021-09-10 14:16 ` [PATCH iw 3/4] iw: event: add the missing time display format in the "iw event" help menu Gokul Sivakumar
2021-09-10 14:16 ` [PATCH iw 4/4] iw: mesh: add comments in the mesh confguration parameter printing sections Gokul Sivakumar
2021-09-23 11:36 ` [PATCH iw 1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions Johannes Berg
2021-09-23 15:53   ` Gokul Sivakumar
2021-09-23 15:56     ` Johannes Berg
2021-09-23 16:23       ` Gokul Sivakumar
2021-09-23 16:25         ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.