21 Commits

Author SHA1 Message Date
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
17d002a252 tests: fix print_quoted_hex output of bytes with high bit set
* tests/tests.h (print_quoted_memory, print_quoted_hex): Change the type
of first argument from "const char *" to "const void *".
* tests/print_quoted_string.c: Likewise.
(print_quoted_hex): Print bytes as unsigned char objects to avoid
unwanted sign extension.
* tests/netlink_protocol.c (send_query): Remove the cast of print_quoted_hex
first argument which is now redundant.
2017-07-08 14:57:44 +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
8d71474ea1 tests: print quotation marks in print_quoted_memory
* tests/print_quoted_string.c (print_quoted_memory): Print opening
and closing quotation marks.
* tests/getcwd.c (main): Do not print quotation marks around
print_quoted_string.
* tests/uname.c (main): Likewise.
* tests/keyctl.c (print_quoted_string_limit): Do not print quotation
marks around print_quoted_memory.
* tests/netlink_protocol.c (send_query): Likewise.
* tests/xattr.c (main): Likewise.
2017-07-07 16:43:41 +00:00
005c67a900 tests: move DEFAULT_STRLEN macro to tests.h
* tests/tests.h [!DEFAULT_STRLEN] (DEFAULT_STRLEN): New macro.
* tests/mincore.c (DEFAULT_STRLEN): Remove.
* tests/mmsg_name.c: Likewise.
* tests/msg_control.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/nlattr.c: Likewise.
* tests/nlattr_inet_diag_msg.c: Likewise.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.
* tests/printstr.c: Likewise.
* tests/xattr.c: Likewise.
* tests/execve.c: Likewise.
(main): Initialize str_a and str_b arrays at run time.
* tests/execveat.c: Likewise.

Suggested-by: JingPiao Chen <chenjingpiao@gmail.com>
2017-07-03 15:14:54 +00:00
4a2a9a7cb1 Include "netlink.h" instead of <linux/netlink.h>
* net.c: Include "netlink.h" instead of <linux/netlink.h>.
* sockaddr.c: Likewise.
* tests/create_nl_socket.c: Likewise.
* tests/net-sockaddr.c: Likewise.
* tests/netlink_audit.c: Likewise.
* tests/netlink_generic.c: Likewise.
* tests/netlink_inet_diag.c: Likewise.
* tests/netlink_netfilter.c: Likewise.
* tests/netlink_route.c: Likewise.
* tests/netlink_selinux.c: Likewise.
* tests/netlink_xfrm.c: Likewise.
* tests/net-yy-netlink.c: Include "netlink.h" instead
of <linux/netlink.h>, remove fallback definition of NETLINK_SOCK_DIAG.
* tests/netlink_netlink_diag.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/netlink_sock_diag.c: Likewise.
* tests/netlink_unix_diag.c: Likewise.
* tests/nlattr.c: Likewise.
2017-06-25 00:40:29 +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
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
0d6d520521 tests: use create_nl_socket in netlink_protocol.test
* tests/netlink_protocol.c (main): Use create_nl_socket.
2017-06-05 14:56:09 +00:00
1274e27487 tests: change netlink_protocol.test to trace sendto syscalls only
* tests/gen_tests.in (netlink_protocol): Replace %network with sendto.
* tests/netlink_protocol.c (main): Update expected output.
2017-06-05 14:56:08 +00:00
8a3551abc8 tests: extend checking of NLMSG_DONE decoding
* tests/netlink_protocol.c (test_nlmsg_done):  Use designated
initializers.  Check decoding of messages with non-integer payload.
2017-06-04 13:40:17 +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
d1cca88c80 tests: fix netlink_protocol on sparc
* tests/netlink_protocol.c (test_nlmsgerr): Do not access fields of an
unaligned structure, this makes architectures like sparc very unhappy.
2017-04-21 23:01:22 +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
b9bac78553 tests: use sprintrc in tests/netlink_protocol.c
* tests/netlink_protocol.c (main): Use sprintrc.
2016-09-20 12:29:35 +00:00
9c652ccf90 tests: skip netlink_protocol.test on old systems
* tests/netlink_protocol.c: Check that HAVE_SYS_XATTR_H is defined.
Include <stdlib.h> and <sys/xattr.h>.
(main): Check that system.sockprotoname attribute is supported.
2016-07-21 20:57:55 +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
73362a23fd tests: extend netlink protocol check
* tests/netlink_protocol.c (send_query): Check that no part
of netlink message is fetched beyond the end of message.
Check decoding of zero address and zero length messages.
Check decoding of messages with nlmsg_len exceeding message length.
2016-07-07 10:01:25 +00:00
Fabien Siron
1b1baea407 tests: check decoding of netlink protocol
* tests/netlink_protocol.test: New test.
* tests/netlink_protocol.c: New file.
* tests/.gitignore: Add netlink_protocol.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add netlink_protocol.test.
2016-07-07 09:48:32 +00:00