diff mbox series

[iw,1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions

Message ID 20210910141618.1594617-1-gokulkumar792@gmail.com
State New
Headers show
Series [iw,1/4] iw: nl80211: add NLA_F_NESTED to nla_nest_start() with older libnl versions | expand

Commit Message

Gokul Sivakumar Sept. 10, 2021, 2:16 p.m. UTC
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(+)

Comments

Johannes Berg Sept. 23, 2021, 11:36 a.m. UTC | #1
Applied 2-4, but

> 

> +#ifndef NL_CAPABILITY_VERSION_3_5_0


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

johannes
Gokul Sivakumar Sept. 23, 2021, 3:53 p.m. UTC | #2
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
Johannes Berg Sept. 23, 2021, 3:56 p.m. UTC | #3
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
Gokul Sivakumar Sept. 23, 2021, 4:23 p.m. UTC | #4
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
Johannes Berg Sept. 23, 2021, 4:25 p.m. UTC | #5
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
diff mbox series

Patch

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