From dc84eddc8169df596fdc87faf7d73820ef73be4b Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 13 Jun 2017 17:26:44 +0900 Subject: [PATCH] netlink: add decoding of NETLINK_GENERIC protocol families 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, {{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 Signed-off-by: Dmitry V. Levin --- netlink.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/netlink.c b/netlink.c index dc1a070d..24ac1ecb 100644 --- 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, -- 2.40.0