[PATCH 07/10] netlink: decode AF_SMC diag attributes
JingPiao Chen
chenjingpiao at gmail.com
Wed Jun 21 02:42:20 UTC 2017
* netlink_sock_diag.c: Include "xlat/smc_link_group_roles.h".
(smc_decoders): New array.
(decode_smc_diag_msg): Use it.
* linux/smc_diag.h (smc_diag_cursor, smc_diag_conninfo
smc_diag_linkinfo, smc_diag_lgrinfo): New structures.
* xlat/smc_link_group_roles.in: New file.
---
linux/smc_diag.h | 39 +++++++++++++++++++
netlink_sock_diag.c | 89 +++++++++++++++++++++++++++++++++++++++++++-
xlat/smc_link_group_roles.in | 2 +
3 files changed, 129 insertions(+), 1 deletion(-)
create mode 100644 xlat/smc_link_group_roles.in
diff --git a/linux/smc_diag.h b/linux/smc_diag.h
index aea7d32..a9d4a51 100644
--- a/linux/smc_diag.h
+++ b/linux/smc_diag.h
@@ -30,4 +30,43 @@ enum {
SMC_DIAG_SHUTDOWN,
};
+/* SMC_DIAG_CONNINFO */
+struct smc_diag_cursor {
+ uint16_t reserved;
+ uint16_t wrap;
+ uint32_t count;
+};
+
+struct smc_diag_conninfo {
+ uint32_t token;
+ uint32_t sndbuf_size;
+ uint32_t rmbe_size;
+ uint32_t peer_rmbe_size;
+ struct smc_diag_cursor rx_prod;
+ struct smc_diag_cursor rx_cons;
+ struct smc_diag_cursor tx_prod;
+ struct smc_diag_cursor tx_cons;
+ uint8_t rx_prod_flags;
+ uint8_t rx_conn_state_flags;
+ uint8_t tx_prod_flags;
+ uint8_t tx_conn_state_flags;
+ struct smc_diag_cursor tx_prep;
+ struct smc_diag_cursor tx_sent;
+ struct smc_diag_cursor tx_fin;
+};
+
+/* SMC_DIAG_LINKINFO */
+struct smc_diag_linkinfo {
+ uint8_t link_id;
+ uint8_t ibname[64]; /* IB_DEVICE_NAME_MAX */
+ uint8_t ibport;
+ uint8_t gid[40];
+ uint8_t peer_gid[40];
+};
+
+struct smc_diag_lgrinfo {
+ struct smc_diag_linkinfo lnk[1];
+ uint8_t role;
+};
+
#endif /* !STRACE_LINUX_SMC_DIAG_H */
diff --git a/netlink_sock_diag.c b/netlink_sock_diag.c
index 43e6f0b..bc2c78f 100644
--- a/netlink_sock_diag.c
+++ b/netlink_sock_diag.c
@@ -61,6 +61,7 @@
#ifdef AF_SMC
# include "xlat/smc_diag_attrs.h"
# include "xlat/smc_diag_extended_flags.h"
+# include "xlat/smc_link_group_roles.h"
# include "xlat/smc_states.h"
#endif
@@ -892,6 +893,92 @@ decode_smc_diag_req(struct tcb *const tcp,
}
static void
+print_smc_diag_cursor(const struct smc_diag_cursor *cursor)
+{
+ tprintf("{reserved=%" PRIu16 ", wrap=%" PRIu16
+ ", count=%" PRIu32 "}",
+ cursor->reserved, cursor->wrap, cursor->count);
+}
+
+static bool
+decode_smc_diag_conninfo(struct tcb *tcp, kernel_ulong_t addr,
+ kernel_ulong_t len, void *const opaque_data)
+{
+ struct smc_diag_conninfo cinfo;
+
+ if (len < sizeof(cinfo))
+ return false;
+ if (umove_or_printaddr(tcp, addr, &cinfo))
+ return true;
+
+ tprintf("{token=%" PRIu32 ", sndbuf_size=%" PRIu32
+ ", rmbe_size=%" PRIu32 ", peer_rmbe_size=%" PRIu32,
+ cinfo.token, cinfo.sndbuf_size,
+ cinfo.rmbe_size, cinfo.peer_rmbe_size);
+ tprints(", rx_prod=");
+ print_smc_diag_cursor(&cinfo.rx_prod);
+ tprints(", rx_cons=");
+ print_smc_diag_cursor(&cinfo.rx_cons);
+ tprints(", tx_prod=");
+ print_smc_diag_cursor(&cinfo.tx_prod);
+ tprints(", tx_cons=");
+ print_smc_diag_cursor(&cinfo.tx_cons);
+ tprintf(", rx_prod_flags=%#0*x, rx_conn_state_flags=%#0*x"
+ ", tx_prod_flags=%#0*x, tx_conn_state_flags=%#0*x",
+ (int) sizeof(cinfo.rx_prod_flags) * 2 + 2,
+ cinfo.rx_prod_flags,
+ (int) sizeof(cinfo.rx_conn_state_flags) * 2 + 2,
+ cinfo.rx_conn_state_flags,
+ (int) sizeof(cinfo.tx_prod_flags) * 2 + 2,
+ cinfo.tx_prod_flags,
+ (int) sizeof(cinfo.tx_conn_state_flags) * 2 + 2,
+ cinfo.tx_conn_state_flags);
+ tprints(", tx_prep=");
+ print_smc_diag_cursor(&cinfo.tx_prep);
+ tprints(", tx_sent=");
+ print_smc_diag_cursor(&cinfo.tx_sent);
+ tprints(", tx_fin=");
+ print_smc_diag_cursor(&cinfo.tx_fin);
+ tprints("}");
+
+ return true;
+}
+
+static bool
+decode_smc_diag_lgrinfo(struct tcb *tcp, kernel_ulong_t addr,
+ kernel_ulong_t len, void *const opaque_data)
+{
+ struct smc_diag_lgrinfo linfo;
+
+ if (len < sizeof(linfo))
+ return false;
+ if (umove_or_printaddr(tcp, addr, &linfo))
+ return true;
+
+ tprintf("{lnk[0]={link_id=%" PRIu8 ", ibname=", linfo.lnk[0].link_id);
+ print_quoted_string((char *) linfo.lnk[0].ibname,
+ sizeof(linfo.lnk[0].ibname), QUOTE_0_TERMINATED);
+ tprintf(", ibport=%" PRIu8 ", gid=", linfo.lnk[0].ibport);
+ print_quoted_string((char *) linfo.lnk[0].gid,
+ sizeof(linfo.lnk[0].gid), QUOTE_0_TERMINATED);
+ tprints(", peer_gid=");
+ print_quoted_string((char *) linfo.lnk[0].peer_gid,
+ sizeof(linfo.lnk[0].peer_gid), QUOTE_0_TERMINATED);
+ tprints("}");
+ tprints(", role=");
+ printxval(smc_link_group_roles, linfo.role, "SMC_???");
+ tprints("}");
+
+ return true;
+}
+
+static nla_decoder_t smc_decoders[] = {
+ [SMC_DIAG_CONNINFO] = decode_smc_diag_conninfo,
+ [SMC_DIAG_LGRINFO] = decode_smc_diag_lgrinfo,
+ [SMC_DIAG_SHUTDOWN] = decode_nla_u8
+};
+
+static void
decode_smc_diag_msg(struct tcb *const tcp,
const struct nlmsghdr *const nlmsghdr,
const uint8_t family,
@@ -934,7 +1021,7 @@ decode_smc_diag_msg(struct tcb *const tcp,
tprints(", ");
decode_nlattr(tcp, addr + offset, len - offset,
smc_diag_attrs, "SMC_DIAG_???",
- NULL, 0, NULL);
+ smc_decoders, ARRAY_SIZE(smc_decoders), NULL);
}
}
#endif
diff --git a/xlat/smc_link_group_roles.in b/xlat/smc_link_group_roles.in
new file mode 100644
index 0000000..d1cc06d
--- /dev/null
+++ b/xlat/smc_link_group_roles.in
@@ -0,0 +1,2 @@
+SMC_CLNT 0
+SMC_SERV 1
--
2.7.4
More information about the Strace-devel
mailing list