[PATCH v2 04/16] netlink: add a dummy netlink attribute parser of AF_NETLINK diag
JingPiao Chen
chenjingpiao at gmail.com
Sun Jun 18 05:18:31 UTC 2017
* linux/netlink_diag.h (NETLINK_DIAG_*): New enum.
* netlink_sock_diag.c: Include "xlat/netlink_diag_attrs.h".
(decode_netlink_diag_msg): Use decode_nlattr.
* xlat/netlink_diag_attrs.in: New file.
Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
linux/netlink_diag.h | 8 ++++++++
netlink_sock_diag.c | 8 ++++++++
xlat/netlink_diag_attrs.in | 5 +++++
3 files changed, 21 insertions(+)
create mode 100644 xlat/netlink_diag_attrs.in
diff --git a/linux/netlink_diag.h b/linux/netlink_diag.h
index 49b7550..ad13aa9 100644
--- a/linux/netlink_diag.h
+++ b/linux/netlink_diag.h
@@ -23,6 +23,14 @@ struct netlink_diag_msg {
uint32_t ndiag_cookie[2];
};
+enum {
+ NETLINK_DIAG_MEMINFO,
+ NETLINK_DIAG_GROUPS,
+ NETLINK_DIAG_RX_RING,
+ NETLINK_DIAG_TX_RING,
+ NETLINK_DIAG_FLAGS,
+};
+
#define NDIAG_SHOW_MEMINFO 0x00000001
#define NDIAG_SHOW_GROUPS 0x00000002
#define NDIAG_SHOW_RING_CFG 0x00000004 /* deprecated since 4.6 */
diff --git a/netlink_sock_diag.c b/netlink_sock_diag.c
index e515810..8d2a882 100644
--- a/netlink_sock_diag.c
+++ b/netlink_sock_diag.c
@@ -45,6 +45,7 @@
#include "xlat/tcp_states.h"
#include "xlat/tcp_state_flags.h"
+#include "xlat/netlink_diag_attrs.h"
#include "xlat/netlink_diag_show.h"
#include "xlat/netlink_states.h"
@@ -223,6 +224,13 @@ decode_netlink_diag_msg(struct tcb *const tcp,
} else
tprints("...");
tprints("}");
+
+ if (len > NLA_ALIGN(sizeof(msg))) {
+ tprints(", ");
+ decode_nlattr(tcp, addr + NLA_ALIGN(sizeof(msg)),
+ len - NLA_ALIGN(sizeof(msg)),
+ netlink_diag_attrs, "NETLINK_DIAG_???");
+ }
}
static void
diff --git a/xlat/netlink_diag_attrs.in b/xlat/netlink_diag_attrs.in
new file mode 100644
index 0000000..22c70bd
--- /dev/null
+++ b/xlat/netlink_diag_attrs.in
@@ -0,0 +1,5 @@
+#unconditional
+NETLINK_DIAG_MEMINFO
+NETLINK_DIAG_GROUPS
+NETLINK_DIAG_RX_RING
+NETLINK_DIAG_TX_RING
--
2.7.4
More information about the Strace-devel
mailing list