Commit Graph

49 Commits

Author SHA1 Message Date
Eugene Syromiatnikov
c46fefcad3 Add tcp arguments to netlink calls
Since they call tracee-specific socket/sendmsg/recvmsg, we'd like to
pass tcp there.

* defs.h (genl_families_xlat): Add tcp argument.
* netlink.c (decode_nlmsg_type_default, decode_nlmsg_type_generic,
decode_nlmsg_type_netfilter, typedef nlmsg_types_decoder_t): Likewise.
(decode_nlmsg_type): Add tcp argument. Pass tcp to decoder call.
(print_nlmsghdr): Pass tcp to the decode_nlmsg_type call.
* socketutils.c (send_query, receive_responses): Add tcp argument.
(inet_send_query, unix_send_query, netlink_send_query, ): Add tcp argument.
Pass tcp to the send_query call.
(unix_get): Add tcp argument. Pass tcp to the unix_send_query and
receive_responses calls.
(inet_get): Add tcp argument. Pass tcp to the inet_send_query and
receive_responses calls.
(tcp_v4_get, udp_v4_get, tcp_v6_get, udp_v6_get): Add tcp argument. Pass
tcp to the inet_get call.
(netlink_get): Add tcp argument. Pass tcp to the netlink_send_query and
receive_responses calls.
(protocols): Add tcp argument to the get field.
(get_sockaddr_by_inode_uncached): Add tcp argument. Pass tcp to
the protocols[].get calls.
(print_sockaddr_by_inode_uncached): Add tcp argument. Pass tcp to
the get_sockaddr_by_inode_uncached call.
(get_sockaddr_by_inode): Pass tcp to the get_sockaddr_by_inode_uncached
call.
(print_sockaddr_by_inode): Pass tcp to the
print_sockaddr_by_inode_uncached call.
(genl_send_dump_families): Add tcp argument. Pass tcp to the send_query
call.
(genl_families_xlat): Add tcp argument. Pass tcp to the
genl_send_dump_families and receive_responses calls.
2018-01-07 16:46:32 +00:00
JingPiao Chen
58739bf243 netlink: decode NETLINK_NETFILTER netlink message flags
* netlink.c (decode_nlmsg_flags_netfilter): New function.
(nlmsg_flags): Add NETLINK_NETFILTER.
* NEWS: Mention this.
2017-10-26 18:08:03 +00:00
JingPiao Chen
b56c8dbcfb netlink: decode netlink message delete flags
* netlink.c: Include "xlat/netlink_delete_flags.h".
(decode_nlmsg_flags_crypto, decode_nlmsg_flags_route,
decode_nlmsg_flags_xfrm): Decode delete flags.
* netlink.h (NLM_F_NONREC): New macro.
* xlat/netlink_delete_flags.in: New file.
* tests/netlink_crypto.c (test_nlmsg_flags): Check this.
* tests/netlink_route.c (test_nlmsg_flags): Likewise.
* tests/netlink_xfrm.c (test_nlmsg_flags): Likewise.
2017-10-26 18:07:03 +00:00
JingPiao Chen
695de1df13 netlink: refactor decode_nlmsg_flags
Refactor decode_nlmsg_flags to make it family-specific, just like
decode_nlmsg_type and decode_payload.

* netlink.c (decode_nlmsg_flags_crypto, decode_nlmsg_flags_route,
decode_nlmsg_flags_sock_diag, decode_nlmsg_flags_xfrm): New functions.
(nlmsg_flags_decoder_t): New typedef.
(nlmsg_flags): New array.
(decode_nlmsg_flags): Use it.
2017-10-26 18:04:08 +00:00
JingPiao Chen
c5d6bccdb0 netlink: decode NETLINK_NETFILTER netlink message types
* netlink.c: Include "xlat/nf_acct_msg_types.h",
"xlat/nf_cthelper_msg_types.h", "xlat/nf_ctnetlink_exp_msg_types.h",
"xlat/nf_ctnetlink_msg_types.h", "xlat/nf_cttimeout_msg_types.h",
"xlat/nf_ipset_msg_types.h", "xlat/nf_nft_compat_msg_types.h",
"xlat/nf_nftables_msg_types.h", "xlat/nf_osf_msg_types.h",
"xlat/nf_queue_msg_types.h", and "xlat/nf_ulog_msg_types.h".
(nf_nlmsg_types): New array.
(decode_nlmsg_type_netfilter): Use it.
* NEWS: Mention this.
* xlat/nf_acct_msg_types.in: New file.
* xlat/nf_cthelper_msg_types.in: Likewise.
* xlat/nf_ctnetlink_exp_msg_types.in: Likewise.
* xlat/nf_ctnetlink_msg_types.in: Likewise.
* xlat/nf_cttimeout_msg_types.in: Likewise.
* xlat/nf_ipset_msg_types.in: Likewise.
* xlat/nf_nft_compat_msg_types.in: Likewise.
* xlat/nf_nftables_msg_types.in: Likewise.
* xlat/nf_osf_msg_types.in: Likewise.
* xlat/nf_queue_msg_types.in: Likewise.
* xlat/nf_ulog_msg_types.in: Likewise.
* tests/netlink_netfilter.c (test_nlmsg_type): Update expected output.
2017-09-24 10:07:57 +00:00
JingPiao Chen
4c437e1856 Move nl_route_types definition from netlink.c to netlink_route.c
The side effect of #include "xlat/nl_route_types.h" is
RTM_* constants properly defined in that header file.
While netlink.c does not use these constants itself,
netlink_route.c is going to need them soon.

* defs.h (nl_route_types): New xlat prototype.
* netlink.c: Move inclusion of "xlat/nl_route_types.h" ...
* netlink_route.c: ... here.
2017-08-09 08:43:49 +08:00
JingPiao Chen
670390ac71 netlink: introduce family specific decoder of NETLINK_ROUTE
* netlink_route.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink_route): New prototype.
* netlink.c (netlink_decoders): Add NETLINK_ROUTE.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-09 08:18:43 +08:00
JingPiao Chen
6555267d92 netlink: add decoding of NETLINK_KOBJECT_UEVENT messages
* netlink.c (decode_netlink): Print NETLINK_KOBJECT_UEVENT messages
as a string using printstrn.
2017-08-08 16:36:59 +00:00
JingPiao Chen
338f0592ae netlink: call get_fd_nl_family before nlmsghdr decoding
Prepare for decoding of NETLINK_KOBJECT_UEVENT.  Messages of the latter,
unlike traditional netlink families, don't contain a header at all.

* netlink.c (NL_FAMILY_*): Remove enum.
(get_fd_nl_family): Replace NL_FAMILY_ERROR with -1.
(decode_nlmsg_type): Update the comment.
Skip family specific type decoders for type < NLMSG_MIN_TYPE.
(decode_nlmsghdr_with_payload): Skip family specific decoders
for type < NLMSG_MIN_TYPE && type != NLMSG_DONE.
(print_nlmsghdr): Move get_fd_nl_family invocation ...
(decode_nlmsghdr_with_payload): ... here.
2017-08-08 16:36:59 +00:00
JingPiao Chen
f9638667ee netlink.c: fix indentation
* netlink.c (print_cookie): Fix indentation.
2017-08-07 12:48:20 +00:00
JingPiao Chen
9da72b5251 netlink: add a basic parser of NETLINK_CRYPTO messages
* netlink_crypto.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink_crypto): New prototype.
* netlink.c (netlink_decoders): Add NETLINK_CRYPTO.
* NEWS: Mention this.
2017-07-24 10:47:19 +00:00
c56a3c361c Adjust prototypes of netlink parsing functions
Change the type of "len" argument that is based
on struct nlmsghdr.nlmsg_len from kernel_ulong_t to unsigned int.

* defs.h (netlink_decoder_t, DECL_NETLINK): Change "len" argument type
from kernel_ulong_t to unsigned int.
* netlink.c (decode_nlmsgerr_attr_cookie, decode_nlmsgerr,
decode_payload): Likewise.
* netlink_selinux.c (decode_netlink_selinux): Likewise.
* netlink_sock_diag.c (decode_family, decode_unix_diag_req,
decode_meminfo, decode_unix_diag_vfs, decode_unix_diag_inode,
decode_unix_diag_rqlen, decode_unix_diag_msg, decode_netlink_diag_req,
print_group, decode_netlink_diag_ring, decode_netlink_diag_flags,
decode_netlink_diag_msg, decode_packet_diag_req,
decode_packet_diag_info, decode_packet_diag_mclist,
decode_packet_diag_ring, decode_packet_diag_filter,
decode_packet_diag_msg, decode_inet_addr, decode_inet_diag_hostcond,
decode_inet_diag_markcond, decode_bytecode_data, decode_inet_diag_bc_op,
decode_inet_diag_req_compat, decode_inet_diag_req_v2,
decode_inet_diag_req, decode_inet_diag_meminfo, decode_tcpvegas_info,
decode_tcp_dctcp_info, decode_tcp_bbr_info, decode_inet_diag_msg,
decode_smc_diag_req, decode_smc_diag_conninfo, decode_smc_diag_lgrinfo,
decode_smc_diag_msg, netlink_diag_decoder_t, decode_netlink_sock_diag):
Likewise.
* nlattr.c (fetch_nlattr, decode_nlattr_with_data, decode_nlattr,
decode_nla_str, decode_nla_strn, DECODE_NLA_INTEGER): Likewise.
* nlattr.h (nla_decoder_t, DECL_NLA, decode_nlattr): Likewise.
2017-07-19 10:07:34 +00:00
JingPiao Chen
3bfaa0f744 netlink: decode nlmsgerr attributes
* netlink.c: Include "nlattr.h" and "xlat/nlmsgerr_attrs.h".
(print_cookie, decode_nlmsgerr_attr_cookie): New functions.
(nlmsgerr_nla_decoders): New array.
(decode_nlmsgerr): Use it.
* xlat/nlmsgerr_attrs.in: New file.
* NEWS: Mention this.
2017-07-19 09:25:58 +00:00
JingPiao Chen
9c9e061536 netlink: adjust decode_nlmsgerr for extended ACK reporting
Extended ACK reporting introduced by linux kernel commit
v4.11-rc5-1382-g2d4bc93.

* netlink.h (NLM_F_CAPPED): New macro.
* netlink.c (decode_payload): Pass
nlmsghdr->nlmsg_flags & NLM_F_CAPPED to decode_nlmsgerr.
(decode_nlmsgerr): Adjust the length pass to
decode_nlmsghdr_with_payload.
2017-07-19 09:25:58 +00:00
JingPiao Chen
9ec9ad9c0f netlink: decode netlink message ack flags
* netlink.c: Include "xlat/netlink_ack_flags.h".
(decode_nlmsg_flags): Decode ack flags when type == NLMSG_ERROR.
* xlat/netlink_ack_flags.in: New file.
* NEWS: Mention this.
* tests/netlink_protocol.c (test_ack_flags): New function, check this.
(main): Use it.
2017-07-19 09:25:58 +00:00
JingPiao Chen
37dfe8c769 netlink: decode NETLINK_SELINUX protocol
* netlink_selinux.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink_selinux): New prototype.
* netlink.c (netlink_decoders): Add NETLINK_SELINUX.
2017-07-16 18:26:10 +00:00
JingPiao Chen
c4d14b4457 netlink: add decoding of NETLINK_CRYPTO nlmsg_flags
* netlink.c (decode_nlmsg_flags): Add NETLINK_CRYPTO.
2017-07-12 21:08:03 +00:00
JingPiao Chen
771c6be31a netlink: add decoding of NETLINK_CRYPTO message types
* xlat/nl_crypto_types.in: New file.
* netlink.c: Include "xlat/nl_crypto_types.h".
(nlmsg_types): Add NETLINK_CRYPTO.
2017-07-12 21:08:03 +00:00
JingPiao Chen
5626a08061 netlink: print unrecognized netlink messages in hex
* netlink.c (fetch_nlmsghdr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (send_query): Update expected output.
2017-07-07 16:43:41 +00:00
JingPiao Chen
b61dfe9a37 netlink: print unrecognized netlink payload in hex
* netlink.c (decode_payload): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (send_query, test_nlmsgerr,
test_nlmsg_done): Update expected output.
* tests/netlink_generic.c (test_nlmsg_type): Likewise.
2017-07-07 16:43:41 +00:00
JingPiao Chen
dbb622c061 netlink: print unrecognized nlmsgerr in hex
* netlink.c (decode_nlmsgerr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (test_nlmsgerr): Update expected output.
2017-07-07 16:43:41 +00:00
JingPiao Chen
54aed21036 netlink: pass NLMSG_DONE messages to family specific payload decoders
While many NLMSG_DONE messages indeed have payload containing
just one integer, there are exceptions. Handle this by passing
payloads of NLMSG_DONE messages to family specific netlink
payload decoders.

* netlink.c (print_nlmsghdr): Do not skip family detection
for nlmsg_type == NLMSG_DONE.
(decode_nlmsg_type): Skip family specific type decoders
for type == NLMSG_DONE.
(decode_nlmsg_flags): Skip family specific decoding of flags
for type == NLMSG_DONE.
(decode_netlink_sock_diag): Skip for nlmsg_type == NLMSG_DONE.
2017-06-27 09:37:09 +00:00
JingPiao Chen
72ecbdb9f3 netlink: introduce netlink.h
* netlink.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* netlink_sock_diag.c: Include "netlink.h",
remove <sys/socket.h> and <linux/netlink.h>.
* netlink.c: Likewise.
(NLMSG_HDRLEN): Move to netlink.h.
* tests/netlink_protocol.c: Replace <linux/netlink.h> with "netlink.h".
* tests/netlink_sock_diag.c: Likewise.
2017-06-21 16:31:04 +00:00
Masatake YAMATO
dc84eddc81 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<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>
2017-06-19 21:45:58 +00:00
f639f90241 netlink: do not print extra braces around payloadless nlmsghdr
* netlink.c (decode_nlmsghdr_with_payload): Print braces before
print_nlmsghdr and after decode_payload iff decode_payload is invoked.
* tests/netlink_audit.c (test_nlmsg_type): Update expected output.
* tests/netlink_netfilter.c: Likewise.
* tests/netlink_selinux.c: Likewise.
* tests/netlink_protocol.c (send_query): Likewise.
* tests/netlink_route.c (test_nlmsg_type, test_nlmsg_flags): Likewise.
* tests/netlink_sock_diag.c: Likewise.
* tests/netlink_xfrm.c: Likewise.
2017-06-18 21:43:39 +00:00
09c4dac214 netlink: introduce family specific payload decoders
* defs.h (netlink_decoder_t): New typedef.
(DECL_NETLINK): New macro.
(decode_netlink_sock_diag): New prototype.
* netlink.c (netlink_decoders): New array.
(decode_payload): Use it to invoke netlink family specific decoders.
* netlink_sock_diag.c: New file.
* Makefile.am (strace_SOURCES): Add it.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
Co-authored-by: JingPiao Chen <chenjingpiao@gmail.com>
2017-06-15 00:30:47 +00:00
44049f87ab netlink: refactor decode_nlmsg_type
* netlink.c (decode_nlmsg_type_default, decode_nlmsg_type_netfilter):
New functions.
(nlmsg_types_decoder_t): New typedef.
(nlmsg_types): Add decoder field.
(decode_nlmsg_type): Use it.
2017-06-14 23:32:45 +00:00
127962f217 Introduce printflags_ex function
Add printflags_ex extension over printflags64 that, similar
to printxvals, takes a NULL-terminated sequence of xlat pointers.

* defs.h (printflags_ex): New prototype.
(printflags64): Turn into a thin wrapper around printflags_ex.
* netlink.c (decode_nlmsg_flags): Use printflags_ex.
* util.c (printflags_ex): New function.
(printflags64): Remove.
* xlat/netlink_get_flags.in: Remove entries listed
in xlat/netlink_flags.in file.
* xlat/netlink_new_flags.in: Likewise.
2017-06-08 22:26:46 +00:00
JingPiao Chen
fe36545586 netlink: implement generic nlmsg_flags decoding
* netlink.c: Include "xlat/netlink_get_flags.h"
and "xlat/netlink_new_flags.h".
(decode_nlmsg_flags): New function.
(print_nlmsghdr): Use it.
* xlat/netlink_get_flags.in: New file.
* xlat/netlink_new_flags.in: Likewise.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-06-08 22:26:46 +00:00
6706343b2d netlink: add decoding of NETLINK_NETFILTER message types
* xlat/nl_netfilter_msg_types.in: New file.
* xlat/nl_netfilter_subsys_ids.in: Likewise.
* netlink.c: Include "xlat/nl_netfilter_msg_types.h"
and "xlat/nl_netfilter_subsys_ids.h".
(nlmsg_types): Add NETLINK_NETFILTER.
(decode_nlmsg_type): Handle NETLINK_NETFILTER.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-05 11:52:11 +00:00
d0231ef60b netlink: add decoding of NETLINK_XFRM message types
* xlat/nl_xfrm_types.in: New file.
* netlink.c: Include "xlat/nl_xfrm_types.h".
(nlmsg_types): Add NETLINK_XFRM.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-05 11:52:11 +00:00
c78de345e0 netlink: add decoding of NETLINK_SELINUX message types
* xlat/nl_selinux_types.in: New file.
* netlink.c: Include "xlat/nl_selinux_types.h".
(nlmsg_types): Add NETLINK_SELINUX.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-05 11:52:11 +00:00
d5435f74ed netlink: add decoding of NETLINK_ROUTE message types
* xlat/nl_route_types.in: New file.
* netlink.c: Include <linux/rtnetlink.h> and "xlat/nl_route_types.h".
(nlmsg_types): Add NETLINK_ROUTE.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-05 11:52:11 +00:00
c5db18d946 netlink: add decoding of NETLINK_AUDIT message types
* xlat/nl_audit_types.in: New file.
* netlink.c: Include <linux/audit.h> and "xlat/nl_audit_types.h".
(nlmsg_types): Add NETLINK_AUDIT.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-05 11:52:11 +00:00
8700030e48 netlink: implement generic nlmsg_type decoding
Implement a pluggable mechanism of nlmsg_type decoding.
Add decoding of NETLINK_SOCK_DIAG types.

* linux/sock_diag.h (SOCK_DESTROY): New macro.
* xlat/nl_sock_diag_types.in: New file.
* netlink.c: Include xlat/nl_sock_diag_types.h.
(get_fd_nl_family, decode_nlmsg_type): New functions.
(print_nlmsghdr): Use them for nlmsg_type decoding.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-05 11:52:11 +00:00
1b634252c7 netlink: add netlink family argument to printers and decoders
* netlink.c (NL_FAMILY_ERROR, NL_FAMILY_DEFAULT): New constants.
(print_nlmsghdr): Add netlink family argument, change return type
to int, return family.
(decode_nlmsghdr_with_payload, decode_nlmsgerr, decode_payload): Add
netlink family argument.  All callers updated.
2017-06-05 11:52:11 +00:00
Fabien Siron
8240e4e983 Add file descriptor argument to decode_netlink
* defs.h (decode_netlink): Add file descriptor argument.
* io.c (print_iovec): Specify file descriptor to decode_netlink.
* net.c (decode_sockbuf): Likewise.
* netlink.c (print_nlmsghdr, decode_nlmsghdr_with_payload,
decode_nlmsgerr, decode_payload, decode_nlmsghdr_with_payload,
decode_netlink): Likewise.
All callers updated.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-06-05 11:52:11 +00:00
c826fa0f71 Move netlink_protocols definition from net.c to netlink.c
The side effect of #include "xlat/netlink_protocols.h" is
NETLINK_* constants properly defined in that header file.
While net.c does not use these constants itself, netlink.c
is going to need them soon.

* net.c: Move inclusion of "xlat/netlink_protocols.h" ...
* netlink.c: ... here.
2017-06-04 17:03:44 +00:00
JingPiao Chen
852046ce0e netlink: decode NLMSG_DONE messages
* netlink.c (decode_payload): Decode NLMSG_DONE messages.
* tests/netlink_protocol.c (test_nlmsg_done): New function
for checking decoding of NLMSG_DONE messages.
(main): Use it.
2017-06-04 13:17:06 +00:00
28e478a6eb netlink: move NLMSG_ERROR payload length check to nlmsgerr decoder
Move decoder specific check to the decoder.

* netlink.c (decode_payload): Move NLMSG_ERROR payload length check ...
(decode_nlmsgerr): ... here.
2017-06-02 22:22:22 +00:00
Eugene Syromyatnikov
9d095c7860 Add copyright headers 2017-05-22 17:33:51 +00:00
1be0e27b0b netlink: decode NLMSG_ERROR messages
* netlink.c (decode_nlmsgerr, decode_payload): New functions.
(decode_nlmsghdr_with_payload): Use decode_payload.
* tests/netlink_protocol.c (send_query): Check decoding
of NLMSG_ERROR messages.
* NEWS: Mention this change.
2017-04-17 04:37:41 +00:00
51929c017a netlink: avoid using unaligned sizeof(struct nlmsghdr) unnecessarily
* netlink.c (NLMSG_HDRLEN): Redefine.
(decode_nlmsghdr_with_payload, decode_netlink): Use it instead
of sizeof(struct nlmsghdr).
2017-04-17 04:37:29 +00:00
7fa3d78319 Automatically replace kernel_(scno|ureg)_t with kernel_ulong_t
Remove temporary types created for transition from long
to kernel_ulong_t.

Automatically replace kernel_scno_t and kernel_ureg_t with
kernel_ulong_t using
$ git grep -El 'kernel_(scno|ureg)_t' |
  xargs sed -ri 's/kernel_(scno|ureg)_t/kernel_ulong_t/g'

* kernel_types.h (kernel_scno_t, kernel_ureg_t): Remove.
All users updated.
2016-12-26 10:43:34 +00:00
b19829eaf4 netlink: change size types from unsigned long to kernel_ureg_t
* defs.h (decode_netlink): Change len argument type from unsigned long
to kernel_ureg_t.
* netlink.c (fetch_nlmsghdr): Likewise.
(decode_nlmsghdr_with_payload): Likewise.  Change nlmsg_len variable
type from unsigned long to unsigned int.
(decode_netlink): Change the type of len argument and next_len variable
from unsigned long to kernel_ureg_t.  Change nlmsg_len variable type
from unsigned long to unsigned int.
2016-12-25 11:32:46 +00:00
a940d1a60f printstr: rename to printstrn, add printstr as a thin wrapper
As about half of all printstr uses cases are invocations with the last
argument set to -1, create a dedicated function for this use case.

* defs.h (printstr): Rename to printstrn.  All callers updated.
(printstr): New static inline function.  All callers updated.
2016-12-25 11:32:45 +00:00
b6b3dc4361 decode_netlink: change address argument type from unsigned long to kernel_ureg_t
* defs.h (decode_netlink) Change address argument type
from unsigned long to kernel_ureg_t.
* netlink.c (fetch_nlmsghdr, decode_nlmsghdr_with_payload,
decode_netlink): Likewise.
2016-12-23 19:26:57 +00:00
deb0c18871 netlink: handle multipart netlink messages
Handle multipart netlink messages made of multiple struct nlmsghdr
headers with associated payload in one byte stream.

* netlink.c (fetch_nlmsghdr, print_nlmsghdr,
decode_nlmsghdr_with_payload): New functions.
(decode_netlink): Use them.
* tests/netlink_parsing.c (send_query): Check them.
2016-07-08 16:01:49 +00:00
Fabien Siron
2850f745ca Add a general netlink socket parser
Introduce a general socket netlink parser which prints the header and
a string for the remaining part of the buffer.  It doesn't handle all
the netlink flags and types yet because the parser needs more
information, this will be implemented later.

* net.c (decode_sockbuf): New function.
(SYS_FUNC(send), SYS_FUNC(sendto), SYS_FUNC(recv), SYS_FUNC(recvfrom)):
Use it instead of printstr.
* msghdr.c (print_msghdr): Pass IOV_DECODE_NETLINK to tprint_iov_upto()
for netlink sockets.
* netlink.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink, getfdproto): New prototypes.
(iov_decode): Add IOV_DECODER_NETLINK.
* io.c (print_iovec): Use decode_netlink().
* util.c (getfdproto): Remove static keyword.
* xlat/netlink_flags.in: New file.
* xlat/netlink_types.in: New file.
2016-07-07 09:46:51 +00:00