[PATCH v3 4/5] netlink: decode "family" field of Netlink GENERIC protocol
Masatake YAMATO
yamato at redhat.com
Tue Jun 13 08:26:44 UTC 2017
Example session:
$ ./strace -yy -e 'sendto' ip tcp_metrics > /dev/null
sendto(4<NETLINK:[GENERIC:7939]>, {{len=20, type=tcp_metrics, ...
+++ exited with 0 +++
type= is decoded well.
* netlink.c (nlmsg_types): Remove const modifiers to allow to
install a xlat table for decoding the field made at run-time.
Add an element for NETLINK_GENERIC.
(decode_nlmsg_type): Install the xlat table to the NETLINK_GENERIC
element of nlmsg_types.
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
netlink.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/netlink.c b/netlink.c
index 049843d..541fa59 100644
--- a/netlink.c
+++ b/netlink.c
@@ -100,11 +100,12 @@ get_fd_nl_family(struct tcb *const tcp, const int fd)
return NL_FAMILY_ERROR;
}
-static const struct {
- const struct xlat *const xlat;
+static struct {
+ const struct xlat *xlat;
const char *const dflt;
} nlmsg_types[] = {
[NETLINK_AUDIT] = { nl_audit_types, "AUDIT_???" },
+ [NETLINK_GENERIC] = { NULL, "GENERIC_FAMILY_???" },
[NETLINK_NETFILTER] = { nl_netfilter_subsys_ids, "NFNL_SUBSYS_???" },
[NETLINK_ROUTE] = { nl_route_types, "RTM_???" },
[NETLINK_SELINUX] = { nl_selinux_types, "SELNL_MSG_???" },
@@ -119,6 +120,9 @@ static const struct {
static void
decode_nlmsg_type(const uint16_t type, const unsigned int family)
{
+ if (!nlmsg_types[NETLINK_GENERIC].xlat)
+ nlmsg_types[NETLINK_GENERIC].xlat = genl_families_xlat();
+
if (family < ARRAY_SIZE(nlmsg_types)
&& nlmsg_types[family].xlat) {
if (family == NETLINK_NETFILTER) {
--
2.9.4
More information about the Strace-devel
mailing list