[PATCH 10/27] netlink: add basic attribute parser of ifaddrlblmsg of NETLINK_ROUTE
JingPiao Chen
chenjingpiao at gmail.com
Tue Aug 15 04:41:18 UTC 2017
* rtnl_addrlabel.c: Include "netlink.h", "nlattr.h"
and "xlat/rtnl_addrlabel_attrs.h".
(decode_ifaddrlblmsg): Call decode_nlattr.
* xlat/rtnl_addrlabel_attrs.in: New file.
Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
rtnl_addrlabel.c | 15 ++++++++++++++-
xlat/rtnl_addrlabel_attrs.in | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 xlat/rtnl_addrlabel_attrs.in
diff --git a/rtnl_addrlabel.c b/rtnl_addrlabel.c
index 42dc65e..53cfb2c 100644
--- a/rtnl_addrlabel.c
+++ b/rtnl_addrlabel.c
@@ -32,14 +32,19 @@
#ifdef HAVE_STRUCT_IFADDRLBLMSG
# include "netlink_route.h"
+# include "nlattr.h"
# include "print_fields.h"
# include <linux/if_addrlabel.h>
+# include "netlink.h"
+
+# include "xlat/rtnl_addrlabel_attrs.h"
DECL_NETLINK_ROUTE_DECODER(decode_ifaddrlblmsg)
{
struct ifaddrlblmsg ifal = { .ifal_family = family };
- const size_t offset = sizeof(ifal.ifal_family);
+ size_t offset = sizeof(ifal.ifal_family);
+ bool decode_nla = false;
PRINT_FIELD_XVAL("{", ifal, ifal_family, addrfams, "AF_???");
@@ -52,10 +57,18 @@ DECL_NETLINK_ROUTE_DECODER(decode_ifaddrlblmsg)
PRINT_FIELD_U(", ", ifal, ifal_flags);
PRINT_FIELD_IFINDEX(", ", ifal, ifal_index);
PRINT_FIELD_U(", ", ifal, ifal_seq);
+ decode_nla = true;
}
} else
tprints("...");
tprints("}");
+
+ offset = NLMSG_ALIGN(sizeof(ifal));
+ if (decode_nla && len > offset) {
+ tprints(", ");
+ decode_nlattr(tcp, addr + offset, len - offset,
+ rtnl_addrlabel_attrs, "IFAL_???", NULL, 0, NULL);
+ }
}
#endif
diff --git a/xlat/rtnl_addrlabel_attrs.in b/xlat/rtnl_addrlabel_attrs.in
new file mode 100644
index 0000000..0dc464d
--- /dev/null
+++ b/xlat/rtnl_addrlabel_attrs.in
@@ -0,0 +1,2 @@
+IFAL_ADDRESS 1
+IFAL_LABEL 2
--
2.7.4
More information about the Strace-devel
mailing list