]> granicus.if.org Git - strace/log
strace
7 years agoMove offsetofend from defs.h to macros.h
Dmitry V. Levin [Wed, 26 Jul 2017 10:28:25 +0000 (10:28 +0000)]
Move offsetofend from defs.h to macros.h

* defs.h (offsetofend): Move ...
* macros.h: ... here.

7 years agobpf: print unused fields of union bpf_attr if one of them is non-zero
Dmitry V. Levin [Wed, 26 Jul 2017 10:28:25 +0000 (10:28 +0000)]
bpf: print unused fields of union bpf_attr if one of them is non-zero

When the size argument specifies more data than necessary for the given
command, kernel checks that all unused fields of union bpf_attr are
zero.  Print this extra data when it contains non-zero bytes to enhance
debugging experience.

* bpf.c (decode_attr_extra_data): New function.
(decode_BPF_MAP_CREATE, decode_BPF_MAP_UPDATE_ELEM,
decode_BPF_MAP_DELETE_ELEM, bpf_map_io, decode_BPF_PROG_LOAD,
decode_BPF_OBJ_PIN, decode_BPF_OBJ_GET, decode_BPF_PROG_ATTACH,
decode_BPF_PROG_DETACH): Use it to print extra data passed
via bpf_attr pointer.
(bpf_obj_manage, bpf_prog_attach_detach): Remove.
* tests/bpf.c (map_delete_elem): New function.
(main): Use it.

7 years agobpf: change handling of big and unaccessible data to match the kernel
Dmitry V. Levin [Wed, 26 Jul 2017 10:28:25 +0000 (10:28 +0000)]
bpf: change handling of big and unaccessible data to match the kernel

When the size argument exceeds PAGE_SIZE, the kernel fails with E2BIG
without parsing union bpf_attr.
When the whole chunk of memory specified by addr and size arguments is
not readable, the kernel fails with EFAULT.

* bpf.c (DECL_BPF_CMD_DECODER) <bpf_cmd_decoder>: Add const qualifier
to size argument, add data argument.
(decode_BPF_MAP_CREATE, decode_BPF_MAP_UPDATE_ELEM,
decode_BPF_MAP_DELETE_ELEM, bpf_map_io, decode_BPF_PROG_LOAD,
bpf_obj_manage, bpf_prog_attach_detach): Move size argument check and
memory fetching ...
(SYS_FUNC(bpf)) ... here, add PAGE_SIZE check, pass fetched memory
to command-specific parsers.

7 years agobpf: replace big switch statement with a dispatch table
Dmitry V. Levin [Tue, 25 Jul 2017 12:47:19 +0000 (12:47 +0000)]
bpf: replace big switch statement with a dispatch table

* bpf.c (DECL_BPF_CMD_DECODER, DEF_BPF_CMD_DECODER, BPF_CMD_ENTRY):
New macros.
(bpf_cmd_decoder_t): New typedef.
Rename static parser functions using DEF_BPF_CMD_DECODER.
(decode_BPF_MAP_LOOKUP_ELEM, decode_BPF_MAP_GET_NEXT_KEY): New proxy
functions.
(SYS_FUNC(bpf)): Replace big switch statement with a dispatch table.

7 years agobpf: use PRINT_FIELD_* macros
Dmitry V. Levin [Tue, 25 Jul 2017 12:47:19 +0000 (12:47 +0000)]
bpf: use PRINT_FIELD_* macros

* print_fields.h (PRINT_FIELD_STR, PRINT_FIELD_PATH): New macros.
* bpf.c: Include "print_fields.h".
(bpf_map_create): Use PRINT_FIELD_U and PRINT_FIELD_XVAL.
(bpf_map_update_elem): Use PRINT_FIELD_FD, PRINT_FIELD_X, and
PRINT_FIELD_XVAL.
(bpf_map_delete_elem, bpf_map_io): Use PRINT_FIELD_FD and PRINT_FIELD_X.
(bpf_prog_load): Use PRINT_FIELD_STR, PRINT_FIELD_U, PRINT_FIELD_X,
and PRINT_FIELD_XVAL.
(bpf_obj_manage): Use PRINT_FIELD_FD and PRINT_FIELD_PATH.
(bpf_prog_attach_detach): Use PRINT_FIELD_FD, PRINT_FIELD_FLAGS,
and PRINT_FIELD_XVAL.

7 years agoAdd terminating comment after each DECL_* macro definition
Eugene Syromyatnikov [Tue, 25 Jul 2017 10:57:11 +0000 (12:57 +0200)]
Add terminating comment after each DECL_* macro definition

In an attempt to improve readability.

* defs.h (DECL_IOCTL, DECL_NETLINK, DECL_PRINTNUM, DECL_PRINTNUM_ADDR,
ATTRIBUTE_FORMAT): Add comment that marks end of macro definition.
* netlink_sock_diag (DECL_NETLINK_DIAG_DECODER): Likewise.
* nlattr.h (DECL_NLA): Likewise.

7 years agoIntroduce print_quoted_cstring
Dmitry V. Levin [Mon, 24 Jul 2017 12:10:54 +0000 (12:10 +0000)]
Introduce print_quoted_cstring

In many places where kernel expects a NUL-terminated string of length
up to a known fixed limit, e.g. when a NUL-terminated string is
a fixed-size field of a structure, strace does not print the last byte
assuming it is NUL, which is not always the case.

Change output format for such strings to distinguish NUL-terminated
strings from non-NUL-terminated ones: append ellipsis to the output
when the string is not NUL-terminated.

* defs.h (print_quoted_cstring): New prototype.
* util.c (print_quoted_cstring): New function.
(printpathn): Use it instead of print_quoted_string with
QUOTE_0_TERMINATED argument.
* print_fields.h (PRINT_FIELD_CSTRING): Likewise.
* btrfs.c (btrfs_ioctl): Likewise.
* dirent.c (SYS_FUNC(getdents)): Likewise.
* dirent64.c (SYS_FUNC(getdents64)): Likewise.
* print_ifindex.c (print_ifindex): Likewise.
* sysmips.c (SYS_FUNC(sysmips)): Likewise.
* ubi.c (ubi_ioctl): Likewise.
* tests/tests.h (print_quoted_cstring): New prototype.
* tests/print_quoted_string.c (print_quoted_cstring): New function.
* tests/ioctl_block.c (main): Update expected output.
* tests/ioctl_dm.c (main): Likewise.
* tests/ioctl_loop.c (print_loop_info, print_loop_info64): Likewise.
* tests/netlink_crypto.c (test_crypto_msg_newalg): Likewise.

7 years agotests: check decoding of NETLINK_CRYPTO crypto_user_alg attributes
JingPiao Chen [Sat, 22 Jul 2017 23:56:04 +0000 (07:56 +0800)]
tests: check decoding of NETLINK_CRYPTO crypto_user_alg attributes

* tests/nlattr_crypto_user_alg.c: New file.
* tests/gen_tests.in (nlattr_crypto_user_alg): New entry.
* tests/pure_executables.list: Add nlattr_crypto_user_alg.
* tests/.gitignore: Likewise.

7 years agotests: extend TEST_NLATTR_OBJECT macro
JingPiao Chen [Thu, 20 Jul 2017 08:45:58 +0000 (16:45 +0800)]
tests: extend TEST_NLATTR_OBJECT macro

* tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_,
TEST_NLATTR_OBJECT_EX): New macros.
(TEST_NLATTR_OBJECT): Use TEST_NLATTR_OBJECT_EX_.

7 years agonetlink: decode NETLINK_CRYPTO crypto_user_alg netlink attributes
JingPiao Chen [Sat, 22 Jul 2017 23:25:00 +0000 (07:25 +0800)]
netlink: decode NETLINK_CRYPTO crypto_user_alg netlink attributes

* configure.ac (AC_CHECK_TYPES): Check for crypto_report_aead,
crypto_report_blkcipher, crypto_report_cipher, crypto_report_hash,
and crypto_report_rng structures in <linux/cryptouser.h>.
* netlink_crypto.c (decode_crypto_report_generic,
decode_crypto_report_hash, decode_crypto_report_blkcipher,
decode_crypto_report_aead, decode_crypto_report_rng,
decode_crypto_report_cipher): New functions.
(crypto_user_alg_nla_decoders): New array.
(decode_crypto_user_alg): Use it.
* xlat/crypto_nl_attrs.in: New file.
* NEWS: Mention this.

7 years agotests: check decoding of NETLINK_CRYPTO messages
JingPiao Chen [Thu, 20 Jul 2017 08:08:07 +0000 (16:08 +0800)]
tests: check decoding of NETLINK_CRYPTO messages

* tests/netlink_crypto.c: Include "test_netlink.h"
instead of "netlink.h".
(test_crypto_msg_newalg, test_crypto_msg_unspec): New functions.
(main): Use them.

7 years agotests: extend TEST_NETLINK_OBJECT macro
JingPiao Chen [Thu, 20 Jul 2017 07:58:28 +0000 (15:58 +0800)]
tests: extend TEST_NETLINK_OBJECT macro

As the first field of NETLINK_CRYPTO messages is a string, print
unrecognized data as a string.  Extend TEST_NETLINK_OBJECT macro
to test this case.

* tests/test_netlink.h (TEST_NETLINK_OBJECT_EX_,
TEST_NETLINK_OBJECT_EX): New macros.
(TEST_NETLINK_OBJECT): Use TEST_NETLINK_OBJECT_EX_.

7 years agonetlink: add a basic parser of NETLINK_CRYPTO messages
JingPiao Chen [Thu, 20 Jul 2017 07:55:22 +0000 (15:55 +0800)]
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.

7 years agoUnify PRINT_FIELD_XVAL and PRINT_FIELD_XVAL64
Dmitry V. Levin [Sun, 23 Jul 2017 11:16:23 +0000 (11:16 +0000)]
Unify PRINT_FIELD_XVAL and PRINT_FIELD_XVAL64

* print_fields.h (PRINT_FIELD_XVAL64): Unify with PRINT_FIELD_XVAL.

7 years agoUnify PRINT_FIELD_FLAGS and PRINT_FIELD_FLAGS64
Dmitry V. Levin [Sun, 23 Jul 2017 11:16:23 +0000 (11:16 +0000)]
Unify PRINT_FIELD_FLAGS and PRINT_FIELD_FLAGS64

* print_fields.h (PRINT_FIELD_FLAGS64): Unify with PRINT_FIELD_FLAGS.
* userfaultfd.c (uffdio_ioctl): Replace PRINT_FIELD_FLAGS64 with
PRINT_FIELD_FLAGS.

7 years agopathtrace: fix fanotify_mark path tracing on 32-bit architectures
Nikolay Marchuk [Sun, 23 Jul 2017 04:44:36 +0000 (11:44 +0700)]
pathtrace: fix fanotify_mark path tracing on 32-bit architectures

The fanotify_mark syscall takes a 64-bit mask, and on 32-bit
architectures it is split up into two syscall arguments.

* pathtrace.c (pathtrace_match_set): Use getllval to properly decode
arguments after mask.

7 years agotravis: add valgrind check support
Dmitry V. Levin [Sat, 22 Jul 2017 18:46:16 +0000 (18:46 +0000)]
travis: add valgrind check support

* travis-build.sh [CHECK == valgrind]: Pass --enable-valgrind
to configure and appropriate check-valgrind-* to make.
* travis-install.sh [CHECK == valgrind]: Install valgrind.

7 years agonetlink_sock_diag: replace NLA_ALIGN with NLMSG_ALIGN
JingPiao Chen [Wed, 19 Jul 2017 14:55:53 +0000 (22:55 +0800)]
netlink_sock_diag: replace NLA_ALIGN with NLMSG_ALIGN

In several netlink_sock_diag parsers NLA_ALIGN was used instead of
NLMSG_ALIGN to align the length of netlink messages.  Fortunately,
both macros round the given length to the closest multiple of 4,
so technically there is no difference, but the use of wrong macro
is misleading.

* netlink_inet_diag.c (decode_inet_diag_req_compat,
decode_inet_diag_req_v2, decode_inet_diag_msg): Replace
NLA_ALIGN with NLMSG_ALIGN.
* netlink_netlink_diag.c (decode_netlink_diag_msg): Likewise.
* netlink_packet_diag.c (decode_packet_diag_msg): Likewise.
* netlink_smc_diag.c (decode_smc_diag_msg): Likewise.

7 years agotravis: configure build with dependency tracking disabled
Dmitry V. Levin [Sat, 22 Jul 2017 02:14:14 +0000 (02:14 +0000)]
travis: configure build with dependency tracking disabled

Dependency tracking is completely useless for one-time builds,
so configure build with dependency tracking disabled.

* travis-build.sh (DISTCHECK_CONFIGURE_FLAGS): Add
--disable-dependency-tracking.

7 years agom4: remove equal sign from define directive in ax_valgrind_check.m4
Eugene Syromyatnikov [Sat, 22 Jul 2017 00:01:53 +0000 (02:01 +0200)]
m4: remove equal sign from define directive in ax_valgrind_check.m4

Support for providing equal sign in define directives has been added
only in GNU Make 3.82 [1] and it provides the same semantics (variables
should be recursively expanded) as when it is omitted at all, so let's
remove it in order to preserve compatibility with older GNU Make
versions (like the one used on Travis).

[1] https://git.savannah.gnu.org/cgit/make.git/tree/ChangeLog?h=3.82#n766

* m4/ax_valgrind_check.m4 <define valgrind_tool_rule>: Remove equal
sign.

7 years agokeyctl: add support for KEYCTL_RESTRICT_KEYRING operation
Dmitry V. Levin [Fri, 21 Jul 2017 11:07:55 +0000 (11:07 +0000)]
keyctl: add support for KEYCTL_RESTRICT_KEYRING operation

* keyctl.c (keyctl_restrict_keyring): New function.
(SYS_FUNC(keyctl)): Use it to implement KEYCTL_RESTRICT_KEYRING support.
* NEWS: Mention this.
* tests/keyctl.c (main): Check KEYCTL_RESTRICT_KEYRING decoding.

7 years agotests: robustify strace-t.test
Dmitry V. Levin [Fri, 21 Jul 2017 02:49:24 +0000 (02:49 +0000)]
tests: robustify strace-t.test

If strace -t is running too long, it might happen that time stamps
before and after its invocation differ for more than a second.
Adjust expected output to handle this rare but possible case.

* tests/strace-t.test: Allow any time stamp between start and finish
of strace invocation.

7 years agox86: wire up arch_prctl syscall
Dmitry V. Levin [Fri, 21 Jul 2017 01:30:26 +0000 (01:30 +0000)]
x86: wire up arch_prctl syscall

* linux/i386/syscallent.h [384]: Add arch_prctl entry.
* xlat/archvals.in: Add fallback definitions for constants.
* prctl.c: Stop including <asm/prctl.h>.
(SYS_FUNC(arch_prctl)): Enable for [I386].
* NEWS: Mention this.

7 years agotests: tweak strace-ff.test for slow startup case
Dmitry V. Levin [Fri, 21 Jul 2017 01:08:12 +0000 (01:08 +0000)]
tests: tweak strace-ff.test for slow startup case

strace starts up much slower when invoked under valgrind control.
Increase the tracee's sleep delay to let strace more time to attach.

* tests/strace-ff.test: Increase sleep delay.

7 years agotests: update valgrind suppressions
Dmitry V. Levin [Fri, 21 Jul 2017 01:08:12 +0000 (01:08 +0000)]
tests: update valgrind suppressions

* tests/strace.supp: Add a suppression for the memleak before
error_msg_and_die in qualify_tokens.

7 years agoDo not copy optarg unnecessarily
Dmitry V. Levin [Thu, 20 Jul 2017 22:55:57 +0000 (22:55 +0000)]
Do not copy optarg unnecessarily

There is no need to copy the optarg string since it is a pointer
into the original argv array, not into a static area
that might be overwritten.

* strace.c (username, outfname): Add const qualifier.
(init): Do not xstrdup optarg to initialize outfname and username.

7 years agotravis: add build environment information to the travis log
Dmitry V. Levin [Thu, 20 Jul 2017 22:03:31 +0000 (22:03 +0000)]
travis: add build environment information to the travis log

* travis-build.sh: Print build environment information.

7 years agobuild: add check-valgrind-* to recursive targets
Dmitry V. Levin [Thu, 20 Jul 2017 22:03:31 +0000 (22:03 +0000)]
build: add check-valgrind-* to recursive targets

As make -j$N check-valgrind cannot parallelize properly, add
recursive targets for each of valgrind checks.  This way one can run
for t in $valgrind_enabled_tools; do
make -k check-valgrind-$n || rc=$?
done
in $top_builddir.

* configure.ac (AM_EXTRA_RECURSIVE_TARGETS): Remove.
* m4/ax_valgrind_check.m4 (AX_VALGRIND_CHECK): Add check-valgrind
and check-valgrind-* to AM_EXTRA_RECURSIVE_TARGETS.

7 years agotests: add check-valgrind-local make rule
Dmitry V. Levin [Thu, 20 Jul 2017 00:06:06 +0000 (00:06 +0000)]
tests: add check-valgrind-local make rule

This guarantees that $(check_LIBRARIES) and $(check_PROGRAMS)
are made on 'make check-valgrind' before its recipe is processed.

* tests/Makefile.am (check-valgrind-local): New rule.
(.PHONY): Add it.

7 years agoAdd ksysent.h and scno.h to BUILT_SOURCES
Dmitry V. Levin [Thu, 20 Jul 2017 00:06:06 +0000 (00:06 +0000)]
Add ksysent.h and scno.h to BUILT_SOURCES

This guarantees that ksysent.h and scno.h, along with other targets
listed in BUILT_SOURCES, are made on 'make all', 'make check',
and 'make check-valgrind' before other targets are processed.

* scno.am (BUILT_SOURCES): Add scno.h.
* tests/Makefile.am (BUILT_SOURCES): Add ksysent.h.

7 years agotests: fix valgrind suppression file path
Dmitry V. Levin [Thu, 20 Jul 2017 00:06:06 +0000 (00:06 +0000)]
tests: fix valgrind suppression file path

* tests/Makefile.am (VALGRIND_SUPPRESSIONS_FILES): Replace srcdir
with abs_srcdir.

Fixes: v4.16-74-g16036030 ("tests: run every test except ksysent.test in its own subdirectory")
7 years agoUpdate AX_VALGRIND_CHECK
Dmitry V. Levin [Wed, 19 Jul 2017 21:29:33 +0000 (21:29 +0000)]
Update AX_VALGRIND_CHECK

* m4/ax_valgrind_check.m4: Update to serial 15.  In particular,
this version does not eat check-valgrind errors.

7 years agoUpdate AX_CODE_COVERAGE
Dmitry V. Levin [Wed, 19 Jul 2017 21:29:33 +0000 (21:29 +0000)]
Update AX_CODE_COVERAGE

* m4/ax_code_coverage.m4: Update to serial 24.  In particular,
this version has no lcov version check.
* Makefile.am (strace_LDADD): Rename CODE_COVERAGE_LDFLAGS
to CODE_COVERAGE_LIBS.

7 years agoUpdate input event KEY_* constants
Dmitry V. Levin [Wed, 19 Jul 2017 20:41:15 +0000 (20:41 +0000)]
Update input event KEY_* constants

* xlat/evdev_keycode.in: Add KEY_ASSISTANT introduced by linux kernel
commit v4.13-rc1~13^2~1^2~1.
* NEWS: Mention this.

7 years agoUpdate fs *_MAGIC constants
Dmitry V. Levin [Wed, 19 Jul 2017 20:41:15 +0000 (20:41 +0000)]
Update fs *_MAGIC constants

* xlat/fsmagic.in: Add AAFS_MAGIC introduced by linux kernel commit
v4.13-rc1~161^2~87.
* NEWS: Mention this.

7 years agoMove family-specific NETLINK_SOCK_DIAG parsers to separate files
Dmitry V. Levin [Wed, 19 Jul 2017 10:07:34 +0000 (10:07 +0000)]
Move family-specific NETLINK_SOCK_DIAG parsers to separate files

Split netlink_sock_diag.c that grew too big.

* defs.h (tcp_states, tcp_state_flags): New xlat prototypes.
* netlink_sock_diag.h: New file.
* netlink_inet_diag.c: Likewise.
* netlink_netlink_diag.c: Likewise.
* netlink_packet_diag.c: Likewise.
* netlink_smc_diag.c: Likewise.
* netlink_unix_diag.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* netlink_sock_diag.c: Move family-specific parsers and associated
header includes to separate files.
* nlattr.h (DECL_NLA(meminfo)): New prototype.
* nlattr.c: Include <linux/sock_diag.h>.
(print_meminfo, decode_nla_meminfo): New functions from
netlink_sock_diag.c.

7 years agoAdjust prototypes of netlink parsing functions
Dmitry V. Levin [Wed, 19 Jul 2017 10:07:34 +0000 (10:07 +0000)]
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.

7 years agotests: check decoding of nlmsgerr attributes
JingPiao Chen [Wed, 19 Jul 2017 09:17:38 +0000 (17:17 +0800)]
tests: check decoding of nlmsgerr attributes

* tests/nlattr_nlmsgerr.c: New file.
* tests/gen_tests.in (nlattr_nlmsgerr): New entry.
* tests/pure_executables.list: Add nlattr_nlmsgerr.
* tests/.gitignore: Likewise.

7 years agonetlink: decode nlmsgerr attributes
JingPiao Chen [Wed, 19 Jul 2017 09:17:37 +0000 (17:17 +0800)]
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.

7 years agonetlink: adjust decode_nlmsgerr for extended ACK reporting
JingPiao Chen [Wed, 19 Jul 2017 09:17:36 +0000 (17:17 +0800)]
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.

7 years agonetlink: decode netlink message ack flags
JingPiao Chen [Wed, 19 Jul 2017 09:17:35 +0000 (17:17 +0800)]
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.

7 years agotests: enhance error diagnostics
Dmitry V. Levin [Wed, 19 Jul 2017 08:59:50 +0000 (08:59 +0000)]
tests: enhance error diagnostics

* tests/init.sh (dump_log_and_fail_with): Dump $LOG to stderr instead
of stdout as the latter is more likely to be redirected to a temporary
file in the context where this function is called.

7 years agotests: enhance timeout diagnostics
Dmitry V. Levin [Wed, 19 Jul 2017 02:38:37 +0000 (02:38 +0000)]
tests: enhance timeout diagnostics

* tests/init.sh: Trap SIGXCPU.
* tests/run.sh: Send SIGXCPU instead of SIGKILL in case of timeout, send
SIGKILL if the command is still running 5 seconds after SIGXCPU.

7 years agouserfaultfd: decode struct uffdio_api.features as flags
Dmitry V. Levin [Wed, 19 Jul 2017 00:33:56 +0000 (00:33 +0000)]
userfaultfd: decode struct uffdio_api.features as flags

* xlat/uffd_api_features.in: New file.
* userfaultfd.c: Include "xlat/uffd_api_features.h".
(uffdio_ioctl): Print struct uffdio_api.features using
PRINT_FIELD_FLAGS64 and uffd_api_features.
* NEWS: Mention this.
* tests/ioctl_uffdio.c: Include "xlat.h" and "xlat/uffd_api_features.h".
(main): Update expected output.

7 years agouserfaultfd: enhance decoding of struct uffdio_api.features
Dmitry V. Levin [Wed, 19 Jul 2017 00:33:56 +0000 (00:33 +0000)]
userfaultfd: enhance decoding of struct uffdio_api.features

As struct uffdio_api.features has read-write semantics,
print the value returned by the kernel only when it differs
from the value passed to the kernel.

* userfaultfd.c (uffdio_ioctl) <UFFDIO_API>: On entering syscall,
save the value of struct uffdio_api.features.  On exiting syscall, do
not print struct uffdio_api.features when it's the same as on entering.
* tests/ioctl_uffdio.c (main): Update expected output.

7 years agouserfaultfd: use PRINT_FIELD_* macros
Dmitry V. Levin [Tue, 18 Jul 2017 21:54:38 +0000 (21:54 +0000)]
userfaultfd: use PRINT_FIELD_* macros

This also fixes output correctness for struct uffdio_api.features.

* userfaultfd.c: Include "print_fields.h".
(tprintf_uffdio_range): Use PRINT_FIELD_X.
(PRINT_FIELD_UFFDIO_RANGE): New macro.
(uffdio_ioctl): Use it, PRINT_FIELD_FLAGS64, and PRINT_FIELD_X.
* tests/ioctl_uffdio.c (main): Update expected output.

7 years agoIntroduce PRINT_FIELD_FLAGS64 and PRINT_FIELD_XVAL64
Dmitry V. Levin [Tue, 18 Jul 2017 21:54:38 +0000 (21:54 +0000)]
Introduce PRINT_FIELD_FLAGS64 and PRINT_FIELD_XVAL64

* print_fields.h (PRINT_FIELD_FLAGS64, PRINT_FIELD_XVAL64): New macros.

7 years agoUpdate NEWS
Dmitry V. Levin [Mon, 17 Jul 2017 19:55:17 +0000 (19:55 +0000)]
Update NEWS

7 years agoaio: change struct iocb.aio_lio_opcode output format
Dmitry V. Levin [Mon, 17 Jul 2017 11:59:26 +0000 (11:59 +0000)]
aio: change struct iocb.aio_lio_opcode output format

* aio.c (tprint_lio_opcode): Change opcode output format to match
the kernel.
* tests/aio.c (main): Update expected output.

7 years agoaio: use PRINT_FIELD_* macros
Dmitry V. Levin [Mon, 17 Jul 2017 11:59:26 +0000 (11:59 +0000)]
aio: use PRINT_FIELD_* macros

This also fixes output correctness for struct iocb.

* aio.c: Include "print_fields.h".
(print_common_flags, print_iocb_header, print_iocb, print_io_event):
Use PRINT_FIELD_D, PRINT_FIELD_U, PRINT_FIELD_X, PRINT_FIELD_FD,
and PRINT_FIELD_STRN.
* tests/aio.c (main): Update expected output.

7 years agoIntroduce PRINT_FIELD_FD and PRINT_FIELD_STRN
Dmitry V. Levin [Mon, 17 Jul 2017 11:59:26 +0000 (11:59 +0000)]
Introduce PRINT_FIELD_FD and PRINT_FIELD_STRN

* print_fields.h (PRINT_FIELD_FD, PRINT_FIELD_STRN): New macros.

7 years agoUpdate BPF_* constants
Dmitry V. Levin [Sun, 16 Jul 2017 22:31:34 +0000 (22:31 +0000)]
Update BPF_* constants

* xlat/bpf_commands.in: Add BPF_PROG_TEST_RUN, BPF_PROG_GET_NEXT_ID,
BPF_MAP_GET_NEXT_ID, BPF_PROG_GET_FD_BY_ID, BPF_MAP_GET_FD_BY_ID,
and BPF_OBJ_GET_INFO_BY_FD introduced by linux kernel commits
v4.12-rc1~64^3~287^2~5, v4.13-rc1~157^2~271^2~5,
v4.13-rc1~157^2~271^2~4, v4.13-rc1~157^2~271^2~3, and
v4.13-rc1~157^2~271^2~1, respectively.
* xlat/bpf_attach_type.in: Add BPF_CGROUP_SOCK_OPS introduced
by linux kernel commit v4.13-rc1~157^2~37^2~15.
* xlat/bpf_prog_types.in: Add BPF_PROG_TYPE_SOCK_OPS introduced
by the same commit.

7 years agoUpdate SO_* constants
Dmitry V. Levin [Sun, 16 Jul 2017 22:24:54 +0000 (22:24 +0000)]
Update SO_* constants

* xlat/sockoptions.in: Add SO_PEERGROUPS introduced by linux kernel
commit v4.13-rc1~157^2~124.

7 years agoUpdate SCM_* constants
Dmitry V. Levin [Sun, 16 Jul 2017 22:21:34 +0000 (22:21 +0000)]
Update SCM_* constants

* xlat/scmvals.in: Add SCM_TIMESTAMPING_PKTINFO introduced
by linux kernel commit v4.13-rc1~157^2~405^2~3.

7 years agotests: check decoding of NETLINK_SELINUX protocol
JingPiao Chen [Sat, 15 Jul 2017 01:11:33 +0000 (09:11 +0800)]
tests: check decoding of NETLINK_SELINUX protocol

* test_netlink.h (TEST_NETLINK_OBJECT): New macro.
* tests/netlink_selinux.c: Include "test_netlink.h"
instead of "netlink.h".
(test_selnl_msg_unspec, test_selnl_msg_setenforce,
test_selnl_msg_policyload): New functions.
(main): Use them.

7 years agonetlink: decode NETLINK_SELINUX protocol
JingPiao Chen [Fri, 14 Jul 2017 05:16:36 +0000 (13:16 +0800)]
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.

7 years agosg_io_v3: use PRINT_FIELD_* macros
Dmitry V. Levin [Sat, 15 Jul 2017 00:08:12 +0000 (00:08 +0000)]
sg_io_v3: use PRINT_FIELD_* macros

* sg_io_v3.c: Include "print_fields.h".
(PRINT_FIELD_SG_IO_BUFFER): New macro.
(decode_request, decode_response): Use it, PRINT_FIELD_D, PRINT_FIELD_U,
PRINT_FIELD_X, PRINT_FIELD_PTR, PRINT_FIELD_FLAGS, and PRINT_FIELD_XVAL.

7 years agoIntroduce PRINT_FIELD_PTR
Dmitry V. Levin [Sat, 15 Jul 2017 00:08:12 +0000 (00:08 +0000)]
Introduce PRINT_FIELD_PTR

* print_fields.h (PRINT_FIELD_PTR): New macro.

7 years agoProvide mpers_ptr_t definition for non-mpers case
Dmitry V. Levin [Sat, 15 Jul 2017 00:08:12 +0000 (03:08 +0300)]
Provide mpers_ptr_t definition for non-mpers case

In mpers case, mpers_ptr_t is already defined by DEF_MPERS_TYPE(...).
This allows use of mpers_ptr_t regardless of IN_MPERS state.

* mpers_type.h [!IN_MPERS] (mpers_ptr_t): New typedef.

7 years agoMove is_negated_errno() to new header negated_errno.h
Lazar Trsic [Fri, 14 Jul 2017 09:31:03 +0000 (11:31 +0200)]
Move is_negated_errno() to new header negated_errno.h

Move is_negated_errno() to a separate new header file negated_errno.h
and include it just for architectures which require it.

is_negated_errno() is not used on those architectures
that have a dedicated register to signal a syscall error.

The issue was raised when compiling with clang, which is more
strict regarding semantics of unused static inline functions
defined in C files and will issue a -Wunused-function warrning
if they are not used anywhere.

* syscall.c (is_negated_errno): Move to ...
* negated_errno.h: ... new file.
* Makefile.am (strace_SOURCES): Add it.
* linux/aarch64/get_error.c: Include it.
* linux/arc/get_error.c: Likewise.
* linux/arm/get_error.c: Likewise.
* linux/avr32/get_error.c: Likewise.
* linux/bfin/get_error.c: Likewise.
* linux/crisv10/get_error.c: Likewise.
* linux/hppa/get_error.c: Likewise.
* linux/i386/get_error.c: Likewise.
* linux/ia64/get_error.c: Likewise.
* linux/m68k/get_error.c: Likewise.
* linux/metag/get_error.c: Likewise.
* linux/microblaze/get_error.c: Likewise.
* linux/or1k/get_error.c: Likewise.
* linux/riscv/get_error.c: Likewise.
* linux/s390/get_error.c: Likewise.
* linux/sh/get_error.c: Likewise.
* linux/sh64/get_error.c: Likewise.
* linux/tile/get_error.c: Likewise.
* linux/x86_64/get_error.c: Likewise.
* linux/xtensa/get_error.c: Likewise.

7 years agosg_io_v4: use PRINT_FIELD_* macros
Dmitry V. Levin [Fri, 14 Jul 2017 03:59:13 +0000 (03:59 +0000)]
sg_io_v4: use PRINT_FIELD_* macros

* sg_io_v4.c: Include "print_fields.h".
(PRINT_FIELD_SG_IO_BUFFER): New macro.
(decode_request, decode_response): Use it, PRINT_FIELD_D, PRINT_FIELD_U,
PRINT_FIELD_X, PRINT_FIELD_FLAGS, and PRINT_FIELD_XVAL.

7 years agodm: use PRINT_FIELD_* macros
Dmitry V. Levin [Fri, 14 Jul 2017 00:08:09 +0000 (00:08 +0000)]
dm: use PRINT_FIELD_* macros

* dm.c (dm_decode_values, dm_decode_dm_target_spec,
dm_decode_dm_target_deps, dm_decode_dm_target_msg, dm_known_ioctl): Use
PRINT_FIELD_D, PRINT_FIELD_U, and PRINT_FIELD_FLAGS.

7 years agoMove macros related to kernel types to kernel_types.h
Dmitry V. Levin [Thu, 13 Jul 2017 21:56:29 +0000 (21:56 +0000)]
Move macros related to kernel types to kernel_types.h

Some macros related to kernel types are defined both in defs.h and
tests/tests.h.  Avoid this redundancy by moving these definitions
to kernel_types.h.

* defs.h (PRI_kl, PRI_kld, PRI_klu, PRI_klx, PRI__64, PRI__d64,
PRI__u64, PRI__x64): Move ...
* kernel_types.h: ... here.
* tests/tests.h (PRI__64, PRI__d64, PRI__u64, PRI__x64): Remove.

7 years agomips64: fix PRI__64 macro definition when compiled for Android
Lazar Trsic [Mon, 10 Jul 2017 15:05:44 +0000 (17:05 +0200)]
mips64: fix PRI__64 macro definition when compiled for Android

By default for MIPS64 in Android __u64 type is exported
as unsigned long long.  This caused compilation -Wformat warnings
and would break the build if -Werror is used.

* defs.h [SIZEOF_LONG != 4 && MIPS && __ANDROID__] (PRI__64): Change
from "l" to "ll".

7 years agoblock: use PRINT_FIELD_* macros
Dmitry V. Levin [Thu, 13 Jul 2017 12:38:51 +0000 (12:38 +0000)]
block: use PRINT_FIELD_* macros

This also fixes output correctness for struct blkpg_ioctl_arg.

* block.c (print_blkpg_req): Use PRINT_FIELD_D and PRINT_FIELD_XVAL.
(block_ioctl): Use PRINT_FIELD_U.
* tests/ioctl_block.c (main): Update expected output.

7 years agonetlink_sock_diag: enhance decoding of long meminfo arrays
Dmitry V. Levin [Wed, 12 Jul 2017 21:08:03 +0000 (21:08 +0000)]
netlink_sock_diag: enhance decoding of long meminfo arrays

Print trailing dots instead of silent truncation if the array
is too long.

* netlink_sock_diag.c (decode_meminfo): Do not apply SK_MEMINFO_VARS
limit to nmemb, specify element count to print_array instead.
(print_meminfo): Check element count and terminate printing
if the element count exceeds SK_MEMINFO_VARS.
* tests/nlattr_inet_diag_msg.c (main): Check it.

7 years agotests: extend coverage of netlink_diag_req decoder
Dmitry V. Levin [Wed, 12 Jul 2017 19:33:25 +0000 (19:33 +0000)]
tests: extend coverage of netlink_diag_req decoder

Add one more NETLINK_SOCK_DIAG check to ressurrect full coverage
of netlink_diag_req decoder that was lost after commit
v4.18-58-g37ef2d0d.

* tests/netlink_sock_diag.c (test_netlink_diag_req): Add a check for
sdiag_protocol != NDIAG_PROTO_ALL.

7 years agotests: check decoding of NETLINK_CRYPTO nlmsg_flags
JingPiao Chen [Fri, 9 Jun 2017 11:44:57 +0000 (19:44 +0800)]
tests: check decoding of NETLINK_CRYPTO nlmsg_flags

* tests/netlink_crypto.c (test_nlmsg_flags): New function.
(main): Use it.

7 years agonetlink: add decoding of NETLINK_CRYPTO nlmsg_flags
JingPiao Chen [Fri, 9 Jun 2017 11:42:30 +0000 (19:42 +0800)]
netlink: add decoding of NETLINK_CRYPTO nlmsg_flags

* netlink.c (decode_nlmsg_flags): Add NETLINK_CRYPTO.

7 years agotests: check decoding of NETLINK_CRYPTO message types
JingPiao Chen [Sun, 9 Jul 2017 13:57:19 +0000 (21:57 +0800)]
tests: check decoding of NETLINK_CRYPTO message types

* configure.ac (AC_CHECK_HEADERS): Add linux/cryptouser.h.
* tests/netlink_crypto.c: New file.
* tests/gen_tests.in (netlink_crypto): New entry.
* tests/pure_executables.list: Add netlink_crypto.
* tests/.gitignore: Likewise.

7 years agonetlink: add decoding of NETLINK_CRYPTO message types
JingPiao Chen [Fri, 9 Jun 2017 09:47:49 +0000 (17:47 +0800)]
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.

7 years agotests: introduce TEST_NETLINK and TEST_NETLINK_ macros
JingPiao Chen [Sat, 8 Jul 2017 08:36:46 +0000 (16:36 +0800)]
tests: introduce TEST_NETLINK and TEST_NETLINK_ macros

* tests/test_netlink.h: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/netlink_sock_diag.c: Include "test_netlink.h"
instead of "netlink.h".
(TEST_SOCK_DIAG): New macro.
(test_unix_diag_req, test_unix_diag_msg,
test_netlink_diag_req, test_netlink_diag_msg,
test_packet_diag_req, test_packet_diag_msg,
test_inet_diag_req, test_inet_diag_req_v2,
test_inet_diag_msg, test_smc_diag_req,
test_smc_diag_msg): Use it.
(test_odd_family_req, test_odd_family_msg,
test_inet_diag_sockid): Use TEST_NETLINK macro.

7 years agotests: check decoding of nlattr_inet_diag_req_v2 attributes
JingPiao Chen [Wed, 5 Jul 2017 07:48:28 +0000 (15:48 +0800)]
tests: check decoding of nlattr_inet_diag_req_v2 attributes

* tests/nlattr_inet_diag_req_v2.c: New file.
* tests/gen_tests.in (nlattr_inet_diag_req_v2): New entry.
* tests/pure_executables.list: Add nlattr_inet_diag_req_v2.
* tests/.gitignore: Likewise.

7 years agotests: check decoding of nlattr_inet_diag_req_compat attributes
JingPiao Chen [Wed, 5 Jul 2017 07:46:43 +0000 (15:46 +0800)]
tests: check decoding of nlattr_inet_diag_req_compat attributes

* tests/nlattr_inet_diag_req_compat.c: New file.
* tests/gen_tests.in (nlattr_inet_diag_req_compat): New entry.
* tests/pure_executables.list: Add nlattr_inet_diag_req_compat.
* tests/.gitignore: Likewise.

7 years agonetlink: decode AF_INET inet_diag_req_* attributes
JingPiao Chen [Wed, 24 May 2017 06:55:59 +0000 (14:55 +0800)]
netlink: decode AF_INET inet_diag_req_* attributes

* linux/inet_diag.h (inet_diag_bc_op, inet_diag_hostcond,
inet_diag_markcond): New structures.
(INET_DIAG_BC_*): New enum.
* netlink_sock_diag.c: Include "xlat/inet_diag_bytecodes.h".
(decode_inet_addr, decode_inet_diag_hostcond,
print_inet_diag_bc_op, decode_inet_diag_markcond,
decode_bytecode_data, decode_inet_diag_bc_op): New functions.
(inet_diag_req_nla_decoders): New array.
(decode_inet_diag_req_compat, decode_inet_diag_req_v2): Use it.
* xlat/inet_diag_bytecodes.in: New file.

7 years agoIntroduce PRINT_FIELD_CSTRING
Dmitry V. Levin [Tue, 11 Jul 2017 00:20:54 +0000 (00:20 +0000)]
Introduce PRINT_FIELD_CSTRING

* print_fields.h (PRINT_FIELD_CSTRING): New macro.
* block.c (print_blkpg_req, block_ioctl): Use PRINT_FIELD_CSTRING
instead of print_quoted_string.
* btrfs.c (btrfs_ioctl): Likewise.
* dm.c (dm_decode_device, dm_decode_dm_target_spec): Likewise.
* loop.c (decode_loop_info, decode_loop_info64): Likewise.
* v4l2.c (print_v4l2_capability, print_v4l2_fmtdesc,
print_v4l2_standard, print_v4l2_input, print_v4l2_tuner,
print_v4l2_queryctrl): Likewise.
* netlink_sock_diag.c (decode_smc_diag_lgrinfo): Use PRINT_FIELD_CSTRING
instead of PRINT_FIELD_STRING.
* uname.c (PRINT_UTS_MEMBER): Remove.
(SYS_FUNC(uname)): Use PRINT_FIELD_CSTRING instead of PRINT_UTS_MEMBER.

7 years agoRename PRINT_FIELD_QUOTED_STRING to PRINT_FIELD_STRING
Dmitry V. Levin [Tue, 11 Jul 2017 00:20:54 +0000 (00:20 +0000)]
Rename PRINT_FIELD_QUOTED_STRING to PRINT_FIELD_STRING

As string fields are always qouted when printed, choose a shorter name
for the helper macro.

* print_fields.h (PRINT_FIELD_QUOTED_STRING): Rename
to PRINT_FIELD_STRING.  All callers updated.

7 years agoUpdate RWF_* constants
Dmitry V. Levin [Mon, 10 Jul 2017 15:27:51 +0000 (15:27 +0000)]
Update RWF_* constants

* xlat/rwf_flags.in: Add RWF_NOWAIT introduced by linux kernel
commit v4.12-rc5-150-gb745fafa.

7 years agoIntorduce PRINT_FIELD_0X
Dmitry V. Levin [Mon, 10 Jul 2017 02:23:00 +0000 (02:23 +0000)]
Intorduce PRINT_FIELD_0X

* print_fields.h (PRINT_FIELD_0X): New macro.
* sockaddr.c (print_sockaddr_data_ipx, print_sockaddr_data_nl): Use it
instead of manual tprintf statements.
* netlink_sock_diag.c (PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS): Remove.
(decode_smc_diag_conninfo): Replace it with PRINT_FIELD_0X.

7 years agoprint_inet_addr: use inet_addr-based output format for IPv4
Dmitry V. Levin [Mon, 10 Jul 2017 01:45:18 +0000 (01:45 +0000)]
print_inet_addr: use inet_addr-based output format for IPv4

* sockaddr.c (print_inet_addr): Remove af_name variable.
<AF_INET>: Use inet_addr-based output format.
* tests/netlink_sock_diag.c (test_inet_diag_sockid, test_inet_diag_req,
test_inet_diag_req_v2, test_inet_diag_msg, test_smc_diag_req,
test_smc_diag_msg): Update expected output.
* tests/nlattr_inet_diag_msg.c (print_inet_diag_msg): Likewise.
* tests/nlattr_smc_diag_msg.c (print_smc_diag_msg): Likewise.

7 years agotests: check decoding of netlink smc_diag_msg attributes
JingPiao Chen [Mon, 26 Jun 2017 00:32:08 +0000 (08:32 +0800)]
tests: check decoding of netlink smc_diag_msg attributes

* tests/nlattr_smc_diag_msg.c: New file.
* tests/gen_tests.in (nlattr_smc_diag_msg): New entry.
* tests/pure_executables.list: Add nlattr_smc_diag_msg.
* tests/.gitignore: Likewise.

7 years agonetlink: decode AF_SMC smc_diag_msg attributes
JingPiao Chen [Sun, 21 May 2017 11:49:43 +0000 (19:49 +0800)]
netlink: decode AF_SMC smc_diag_msg attributes

* linux/smc_diag.h (smc_diag_cursor, smc_diag_conninfo
smc_diag_linkinfo, smc_diag_lgrinfo): New structures.
* netlink_sock_diag.c: Include "xlat/smc_link_group_roles.h".
(decode_smc_diag_conninfo, decode_smc_diag_lgrinfo): New functions.
(smc_diag_msg_nla_decoders): New array.
(decode_smc_diag_msg): Use it.
* xlat/smc_link_group_roles.in: New file.

7 years agopathtrace.c: introduce user-provided sets of paths
Nikolay Marchuk [Sat, 8 Jul 2017 08:28:56 +0000 (15:28 +0700)]
pathtrace.c: introduce user-provided sets of paths

* defs.h (struct path_set): New structure.
(global_path_set): New variable prototype.
(tracing_paths): Change macro body to use global_path_set variable.
(pathtrace_select_set): Add "struct path_set *" argument.
(pathtrace_match_set): Likewise.  Change return type to bool.
(pathtrace_select, pathtrace_match): Change into thin macro wrappers
around pathtrace_select_set and pathtrace_match_set, repsectively.
* pathtrace.c (global_path_set): New variable.
(storepath, pathtrace_select_set): Add "struct path_set *" argument.
(pathmatch, upathmatch, fdmatch, pathtrace_match_set): Likewise.
Change return type to bool.

7 years agotests: check decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
tests: check decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP

* tests/group_req.c: New file.
* tests/gen_tests.in (group_req): New entry.
* tests/pure_executables.list: Add group_req.
* tests/.gitignore: Likewise.

7 years agoMpersify struct group_req
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
Mpersify struct group_req

The size of struct group_req depends on alignment of long and therefore
has to be mpersified.

* print_group_req.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* net.c (print_group_req): Move to print_group_req.c, wrap into
MPERS_PRINTER_DECL.

7 years agonet: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP

* net.c (print_group_req): Allow option length greater than
sizeof(struct group_req) to match the kernel behaviour.
When the option length is invalid, print the address.
* NEWS: Mention this.

7 years agonet: hook up MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP decoding for SOL_IPV6
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: hook up MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP decoding for SOL_IPV6

As multicast socket options are shared between IPv4 and IPv6,
they should be decoded both for SOL_IP and SOL_IPV6.

* net.c (print_setsockopt) <SOL_IPV6> [MCAST_JOIN_GROUP]: Handle
MCAST_JOIN_GROUP and MCAST_LEAVE_GROUP.

7 years agoxlat: add MCAST_* to sockipv6options
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
xlat: add MCAST_* to sockipv6options

Multicast socket options are shared between IPv4 and IPv6.

* xlat/sockipv6options.in: Add MCAST_JOIN_GROUP, MCAST_BLOCK_SOURCE,
MCAST_UNBLOCK_SOURCE, MCAST_LEAVE_GROUP, MCAST_JOIN_SOURCE_GROUP,
MCAST_LEAVE_SOURCE_GROUP, and MCAST_MSFILTER.

7 years agonet: enhance decoding of IP_ADD_MEMBERSHIP et al socket options
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: enhance decoding of IP_ADD_MEMBERSHIP et al socket options

* net.c (print_mreq, print_mreq6): Treat negative option length
as invalid to match the kernel behaviour.  When the option length
is invalid, print the address.
* NEWS: Mention it.
* tests/ip_mreq.c (main): Check it.  Update expected output.

7 years agonet: enhance decoding of setsockopt's SO_LINGER negative option length
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: enhance decoding of setsockopt's SO_LINGER negative option length

* net.c (print_set_linger): Treat negative option length as invalid
to match the kernel behaviour.
* tests/so_linger.c (main): Check it.

7 years agomsghdr: use PRINT_FIELD_* macros
Dmitry V. Levin [Sun, 9 Jul 2017 16:04:24 +0000 (16:04 +0000)]
msghdr: use PRINT_FIELD_* macros

* msghdr.c (print_scm_creds): Use PRINT_FIELD_U and PRINT_FIELD_UID.
(print_cmsg_ip_recverr): Use PRINT_FIELD_U.
(print_struct_msghdr): Use PRINT_FIELD_U and PRINT_FIELD_FLAGS.

7 years agoIntorduce PRINT_FIELD_SOCKADDR
Dmitry V. Levin [Sun, 9 Jul 2017 16:04:24 +0000 (16:04 +0000)]
Intorduce PRINT_FIELD_SOCKADDR

* print_fields.h (PRINT_FIELD_SOCKADDR): New macro.
* msghdr.c (print_cmsg_ip_recverr): Use it instead of print_sockaddr.
* net.c (print_group_req): Likewise.
* sock.c (PRINT_IFREQ_ADDR): Remove.
(print_ifreq, print_ifconf_ifreq): Use PRINT_FIELD_SOCKADDR
instead of PRINT_IFREQ_ADDR.

7 years agoprint_sockaddr: remove "struct tcb *" argument
Dmitry V. Levin [Sun, 9 Jul 2017 16:04:24 +0000 (16:04 +0000)]
print_sockaddr: remove "struct tcb *" argument

print_sockaddr does not use its first argument, remove it.

* defs.h (print_sockaddr): Remove argument.
* sockaddr.c (print_sockaddr): Remove argument.  All callers updated.
* sock.c (PRINT_IFREQ_ADDR): Likewise.

7 years agonet: use PRINT_FIELD_* macros
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
net: use PRINT_FIELD_* macros

* net.c (print_tpacket_stats, print_tpacket_req): Use PRINT_FIELD_U.
(print_group_req): Use PRINT_FIELD_IFINDEX.
(print_packet_mreq): Use PRINT_FIELD_IFINDEX, PRINT_FIELD_U,
and PRINT_FIELD_XVAL.

7 years agonetlink_sock_diag: introduce PRINT_FIELD_INET_DIAG_SOCKID
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
netlink_sock_diag: introduce PRINT_FIELD_INET_DIAG_SOCKID

* netlink_sock_diag.c (PRINT_FIELD_INET_DIAG_SOCKID): New macro.
(decode_inet_diag_req_compat, decode_inet_diag_req_v2,
decode_inet_diag_msg, decode_smc_diag_req, decode_smc_diag_msg): Use it
instead of print_inet_diag_sockid.

7 years agoIntorduce PRINT_FIELD_DEV
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_DEV

* print_fields.h (PRINT_FIELD_DEV): New macro.
* dm.c (dm_decode_device, dm_decode_dm_name_list): Use it
instead of print_dev_t.
* loop.c (decode_loop_info, decode_loop_info64): Likewise.
* netlink_sock_diag.c (decode_unix_diag_vfs): Likewise.

7 years agoIntorduce PRINT_FIELD_INET4_ADDR
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_INET4_ADDR

* print_fields.h (PRINT_FIELD_INET4_ADDR): New macro.
* msghdr.c (print_cmsg_ip_pktinfo): Use it instead of manual
tprintf statements.
* net.c (print_mreq): Likewise.
* sockaddr.c (print_sockaddr_data_in): Likewise.

7 years agoIntorduce PRINT_FIELD_NET_PORT
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_NET_PORT

* print_fields.h (PRINT_FIELD_NET_PORT): New macro.
* netlink_sock_diag.c (print_inet_diag_sockid): Use it
instead of a manual tprintf statement.
* sockaddr.c (print_sockaddr_data_in, print_sockaddr_data_in6,
print_sockaddr_data_ipx): Likewise.

7 years agoIntorduce PRINT_FIELD_IFINDEX
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_IFINDEX

* print_fields.h (PRINT_FIELD_IFINDEX): New macro.
* msghdr.c (print_cmsg_ip_pktinfo): Use it instead of print_ifindex.
* net.c (print_mreq6): Likewise.
* netlink_sock_diag.c (print_packet_diag_mclist,
print_inet_diag_sockid): Likewise.
* sockaddr.c (print_sockaddr_data_in6, print_sockaddr_data_ll):
Likewise.

7 years agoIntorduce PRINT_FIELD_INET_ADDR
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_INET_ADDR

* print_fields.h (PRINT_FIELD_INET_ADDR): New macro.
* net.c (print_mreq6): Use it instead of print_inet_addr.
* netlink_sock_diag.c (print_inet_diag_sockid): Likewise.
* sockaddr.c (print_sockaddr_data_in6): Likewise.