]> granicus.if.org Git - strace/commitdiff
netlink: add basic decoding of NETLINK_ROUTE netconfmsg attributes
authorJingPiao Chen <chenjingpiao@gmail.com>
Tue, 15 Aug 2017 04:41:20 +0000 (12:41 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 15 Aug 2017 22:34:46 +0000 (22:34 +0000)
* rtnl_netconf.c: Include "netlink.h", "nlattr.h",
and "xlat/rtnl_netconf_attrs.h".
(decode_netconfmsg): Call decode_nlattr.
* xlat/rtnl_netconf_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
rtnl_netconf.c
xlat/rtnl_netconf_attrs.in [new file with mode: 0644]

index 852e908ddb37e880e54cf9b000b78435bed4bb1f..7e9b173b77c187d1d47b8d7fdbabafc6f3d3b56a 100644 (file)
 #ifdef HAVE_STRUCT_NETCONFMSG
 
 # include "netlink_route.h"
+# include "nlattr.h"
 # include "print_fields.h"
 
 # include <linux/netconf.h>
+# include "netlink.h"
+
+# include "xlat/rtnl_netconf_attrs.h"
 
 DECL_NETLINK_ROUTE_DECODER(decode_netconfmsg)
 {
@@ -42,6 +46,14 @@ DECL_NETLINK_ROUTE_DECODER(decode_netconfmsg)
 
        PRINT_FIELD_XVAL("{", ncm, ncm_family, addrfams, "AF_???");
        tprints("}");
+
+       const size_t offset = NLMSG_ALIGN(sizeof(ncm));
+       if (len > offset) {
+               tprints(", ");
+               decode_nlattr(tcp, addr + offset, len - offset,
+                             rtnl_netconf_attrs, "NETCONFA_???",
+                             NULL, 0, NULL);
+       }
 }
 
 #endif
diff --git a/xlat/rtnl_netconf_attrs.in b/xlat/rtnl_netconf_attrs.in
new file mode 100644 (file)
index 0000000..b376b78
--- /dev/null
@@ -0,0 +1,8 @@
+NETCONFA_UNSPEC                                0
+NETCONFA_IFINDEX                       1
+NETCONFA_FORWARDING                    2
+NETCONFA_RP_FILTER                     3
+NETCONFA_MC_FORWARDING                 4
+NETCONFA_PROXY_NEIGH                   5
+NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN   6
+NETCONFA_INPUT                         7