[PATCH v2 06/16] netlink: add a dummy netlink attribute parser of AF_PACKET diag
JingPiao Chen
chenjingpiao at gmail.com
Sun Jun 18 05:18:33 UTC 2017
* linux/packet_diag.h (PACKET_DIAG_*): New enum.
* netlink_sock_diag.c: Include "xlat/packet_diag_attrs.h".
(decode_packet_diag_msg): Use decode_nlattr.
* xlat/packet_diag_attrs.in: New file.
Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
linux/packet_diag.h | 11 +++++++++++
netlink_sock_diag.c | 8 ++++++++
xlat/packet_diag_attrs.in | 9 +++++++++
3 files changed, 28 insertions(+)
create mode 100644 xlat/packet_diag_attrs.in
diff --git a/linux/packet_diag.h b/linux/packet_diag.h
index 10f48d9..3e8120b 100644
--- a/linux/packet_diag.h
+++ b/linux/packet_diag.h
@@ -26,4 +26,15 @@ struct packet_diag_msg {
uint32_t pdiag_cookie[2];
};
+enum {
+ PACKET_DIAG_INFO,
+ PACKET_DIAG_MCLIST,
+ PACKET_DIAG_RX_RING,
+ PACKET_DIAG_TX_RING,
+ PACKET_DIAG_FANOUT,
+ PACKET_DIAG_UID,
+ PACKET_DIAG_MEMINFO,
+ PACKET_DIAG_FILTER,
+};
+
#endif /* !STRACE_LINUX_PACKET_DIAG_H */
diff --git a/netlink_sock_diag.c b/netlink_sock_diag.c
index 8d2a882..099e533 100644
--- a/netlink_sock_diag.c
+++ b/netlink_sock_diag.c
@@ -49,6 +49,7 @@
#include "xlat/netlink_diag_show.h"
#include "xlat/netlink_states.h"
+#include "xlat/packet_diag_attrs.h"
#include "xlat/packet_diag_show.h"
#ifdef AF_SMC
@@ -293,6 +294,13 @@ decode_packet_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)),
+ packet_diag_attrs, "PACKET_DIAG_???");
+ }
}
static void
diff --git a/xlat/packet_diag_attrs.in b/xlat/packet_diag_attrs.in
new file mode 100644
index 0000000..5e33871
--- /dev/null
+++ b/xlat/packet_diag_attrs.in
@@ -0,0 +1,9 @@
+#unconditional
+PACKET_DIAG_INFO
+PACKET_DIAG_MCLIST
+PACKET_DIAG_RX_RING
+PACKET_DIAG_TX_RING
+PACKET_DIAG_FANOUT
+PACKET_DIAG_UID
+PACKET_DIAG_MEMINFO
+PACKET_DIAG_FILTER
--
2.7.4
More information about the Strace-devel
mailing list