[PATCH 14/27] netlink: add basic attribute parser of rtgenmsg of NETLINK_ROUTE
JingPiao Chen
chenjingpiao at gmail.com
Tue Aug 15 04:41:22 UTC 2017
* rtnl_nsid.c: Include "nlattr.h" and "xlat/rtnl_nsid_attrs.h".
(decode_rtgenmsg): Call decode_nlattr.
* xlat/rtnl_nsid_attrs.in
Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
rtnl_nsid.c | 10 ++++++++++
xlat/rtnl_nsid_attrs.in | 5 +++++
2 files changed, 15 insertions(+)
create mode 100644 xlat/rtnl_nsid_attrs.in
diff --git a/rtnl_nsid.c b/rtnl_nsid.c
index de28788..e3fe18b 100644
--- a/rtnl_nsid.c
+++ b/rtnl_nsid.c
@@ -29,15 +29,25 @@
#include "defs.h"
#include "netlink_route.h"
+#include "nlattr.h"
#include "print_fields.h"
#include "netlink.h"
#include <linux/rtnetlink.h>
+#include "xlat/rtnl_nsid_attrs.h"
+
DECL_NETLINK_ROUTE_DECODER(decode_rtgenmsg)
{
struct rtgenmsg rtgenmsg = { .rtgen_family = family };
PRINT_FIELD_XVAL("{", rtgenmsg, rtgen_family, addrfams, "AF_???");
tprints("}");
+
+ const size_t offset = NLMSG_ALIGN(sizeof(rtgenmsg));
+ if (len > offset) {
+ tprints(", ");
+ decode_nlattr(tcp, addr + offset, len - offset,
+ rtnl_nsid_attrs, "NETNSA_???", NULL, 0, NULL);
+ }
}
diff --git a/xlat/rtnl_nsid_attrs.in b/xlat/rtnl_nsid_attrs.in
new file mode 100644
index 0000000..f5b01bf
--- /dev/null
+++ b/xlat/rtnl_nsid_attrs.in
@@ -0,0 +1,5 @@
+NETNSA_NSID_NOT_ASSIGNED -1
+NETNSA_NONE 0
+NETNSA_NSID 1
+NETNSA_PID 2
+NETNSA_FD 3
--
2.7.4
More information about the Strace-devel
mailing list