summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-06-04 20:58:31 +0200
committerJo-Philipp Wich <jo@mein.io>2022-06-04 21:01:45 +0200
commit1347440421718d1207e0b53158514737010665e9 (patch)
treeb6ac12b0006f4d9e43d184b4dbcef73bbc1cc9cf
parentb211ca0e420d8086d3fa0358413a6f8b44df1115 (diff)
rtnl: avoid stray "netlink: %d bytes leftover after parsing attributes."
Some nested RTAs such as IFLA_INET_CONF do not contain actual sub-RTAs but just an array of integers. Avoid calling a no-op `nla_parse()` for such attributes to suppress the non-harmful leftover bytes warning emitted by libnl. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--lib/rtnl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/rtnl.c b/lib/rtnl.c
index b6a3e38..3b8d6cc 100644
--- a/lib/rtnl.c
+++ b/lib/rtnl.c
@@ -1345,10 +1345,13 @@ uc_nl_convert_attrs(struct nl_msg *msg, void *buf, size_t buflen, size_t headsiz
if (!tb)
return false;
- if (buflen > headsize)
- nla_parse(tb, maxattr, buf + headsize, buflen - headsize, NULL);
- else
+ if (buflen > headsize) {
+ if (maxattr)
+ nla_parse(tb, maxattr, buf + headsize, buflen - headsize, NULL);
+ }
+ else {
structlen = buflen;
+ }
for (i = 0; i < nattrs; i++) {
if (attrs[i].attr == 0 && (uintptr_t)attrs[i].auxdata >= structlen)