]> granicus.if.org Git - strace/commitdiff
netlink: add decoding of NETLINK_GENERIC protocol families
authorMasatake YAMATO <yamato@redhat.com>
Tue, 13 Jun 2017 08:26:44 +0000 (17:26 +0900)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 19 Jun 2017 21:45:58 +0000 (21:45 +0000)
NETLINK_GENERIC is a protocol stacked on netlink protocol.

When a NETLINK_GENERIC subsystem registers its "family" name in the
kernel at run time, an integer value associated with this name is
assigned by the kernel.  This integer value is specified in struct
nlmsghdr.nlmsg_type of subsequent communications with the
NETLINK_GENERIC subsystem.

This change implements decoding of NETLINK_GENERIC message types in
symbolic form, for example:

  $ ./strace -yy -e 'sendto' ip tcp_metrics > /dev/null
  sendto(4<NETLINK:[GENERIC:12345]>, {{len=20, type=tcp_metrics, ...
  +++ exited with 0 +++

Note that type= specifying the NETLINK_GENERIC protocol family
is decoded properly.

* netlink.c (decode_nlmsg_type_generic): New function.
(nlmsg_types): Add NETLINK_GENERIC entry.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
netlink.c

index dc1a070d6cf76f6d4cfd9a34222d49beaac70431..24ac1ecbb3ada0b6eb581c5f49bf05759e260764 100644 (file)
--- a/netlink.c
+++ b/netlink.c
@@ -108,6 +108,14 @@ decode_nlmsg_type_default(const struct xlat *const xlat,
        printxval(xlat, type, dflt);
 }
 
+static void
+decode_nlmsg_type_generic(const struct xlat *const xlat,
+                         const uint16_t type,
+                         const char *const dflt)
+{
+       printxval(genl_families_xlat(), type, dflt);
+}
+
 static void
 decode_nlmsg_type_netfilter(const struct xlat *const xlat,
                            const uint16_t type,
@@ -146,6 +154,11 @@ static const struct {
        const char *const dflt;
 } nlmsg_types[] = {
        [NETLINK_AUDIT] = { NULL, nl_audit_types, "AUDIT_???" },
+       [NETLINK_GENERIC] = {
+               decode_nlmsg_type_generic,
+               NULL,
+               "GENERIC_FAMILY_???"
+       },
        [NETLINK_NETFILTER] = {
                decode_nlmsg_type_netfilter,
                nl_netfilter_subsys_ids,