[PATCH v2 08/16] netlink: add a dummy netlink attribute parser of AF_INET diag
JingPiao Chen
chenjingpiao at gmail.com
Sun Jun 18 05:18:35 UTC 2017
* linux/inet_diag.h (INET_DIAG_REQ_*): New enum.
* netlink_sock_diag.c: Include "xlat/inet_diag_attrs.h"
and "xlat/inet_diag_req_attrs.h".
(decode_inet_diag_req_compat, decode_inet_diag_req_v2,
decode_inet_diag_msg): Use decode_nlattr.
* xlat/inet_diag_attrs.in: New file.
* xlat/inet_diag_req_attrs.in: Likewise.
Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
linux/inet_diag.h | 5 +++++
netlink_sock_diag.c | 23 +++++++++++++++++++++++
xlat/inet_diag_attrs.in | 18 ++++++++++++++++++
xlat/inet_diag_req_attrs.in | 3 +++
4 files changed, 49 insertions(+)
create mode 100644 xlat/inet_diag_attrs.in
create mode 100644 xlat/inet_diag_req_attrs.in
diff --git a/linux/inet_diag.h b/linux/inet_diag.h
index 245e476..e1df3bb 100644
--- a/linux/inet_diag.h
+++ b/linux/inet_diag.h
@@ -34,6 +34,11 @@ struct inet_diag_req_v2 {
struct inet_diag_sockid id;
};
+enum {
+ INET_DIAG_REQ_NONE,
+ INET_DIAG_REQ_BYTECODE,
+};
+
/* Info structure */
struct inet_diag_msg {
uint8_t idiag_family;
diff --git a/netlink_sock_diag.c b/netlink_sock_diag.c
index 099e533..5e232fe 100644
--- a/netlink_sock_diag.c
+++ b/netlink_sock_diag.c
@@ -40,7 +40,9 @@
#endif
#include <linux/unix_diag.h>
+#include "xlat/inet_diag_attrs.h"
#include "xlat/inet_diag_extended_flags.h"
+#include "xlat/inet_diag_req_attrs.h"
#include "xlat/tcp_states.h"
#include "xlat/tcp_state_flags.h"
@@ -356,6 +358,13 @@ decode_inet_diag_req_compat(struct tcb *const tcp,
} else
tprints("...");
tprints("}");
+
+ if (len > NLA_ALIGN(sizeof(req))) {
+ tprints(", ");
+ decode_nlattr(tcp, addr + NLA_ALIGN(sizeof(req)),
+ len - NLA_ALIGN(sizeof(req)),
+ inet_diag_req_attrs, "INET_DIAG_REQ_???");
+ }
}
static void
@@ -391,6 +400,13 @@ decode_inet_diag_req_v2(struct tcb *const tcp,
} else
tprints("...");
tprints("}");
+
+ if (len > NLA_ALIGN(sizeof(req))) {
+ tprints(", ");
+ decode_nlattr(tcp, addr + NLA_ALIGN(sizeof(req)),
+ len - NLA_ALIGN(sizeof(req)),
+ inet_diag_req_attrs, "INET_DIAG_REQ_???");
+ }
}
static void
@@ -448,6 +464,13 @@ decode_inet_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)),
+ inet_diag_attrs, "INET_DIAG_???");
+ }
}
#ifdef AF_SMC
diff --git a/xlat/inet_diag_attrs.in b/xlat/inet_diag_attrs.in
new file mode 100644
index 0000000..17519c8
--- /dev/null
+++ b/xlat/inet_diag_attrs.in
@@ -0,0 +1,18 @@
+#unconditional
+INET_DIAG_NONE
+INET_DIAG_MEMINFO
+INET_DIAG_INFO
+INET_DIAG_VEGASINFO
+INET_DIAG_CONG
+INET_DIAG_TOS
+INET_DIAG_TCLASS
+INET_DIAG_SKMEMINFO
+INET_DIAG_SHUTDOWN
+INET_DIAG_DCTCPINFO
+INET_DIAG_PROTOCOL
+INET_DIAG_SKV6ONLY
+INET_DIAG_LOCALS
+INET_DIAG_PEERS
+INET_DIAG_PAD
+INET_DIAG_MARK
+INET_DIAG_BBRINFO
diff --git a/xlat/inet_diag_req_attrs.in b/xlat/inet_diag_req_attrs.in
new file mode 100644
index 0000000..c36369e
--- /dev/null
+++ b/xlat/inet_diag_req_attrs.in
@@ -0,0 +1,3 @@
+#unconditional
+INET_DIAG_REQ_NONE
+INET_DIAG_REQ_BYTECODE
--
2.7.4
More information about the Strace-devel
mailing list