platform/netlink: mark nested netlink attribute with NLA_F_NESTED

Kernel 5.2 is adding stricter checking for netlink messages.
In particular, for certain API it checks now that NLA_F_NESTED flag is
set for nested attributes ([1]).

Note that libnl3 does not ever set this flag, and since our netlink
implementation is copied from there, certain netlink messages are now
rejected as invalid.

On the other hand, libmnl always adds this flag ([2]). So we should do that
as well.

In particular, this affects the WireGuard netlink API causing request
from NetworkManager to be rejected ([3]).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b424e432e770d6dd572765459d5b6a96a19c5286
[2] https://git.netfilter.org/libmnl/tree/src/attr.c?id=5937dfcb0185f5cb9cf275992ea701ec4e619d9c#n535
[3] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/212

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/210
(cherry picked from commit 7811d1c187)
(cherry picked from commit 57048338ee)
(cherry picked from commit 52b52d2f7d)
(cherry picked from commit ef5c7dc0eb)
This commit is contained in:
Thomas Haller 2019-07-23 10:32:07 +02:00
parent 35a31b7910
commit ecaf1acb76

View file

@ -515,7 +515,7 @@ nla_nest_start (struct nl_msg *msg, int attrtype)
{
struct nlattr *start = (struct nlattr *) nlmsg_tail(msg->nm_nlh);
if (nla_put(msg, attrtype, 0, NULL) < 0)
if (nla_put (msg, NLA_F_NESTED | attrtype, 0, NULL) < 0)
return NULL;
return start;