]> granicus.if.org Git - strace/commitdiff
netlink: add a basic netlink attribute parser of AF_SMC diag
authorJingPiao Chen <chenjingpiao@gmail.com>
Tue, 27 Jun 2017 10:10:06 +0000 (18:10 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 30 Jun 2017 21:38:49 +0000 (21:38 +0000)
* netlink_sock_diag.c: Include "xlat/smc_diag_attrs.h".
(decode_smc_diag_msg): Use decode_nlattr.
* xlat/smc_diag_attrs.in: New file.

netlink_sock_diag.c
xlat/smc_diag_attrs.in [new file with mode: 0644]

index 47ee8aba5d64ef302db83b6d3739bc81dc36be4f..60c8627b26ad587df135a921c9c345f02d434117 100644 (file)
@@ -55,6 +55,7 @@
 #include "xlat/packet_diag_show.h"
 
 #ifdef AF_SMC
+# include "xlat/smc_diag_attrs.h"
 # include "xlat/smc_diag_extended_flags.h"
 # include "xlat/smc_states.h"
 #endif
@@ -500,7 +501,8 @@ decode_smc_diag_msg(struct tcb *const tcp,
                    const kernel_ulong_t len)
 {
        struct smc_diag_msg msg = { .diag_family = family };
-       const size_t offset = sizeof(msg.diag_family);
+       size_t offset = sizeof(msg.diag_family);
+       bool decode_nla = false;
 
        PRINT_FIELD_XVAL("{", msg, diag_family, addrfams, "AF_???");
        tprints(", ");
@@ -520,11 +522,18 @@ decode_smc_diag_msg(struct tcb *const tcp,
                        print_inet_diag_sockid(&msg.id, AF_INET);
                        PRINT_FIELD_U(", ", msg, diag_uid);
                        PRINT_FIELD_U(", ", msg, diag_inode);
+                       decode_nla = true;
                }
        } else
                tprints("...");
        tprints("}");
 
+       offset = NLA_ALIGN(sizeof(msg));
+       if (decode_nla && len > offset) {
+               tprints(", ");
+               decode_nlattr(tcp, addr + offset, len - offset,
+                             smc_diag_attrs, "SMC_DIAG_???");
+       }
 }
 #endif
 
diff --git a/xlat/smc_diag_attrs.in b/xlat/smc_diag_attrs.in
new file mode 100644 (file)
index 0000000..cd6179b
--- /dev/null
@@ -0,0 +1,5 @@
+#unconditional
+SMC_DIAG_NONE
+SMC_DIAG_CONNINFO
+SMC_DIAG_LGRINFO
+SMC_DIAG_SHUTDOWN