From b9afb63fd7cc15cc39bd77c335a58debe5374e0f Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Tue, 15 Aug 2017 12:41:22 +0800 Subject: [PATCH] netlink: add basic decoding of NETLINK_ROUTE rtgenmsg attributes * rtnl_nsid.c: Include "nlattr.h" and "xlat/rtnl_nsid_attrs.h". (decode_rtgenmsg): Call decode_nlattr. * xlat/rtnl_nsid_attrs.in: New file. Co-authored-by: Fabien Siron --- 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 de287880..e3fe18b6 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 +#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 00000000..f5b01bfc --- /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.50.1