]> granicus.if.org Git - strace/log
strace
6 years agonet: fix a typo in print_tpacket_stats
Zhibin Li [Thu, 5 Jul 2018 14:43:25 +0000 (22:43 +0800)]
net: fix a typo in print_tpacket_stats

6 years agotests: fix race condition in aio.test
Dmitry V. Levin [Tue, 3 Jul 2018 16:51:49 +0000 (16:51 +0000)]
tests: fix race condition in aio.test

* tests/aio.c (main): Print aio_key fields before the io_submit syscall
invocation to avoid races with the kernel.

6 years agoci: robustify network-related operations
Dmitry V. Levin [Tue, 3 Jul 2018 13:23:19 +0000 (13:23 +0000)]
ci: robustify network-related operations

Reduce false positives by wrapping network-related operations into a loop.

* ci/install-dependencies.sh (retry_if_failed): New function.
Use it to invoke apt-get update, apt-get install, git clone,
add-apt-repository, and pip install.

6 years ago.gitignore: ignore linux/linux
Zhibin Li [Wed, 27 Jun 2018 16:02:37 +0000 (00:02 +0800)]
.gitignore: ignore linux/linux

Ignore directory linux/linux created by workaround from commit
v4.23-11-g15003d4.

* .gitignore: Add /linux/linux.

6 years agoFix build on systems where libc relies on <linux/signal.h>
Dmitry V. Levin [Mon, 18 Jun 2018 22:59:38 +0000 (22:59 +0000)]
Fix build on systems where libc relies on <linux/signal.h>

Commit v4.23~10 has broken the build with Android's libc because it
relies on the UAPI headers (such as <linux/signal.h>) to define various
types, rather than copying them into the libc headers (such as <signal.h>)
like most other Linux C libraries.

* linux/linux/signal.h: Rename to linux/signal.h.in.
* Makefile.am (strace_SOURCES): Remove linux/linux/signal.h.
(EXTRA_DIST): Add linux/signal.h.in.
(DISTCLEANFILES): Add linux/linux/signal.h.
* configure.ac (AC_CACHE_CHECK): Check whether <linux/signal.h>
can be used along with <signal.h>, install linux/linux/signal.h
workaround if they cannot be used together.

Reported-by: Elliott Hughes <enh@google.com>
Closes: https://github.com/strace/strace/issues/72
6 years agoxlat: add AUDIT_INTEGRITY_EVM_XATTR to nl_audit_types
Eugene Syromyatnikov [Mon, 18 Jun 2018 16:51:02 +0000 (18:51 +0200)]
xlat: add AUDIT_INTEGRITY_EVM_XATTR to nl_audit_types

* xlat/nl_audit_types.in (AUDIT_INTEGRITY_EVM_XATTR): New constant,
introduced by Linux commit v4.18-rc1~100^2~9.

6 years agoxlat: add UDP_SEGMENT to sock_udp_options
Eugene Syromyatnikov [Mon, 18 Jun 2018 16:37:55 +0000 (18:37 +0200)]
xlat: add UDP_SEGMENT to sock_udp_options

* xlat/sock_udp_options.in (UDP_SEGMENT): New constant, introduced by
Linux commit v4.18-rc1~114^2~377^2~8.

6 years agoRemove redundant range initializers in syscallent files
Dmitry V. Levin [Sun, 17 Jun 2018 23:02:51 +0000 (23:02 +0000)]
Remove redundant range initializers in syscallent files

* linux/aarch64/syscallent.h: Remove redundant range initializers.
* linux/x32/syscallent.h: Likewise.

6 years agox32: move rseq syscall entry to a suitable place
Chen Jingpiao [Sun, 17 Jun 2018 14:45:46 +0000 (22:45 +0800)]
x32: move rseq syscall entry to a suitable place

As rseq syscall is not x32-specific, move it after the previous one
that is not x32-specific.  Fix the unused syscall number range.

* linux/x32/syscallent.h ([334]): Move it after [333].
([335 ... 511]): Update the range.

6 years agoaio: make iocb array output more strucutred
Eugene Syromyatnikov [Sun, 17 Jun 2018 21:34:37 +0000 (23:34 +0200)]
aio: make iocb array output more strucutred

* aio.c (print_iocb): Print curly brackets.
(print_iocbp): Do not print curly brackets.
* tests/aio.c: Update expected output.

6 years agoaio: print IOCB_CMD_* using xlat
Eugene Syromyatnikov [Sun, 17 Jun 2018 21:15:51 +0000 (23:15 +0200)]
aio: print IOCB_CMD_* using xlat

* xlat/aio_cmds.in: New file.
* aio.c (tprint_lio_opcode): Change array of structs "cmds" to array of
enums "subs", use printxval_indexn_ex for printing cmd, return sub type
using subs array.

6 years agoxlat/sock_tcp_options.in: add #value_indexed
Eugene Syromyatnikov [Sun, 17 Jun 2018 21:35:38 +0000 (23:35 +0200)]
xlat/sock_tcp_options.in: add #value_indexed

* xlat/sock_tcp_options.in: Add #value_indexed, provide fallback
definitions.
* net.c (print_sockopt_fd_level_name) <case SOL_TCP>: Use
printxval_index instead of printxval.

6 years agoxlat/sock_tcp_options.in: update
Eugene Syromyatnikov [Sun, 17 Jun 2018 08:49:02 +0000 (10:49 +0200)]
xlat/sock_tcp_options.in: update

* xlat/sock_tcp_options.in (TCP_ZEROCOPY_RECEIVE): New constant,
introduced by Linux commit v4.18-rc1~114^2~351^2~1.
(TCP_INQ): New constant, introduced by Linux commit v4.18-rc1~114^2~330.

6 years agoxlat/sigtrap_codes.in: add TRAP_UNK
Eugene Syromyatnikov [Fri, 15 Jun 2018 13:35:37 +0000 (15:35 +0200)]
xlat/sigtrap_codes.in: add TRAP_UNK

* xlat/sigtrap_codes.in (TRAP_UNK): New constant, introduced by Linux
commit v4.17-rc1-15-gdb78e6a.

6 years agoPost-release administrivia
Dmitry V. Levin [Fri, 15 Jun 2018 17:52:14 +0000 (17:52 +0000)]
Post-release administrivia

* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.23-1.
* strace.spec.in: Likewise.

6 years agoPrepare for 4.23 release v4.23
Dmitry V. Levin [Thu, 14 Jun 2018 11:00:00 +0000 (11:00 +0000)]
Prepare for 4.23 release

* NEWS: Update for 4.23 release.

6 years agoUpdate copyright headers
Dmitry V. Levin [Thu, 14 Jun 2018 11:00:00 +0000 (11:00 +0000)]
Update copyright headers

Headers updated automatically using maint/update_copyright_years.sh
script.

6 years agotests: add missing copyright headers
Dmitry V. Levin [Thu, 14 Jun 2018 11:00:00 +0000 (11:00 +0000)]
tests: add missing copyright headers

* tests/prctl-spec-inject.test: Add copyright header.
* tests/qualify_personality.sh: Likewise.

6 years agomaint: document release procedure
Dmitry V. Levin [Thu, 14 Jun 2018 11:00:00 +0000 (11:00 +0000)]
maint: document release procedure

* maint/README-release: New file.
* maint/gen-release-notes.sh: Likewise.
* maint/gen-release-github.sh: Likewise.
* maint/gen-release-gitlab.sh: Likewise.

6 years agomaint: prepend contributor names in tag messages with an asterisk
Dmitry V. Levin [Thu, 14 Jun 2018 11:00:00 +0000 (11:00 +0000)]
maint: prepend contributor names in tag messages with an asterisk

* maint/gen-tag-message.sh: Prepend every line of
gen-contributors-list.sh output with an asterisk.

6 years agoUpdate NEWS
Eugene Syromyatnikov [Thu, 14 Jun 2018 09:48:20 +0000 (11:48 +0200)]
Update NEWS

6 years agoWire up rseq syscall
Dmitry V. Levin [Wed, 13 Jun 2018 23:51:31 +0000 (23:51 +0000)]
Wire up rseq syscall

This new syscall was introduced by Linux commit v4.17-1308-gd7822b1.

* linux/dummy.h (sys_rseq): New macro.
* linux/arm/syscallent.h (398): Add rseq entry.
* linux/i386/syscallent.h (386): Likewise.
* linux/powerpc/syscallent.h (387): Likewise.
* linux/powerpc64/syscallent.h (387): Likewise.
* linux/x32/syscallent.h (334): Likewise.
* linux/x86_64/syscallent.h (334): Likewise.

6 years agotests: check decoding of io_pgetevents syscall
Eugene Syromyatnikov [Wed, 13 Jun 2018 15:38:07 +0000 (17:38 +0200)]
tests: check decoding of io_pgetevents syscall

* configure.ac (AC_CHECK_TYPES): Check for struct __aio_sigset
in <linux/aio_abi.h>.
* tests/aio_pgetevents.c: New file.
* tests/.gitignore: Add aio_pgetevents.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (aio_pgetevents): New test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoImplement io_pgetevents syscall decoding
Eugene Syromyatnikov [Thu, 7 Jun 2018 17:57:28 +0000 (19:57 +0200)]
Implement io_pgetevents syscall decoding

Introduced by Linux commit v4.17-rc3-7-g7a074e9.

* print_aio_sigset.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* aio.c (print_io_getevents): Rename from SYS_FUNC(io_getevents), add
has_usig flag, print user sigset on exiting if has_usig is set to true.
(SYS_FUNC(io_getevents), SYS_FUNC(io_pgetevents)): New functions,
wrappers for print_io_getevents.
* linux/32/syscallent.h ([292]): Wire up io_pgetevents.
* linux/64/syscallent.h ([292]): Likewise.
* linux/i386/syscallent.h ([385]): Likewise.
* linux/x32/syscallent.h ([333]): Likewise.
* linux/x86_64/syscallent.h ([333]): Likewise.
* NEWS: Mention this improvement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotravis: re-enable testing with the latest mainline kernel headers
Dmitry V. Levin [Tue, 12 Jun 2018 12:27:22 +0000 (12:27 +0000)]
travis: re-enable testing with the latest mainline kernel headers

As <linux/signal.h> is out of the game now, the Linux commit
v4.17-rc3-7-g7a074e9 should not cause harm anymore, so let's enable
testing with the latest mainline kernel headers again.

* .travis.yml (matrix): Do not specify KBRANCH for KHEADERS=torvalds/linux.

6 years agoWorkaround incompatibility between <linux/signal.h> and libc headers
Dmitry V. Levin [Tue, 12 Jun 2018 12:27:22 +0000 (12:27 +0000)]
Workaround incompatibility between <linux/signal.h> and libc headers

Override <linux/signal.h> with <signal.h> so that those few linux
headers that include <linux/signal.h> could be included along with libc
headers.

* linux/linux/signal.h: New file.
* Makefile.am (strace_SOURCES): Add it.

6 years agotests: add personality specification syntax checks
Eugene Syromyatnikov [Sun, 20 May 2018 01:31:11 +0000 (03:31 +0200)]
tests: add personality specification syntax checks

* tests/options-syntax.test: Add personality specification syntax
checks.

6 years agotests: add basic checks for personality designation support
Eugene Syromyatnikov [Sun, 20 May 2018 01:14:08 +0000 (03:14 +0200)]
tests: add basic checks for personality designation support

* tests/qualify_personality.sh: New file.
* tests/qualify_personality_empty.in: Likewise.
* tests/trace_personality_32.in: Likewise.
* tests/trace_personality_64.in: Likewise.
* tests/trace_personality_regex_32.in: Likewise.
* tests/trace_personality_regex_64.in: Likewise.
* tests/trace_personality_regex_x32.in: Likewise.
* tests/trace_personality_x32.in: Likewise.
* tests/Makefile.am (EXTRA_DIST): Add them.
* tests/gen_tests.in (trace_personality_32, trace_personality_64,
trace_personality_x32, trace_personality_regex_32,
trace_personality_regex_64, trace_personality_regex_x32): New tests.

6 years agoAdd support for personality designation in regex qualifications
Eugene Syromyatnikov [Sun, 11 Feb 2018 04:24:29 +0000 (05:24 +0100)]
Add support for personality designation in regex qualifications

* basic_filters.c (qualify_syscall_regex): Copy syscall name
to a temporary buffer, append the personality designation to it,
and check it against regular expression if the syscall name
hasn't been matched already.

References: https://github.com/strace/strace/issues/35

6 years agoAdd support for personality designation in syscall qualifications
Eugene Syromyatnikov [Sun, 11 Feb 2018 04:04:05 +0000 (05:04 +0100)]
Add support for personality designation in syscall qualifications

* syscall.c (personality_designators): New array.
* defs.h (personality_designators): New declaration.
* basic_filters.c (qualify_syscall_separate_personality,
qualify_syscall_number_personality): New functions.
(qualify_syscall_number): Use qualify_syscall_separate_personality for
checking for a personality specification, call
qualify_syscall_number_personality for setting number set for specific
personality.
(qualify_syscall_name_personality): New function.
(qualify_syscall_name): Use qualify_syscall_separate_personality for
checking for a personality specification, call
qualify_syscall_name_personality for setting number set for specific
personality.
* strace.1.in (.SS Filtering): Document it.
* NEWS: Mention it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://github.com/strace/strace/issues/35
6 years agotests: add basic checks for inject=SET:syscall= expression syntax
Eugene Syromyatnikov [Thu, 7 Jun 2018 17:41:49 +0000 (19:41 +0200)]
tests: add basic checks for inject=SET:syscall= expression syntax

* tests/qual_fault-syscall.test: New test.
* tests/qual_inject-error-signal-syscall.test: Likewise.
* tests/qual_inject-retval-syscall.test: Likewise.
* tests/qual_inject-signal-syscall.test: Likewise.
* tests/Makefile.am (MISC_TESTS): Add them.
* tests/qual_fault-syntax.test: Add checks for inject=SET:syscall=
expression syntax.
* tests/qual_inject-syntax.test: Likewise.
* tests/qual_fault.test: Append $suffix to -e fault arguments, override
$NAME with $name_override if the latter is set.
* tests/qual_inject-error-signal.test: Append $suffix to -e inject
arguments, override $NAME with $name_override if the latter is set.
* tests/qual_inject-retval.test: Likewise.
* tests/qual_inject-signal.test: Likewise.

6 years agoImplement injection of syscalls with no side effects as an alternative to -1
Eugene Syromyatnikov [Thu, 1 Feb 2018 12:51:17 +0000 (13:51 +0100)]
Implement injection of syscalls with no side effects as an alternative to -1

* defs.h (INJECT_F_SYSCALL, INJECT_ACTION_FLAGS, TCB_TAMPERED_NO_FAIL,
syscall_tampered_nofail): New macros.
(inject_data): Add scno field.
* filter_qualify.c (struct inject_personality_data): New type.
(parse_inject_token): Add "pdata" argument, parse "syscall=" option.
(parse_inject_expression): Add "pdata" argument, forward it to
parse_inject_token.
(qualify_inject_common) <pdata>: New variable array, pass it to
parse_inject_expression, copy it into inject_vec.
* syscall.c (tamper_with_syscall_entering): Inject the specified syscall
if INJECT_F_SYSCALL is set.
(tamper_with_syscall_exiting): Update the check for a failed syscall
injection.
(get_syscall_result): Update get_error invocation.
* strace.1.in: Document new syscall injection expression.
* NEWS: Mention it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://github.com/strace/strace/issues/26
6 years agoia64: remove legacy i386 entries from the syscall entry table
Dmitry V. Levin [Wed, 13 Jun 2018 15:05:09 +0000 (15:05 +0000)]
ia64: remove legacy i386 entries from the syscall entry table

Remove the last piece of IA-32 mode support.  Besides being obsolete,
these bogus syscall entries cause problems with syscall name resolution.

* linux/ia64/syscallent.h [CST > 0]: Remove.

Complements: v4.21~17 "linux/ia64: remove IA-32 mode support"

6 years agolinux: set error flags in arch_set_error on POWER and Alpha
Eugene Syromyatnikov [Sun, 10 Jun 2018 12:25:37 +0000 (14:25 +0200)]
linux: set error flags in arch_set_error on POWER and Alpha

* alpha/set_error.c (arch_set_error): Set alpha_r3 to 1, update tracee's
REG_A3.
* powerpc/set_error.c (arch_set_error): Set bit 28 in CCR register,
update tracee's PT_CCR.

Fixes: v4.15~126 "Implement arch specific methods of changing syscall number and error code"
6 years agotests: check decoding of IFLA_LINKINFO netlink attribute
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:54:08 +0000 (12:54 +0200)]
tests: check decoding of IFLA_LINKINFO netlink attribute

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

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: add print_quoted_stringn to print string with a size limit
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:52:52 +0000 (12:52 +0200)]
tests: add print_quoted_stringn to print string with a size limit

This is similar to print_quoted_cstring, but not quite the same.

* tests/print_quoted_string.c (print_quoted_stringn): New function.
* tests/tests.h (print_quoted_stringn): New declaration.

6 years agotests: add fallback_func argument to TEST_NESTED_NLATTR_OBJECT_EX_
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:49:20 +0000 (12:49 +0200)]
tests: add fallback_func argument to TEST_NESTED_NLATTR_OBJECT_EX_

* tests/test_nlattr.h (TEST_NESTED_NLATTR_OBJECT_EX_): Add fallback_func
argument, call it instead of print_quoted_hex.
(TEST_NESTED_NLATTR_OBJECT_EX, TEST_NESTED_NLATTR_OBJECT): Specify
print_quoted_hex as a fallback_func.
* tests/nlattr_ifla_af_spec.c: Specify print_quoted_hex as
a fallback_func in TEST_NESTED_NLATTR_OBJECT_EX_ calls.

6 years agotests/test_nlattr.h: add ability to provide additional nlattr payload
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:46:19 +0000 (12:46 +0200)]
tests/test_nlattr.h: add ability to provide additional nlattr payload

* tests/test_nlattr.h (print_nlattr): Add add_data argument, print
opening square bracket if add_data is set to true.
(TEST_NLATTR_EX_): Rename from TEST_NLATTR_, add nla_total_len_
argument, use it for msg_len calculation, print square brackets
if nla_total_len_ is greater than nla_data_len_.
(TEST_NLATTR_): New macro, a wrapper for TEST_NLATTR_EX_.

6 years agortnl_link: decode struct ifla_bridge_id unconditionally
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:28:11 +0000 (12:28 +0200)]
rtnl_link: decode struct ifla_bridge_id unconditionally

Since it is relatively simple.

* rtnl_link.c (decode_ifla_bridge_id): Provide struct definition for
the id variable.
[!HAVE_STRUCT_IFLA_BRIDGE_ID] (decode_ifla_bridge_id): Decode struct
ifla_bridge_id.

6 years agonlattr: specify size for ethernet protocol
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:43:33 +0000 (12:43 +0200)]
nlattr: specify size for ethernet protocol

Otherwise it tries to decode payload of size 1, which makes little
sense.

* nlattr.c (decode_nla_ether_proto) <opts>: Specify size field.

Fixes: v4.22-321-gfd0cd65 "nlattr: add ethernet protocol decoder"
6 years agortnl_link: use ARRSZ_PAIR where appropriate
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:39:11 +0000 (12:39 +0200)]
rtnl_link: use ARRSZ_PAIR where appropriate

It reduces code duplication somewhat and allows avoiding errors like
the one fixed in the previous commit.

* rtnl_link.c (decode_ifla_protinfo, decode_nla_linkinfo_data_bridge,
decode_nla_linkinfo_data_tun, decode_ifla_linkinfo, decode_ifla_port,
decode_ifla_vf_ports, decode_ifla_xdp,
DECL_NETLINK_ROUTE_DECODER(decode_ifinfomsg)): Use ARRSZ_PAIR in
decode_nlattr call arguments.

6 years agortnl_link: fix incorrect variable names in ARRAY_SIZE arguments
Eugene Syromyatnikov [Sun, 10 Jun 2018 10:29:58 +0000 (12:29 +0200)]
rtnl_link: fix incorrect variable names in ARRAY_SIZE arguments

* rtnl_link.c (decode_nla_linkinfo_data_bridge): Change
rtnl_ifla_info_data_bridge_attrs to ifla_info_data_bridge_nla_decoders
in ARRAY_SIZE call.
(decode_nla_linkinfo_data_tun): Change rtnl_ifla_info_data_tun_attrs
to ifla_info_data_tun_nla_decoders in ARRAY_SIZE call.

Fixes: v4.22-328-g1e6d5a8 "rtnl_link: implement IFLA_INFO_DATA for bridges"
Fixes: v4.22-329-g4eab3a4 "rtnl_link: implement IFLA_INFO_DATA for tun devices"
6 years agomips: add missing pure flag to syscall entries
Eugene Syromyatnikov [Mon, 11 Jun 2018 05:34:42 +0000 (07:34 +0200)]
mips: add missing pure flag to syscall entries

* linux/mips/syscallent-n32.h ([6038], [6100], [6102], [6105], [6106],
[6108], [6109], [6178]): Add pure flag to getpid, getuid, getgid, geteuid,
getegid, getpgid, getpgrp, and gttid syscall descriptors.
* linux/mips/syscallent-n64.h ([5038], [5100], [5102], [5105], [5106],
[5108], [5109], [5178]): Likewise.
* linux/mips/syscallent-o32.h ([4020], [4024], [4047], [4049], [4050],
[4064], [4065], [4222]): Likewise.

Complements: v4.21~29 "Add pure syscall flag"

6 years agomips: add missing "never fails" flag to getpgrp syscall entries
Eugene Syromyatnikov [Mon, 11 Jun 2018 05:32:11 +0000 (07:32 +0200)]
mips: add missing "never fails" flag to getpgrp syscall entries

* linux/mips/syscallent-n32.h ([6109]): Add NF flag.
* linux/mips/syscallent-n64.h ([5109]): Likewise.
* linux/mips/syscallent-o32.h ([4065]): Likewise.

Complements: v4.21~46 "Add SYSCALL_NEVER_FAILS flag to getpgrp"

6 years agoUpdate NEWS
Eugene Syromyatnikov [Fri, 1 Jun 2018 17:00:16 +0000 (19:00 +0200)]
Update NEWS

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat: describe IPV4_DEVCONF_* weirdness
Eugene Syromyatnikov [Thu, 7 Jun 2018 18:02:01 +0000 (20:02 +0200)]
xlat: describe IPV4_DEVCONF_* weirdness

* xlat/inet_devconf_indices.in: Add a comment about fallback definitions.

6 years agoconfigure.ac: fix the check for struct tc_sizespec on old kernel headers
Dmitry V. Levin [Thu, 7 Jun 2018 14:01:24 +0000 (14:01 +0000)]
configure.ac: fix the check for struct tc_sizespec on old kernel headers

* configure.ac (AC_CHECK_TYPES): Include <linux/types.h> before
<linux/pkt_sched.h> to check for struct tc_sizespec on linux kernel
headers without v2.6.29-rc4~77^2~26 fix.

6 years agotravis: use kernel headers from v4.17
Dmitry V. Levin [Wed, 6 Jun 2018 15:10:37 +0000 (15:10 +0000)]
travis: use kernel headers from v4.17

There is too much noise when using unreleased kernel uapi.

* ci/install-dependencies.sh (clone_repo): Add optional "branch"
argument, pass it to "git clone".
($KHEADERS): Pass $KBRANCH as branch argument of clone_repo.
* .travis.yml (matrix): Specify KBRANCH=v4.17 for
KHEADERS=torvalds/linux.

6 years agotests: check decoding of IFLA_AF_SPEC netlink attribute
Eugene Syromyatnikov [Fri, 25 May 2018 03:14:18 +0000 (05:14 +0200)]
tests: check decoding of IFLA_AF_SPEC netlink attribute

* configure.ac (AC_CHECK_TYPES): Check for struct ifla_cacheinfo in
<linux/rtnetlink.h>
(AC_CHECK_DECLS): Check for IFLA_AF_SPEC in <linux/rtnetlink.h>.
* tests/nlattr_ifla_af_spec.c: New file.
* tests/pure_executables.list: Add nlattr_ifla_af_spec.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (nlattr_ifla_af_spec): New test.

6 years agotests: add TEST_NESTED_NLATTR_ARRAY_EX to test_nlattr.h
Eugene Syromyatnikov [Fri, 25 May 2018 03:09:53 +0000 (05:09 +0200)]
tests: add TEST_NESTED_NLATTR_ARRAY_EX to test_nlattr.h

An ability to specify custom depth is going to be needed later to check
IFLA_AF_SPEC decoding.

* configure.ac (AC_CHECK_DECLS): Check for TCA_STAB_DATA in
<linux/pkt_sched.h>.
* tests/test_nlattr.h (TEST_NESTED_NLATTR_ARRAY_EX): Rename from
TEST_NESTED_NLATTR_ARRAY, add depth_ argument, perform padding and
output accordingly.
(TEST_NESTED_NLATTR_ARRAY): New macro, a thin wrapper around
TEST_NESTED_NLATTR_ARRAY_EX.
* tests/nlattr_tca_stab.c [!HAVE_DECL_TCA_STAB_DATA] (TCA_STAB_DATA):
New enumeration declaration.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: pass index to print_elem_ callback in TEST_NLATTR_NESTED_ARRAY
Eugene Syromyatnikov [Fri, 25 May 2018 03:08:04 +0000 (05:08 +0200)]
tests: pass index to print_elem_ callback in TEST_NLATTR_NESTED_ARRAY

* tests/test_nlattr.h (TEST_NLATTR_NESTED_ARRAY): Pass array index
to the print_elem_ callback.
* tests/nlattr_tca_stab.c (print_uint16): Add index argument.

6 years agotests: move common ifinfomsg boilerplate into a separate header
Eugene Syromyatnikov [Thu, 24 May 2018 23:49:08 +0000 (01:49 +0200)]
tests: move common ifinfomsg boilerplate into a separate header

* configure.ac (AC_CHECK_DECLS): Check for IFLA_PORT_SELF, IFLA_PROTINFO, and
IFLA_XDP in <linux/rtnetlink.h>.
* tests/nlattr_ifla.h: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/nlattr_ifla_brport.c [!HAVE_DECL_IFLA_PROTINFO] (IFLA_PROTINFO):
New declaration.
(hdrlen, init_ifinfomsg, print_ifinfomsg): Remove.
(IFLA_ATTR): Define to IFLA_PROTINFO.
Include nlattr_ifla.h.
* tests/nlattr_ifla_port.c [!HAVE_DECL_IFLA_PORT_SELF] (IFLA_PORT_SELF):
New declaration.
(hdrlen, init_ifinfomsg, print_ifinfomsg): Remove.
(IFLA_ATTR): Define to IFLA_PORT_SELF.
Include nlattr_ifla.h.
* tests/nlattr_ifla_xdp.c
* tests/nlattr_ifla_xdp.c [!HAVE_DECL_IFLA_XDP] (IFLA_XDP): New
declaration.
(hdrlen, init_ifinfomsg, print_ifinfomsg): Remove.
(IFLA_ATTR): Define to IFLA_XDP.
Include nlattr_ifla.h.

6 years agortnl_link: implement IFLA_INFO_DATA for tun devices
Eugene Syromyatnikov [Fri, 18 May 2018 16:08:25 +0000 (18:08 +0200)]
rtnl_link: implement IFLA_INFO_DATA for tun devices

* xlat/rtnl_ifla_info_data_tun_attrs.in: New file.
* xlat/tun_device_types.in: Likewise.
* rtnl_link.c: Include xlat/rtnl_ifla_info_data_tun_attrs.h and
xlat/tun_device_types.h.
(decode_nla_tun_type, decode_nla_linkinfo_data_tun): New functions.
(ifla_info_data_tun_nla_decoders): New decoder dispatcher table.
(decode_nla_linkinfo_data): Use decode_nla_linkinfo_data_tun if kind
is
"tun".

6 years agortnl_link: implement IFLA_INFO_DATA for bridges
Eugene Syromyatnikov [Fri, 18 May 2018 15:47:05 +0000 (17:47 +0200)]
rtnl_link: implement IFLA_INFO_DATA for bridges

* xlat/rtnl_ifla_info_data_bridge_attrs.in: New file.
* rtnl_link.c: Include xlat/rtnl_ifla_info_data_bridge_attrs.h.
(ifla_info_data_bridge_nla_decoders): New decoder dispatcher table.
(decode_nla_linkinfo_data_bridge, decode_nla_linkinfo_data): New
functions.
(ifla_linkinfo_nla_decoders) <IFLA_INFO_DATA>: Use
decode_nla_linkinfo_data as a decoder.

6 years agortnl_link: implement IFLA_INFO_XSTATS decoding
Eugene Syromyatnikov [Fri, 18 May 2018 15:45:33 +0000 (17:45 +0200)]
rtnl_link: implement IFLA_INFO_XSTATS decoding

So far, only CAN provides it.

* rtnl_link.c (decode_nla_linkinfo_xstats_can,
decode_nla_linkinfo_xstats): New function.
(ifla_linkinfo_nla_decoders) <IFLA_INFO_XSTATS>: Use
decode_nla_linkinfo_xstats as a decoder.

6 years agortnl_link: add basic IFLA_INFO_* handling
Eugene Syromyatnikov [Fri, 18 May 2018 15:42:18 +0000 (17:42 +0200)]
rtnl_link: add basic IFLA_INFO_* handling

Dispatch for IFLA_INFO_* attributes should be performed based on the
string provided in a IFLA_INFO_KIND attribute.

* nlattr.h (struct ifla_linkinfo_ctx): New type definition.
* rtnl_link.c (decode_nla_linkinfo_kind): New function.
(ifla_linkinfo_nla_decoders) <IFLA_INFO_KIND>: Use
decode_nla_linkinfo_kind as decoder.
(decode_ifla_linkinfo): Add struct ifla_linkinfo_ctx context, pass it to
the decode_nlattr call as opaque data.

6 years agortnl_link: decode IFLA_AF_SPEC
Eugene Syromyatnikov [Mon, 7 May 2018 06:45:29 +0000 (08:45 +0200)]
rtnl_link: decode IFLA_AF_SPEC

* xlat/in6_addr_gen_mode.in: New file.
* xlat/inet6_devconf_indices.in: Likewise.
* xlat/inet6_if_flags.in: Likewise.
* xlat/inet_devconf_indices.in: Likewise.
* xlat/rtnl_ifla_af_spec_inet6_attrs.in: Likewise.
* xlat/rtnl_ifla_af_spec_inet_attrs.in: Likewise.
* xlat/snmp_icmp6_stats.in: Likewise.
* xlat/snmp_ip_stats.in: Likewise.
* rtnl_link.c: Include netinet/in.h, xlat/in6_addr_gen_mode.h,
xlat/inet_devconf_indices.h, xlat/inet6_devconf_indices.h,
xlat/inet6_if_flags.h, xlat/rtnl_ifla_af_spec_inet_attrs.h,
xlat/rtnl_ifla_af_spec_inet6_attrs.h, xlat/snmp_icmp6_stats.h,
and xlat/snmp_ip_stats.h.
(decode_ifla_inet_conf, decode_ifla_inet6_flags,
decode_ifla_inet6_conf, decode_ifla_inet6_stats,
decode_ifla_inet6_cacheinfo, decode_ifla_inet6_icmp6_stats,
decode_ifla_inet6_token, decode_ifla_inet6_agm, decode_ifla_af,
decode_ifla_af_spec): New functions.
(ifla_inet_nla_decoders, ifla_inet6_nla_decoders,
nla_decoder_table_desc): New static constant variables.
(ifinfomsg_nla_decoders) <[IFLA_AF_SPEC]>: Change value from NULL to
decode_ifla_af_spec.

6 years agonlattr: add size check to decode_nla_xval and decode_nla_flags
Eugene Syromyatnikov [Wed, 23 May 2018 16:50:48 +0000 (18:50 +0200)]
nlattr: add size check to decode_nla_xval and decode_nla_flags

If the field size is known, do not print as valid numbers those
attributes that are too short, and ignore extra data.

This change puts xval/flags printing in line with the reset of attribute
decoders.

* nlattr.h (struct decode_nla_xlat_opts): Add size field.
* nlattr.c (decode_nla_xval, decode_nla_flags): Check that len is at
least opts->size, limit len to opts->size.
(decode_nla_ip_proto): Specify size of 1.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agonlattr: add UID/GID netlink attribute decoders
Eugene Syromyatnikov [Fri, 18 May 2018 16:06:38 +0000 (18:06 +0200)]
nlattr: add UID/GID netlink attribute decoders

* nlattr.h (DECL_NLA(uid), DECL_NLA(gid)): New declarations.
* nlattr.c (decode_nla_uid, decode_nla_gid): New functions.

6 years agonlattr: add unsigned int decoders that print in hex form
Eugene Syromyatnikov [Fri, 18 May 2018 15:38:43 +0000 (17:38 +0200)]
nlattr: add unsigned int decoders that print in hex form

* nlattr.h (DECL_NLA(x8), DECL_NLA(x16), DECL_NLA(x32), DECL_NLA(x64)):
New declarations.
* nlattr.c (DECODE_NLA_INTEGER(x8, uint8_t, "%#" PRIx8),
DECODE_NLA_INTEGER(x16, uint16_t, "%#" PRIx16),
DECODE_NLA_INTEGER(x32, uint32_t, "%#" PRIx32),
DECODE_NLA_INTEGER(x64, uint64_t, "%#" PRIx64)): New decoders.

6 years agonlattr: add ethernet protocol decoder
Eugene Syromyatnikov [Fri, 18 May 2018 15:37:51 +0000 (17:37 +0200)]
nlattr: add ethernet protocol decoder

* nlattr.h (DECL_NLA(ether_proto)): New declaration.
* nlattr.c (process_host_order, decode_nla_ether_proto): New functions.

6 years agonlattr: add value processing support for xlat/flags nlattr decoders
Eugene Syromyatnikov [Fri, 18 May 2018 15:36:00 +0000 (17:36 +0200)]
nlattr: add value processing support for xlat/flags nlattr decoders

Needed for upcoming decoder of ethernet proto which is stored in the
host order and has to be converted to the network order before printing
as an xval constant.  This change also adds ability to provide
prefix/suffix in order to enclose the printed value in something that
describes the performed conversion.

* nlattr.h (struct decode_nla_xlat_opts): Add prefix, suffix, and
process_fn fields.
* nlattr.c (decode_nla_xval, decode_nla_flags): Handle process_fn,
prefix, snd uffix parameters.

6 years agonlattr: introduce decode_nla_flags
Eugene Syromyatnikov [Mon, 7 May 2018 06:40:02 +0000 (08:40 +0200)]
nlattr: introduce decode_nla_flags

Similar to decode_nla_xval.

* nlattr.c (decode_nla_flags): New function.
* nlattr.h: (DECL_NLA(flags)): New declaration.

6 years agonlattr: add ability to pass nla_type to decoder in decode_nlattr
Eugene Syromyatnikov [Mon, 7 May 2018 06:28:38 +0000 (08:28 +0200)]
nlattr: add ability to pass nla_type to decoder in decode_nlattr

As of now, it's impossible to introduce a dispatching nlattr decoder
that performs actions based on the type of the message, so let's use
a combination of zero decoder list size and non-zero decoder pointer
for this.

This is going to be used later in IFLA_AF_SPEC decoding.

* nlattr.c (decode_nlattr_with_data): Handle zero size and non-NULL
decoders in a special way.
(decode_nlattr): Add an error message about ignoring of opaque_data
argument when zero size and non-NULL decoders are provided.
* nlattr.h (decode_nlattr): Add a comment about the new special case.

6 years agotests: use STRINGIFY instead of _STR
Dmitry V. Levin [Wed, 6 Jun 2018 10:10:43 +0000 (10:10 +0000)]
tests: use STRINGIFY instead of _STR

Remove _STR which is essentially the same as STRINGIFY but from
the namespace where we should not introduce new identifiers.

* tests/tests.h (_STR): Remove.
* tests/add_key.c (main): Replace _STR with STRINGIFY.
* tests/keyctl.c (XARG_STR): Likewise.
* tests/request_key.c (main): Likewise.

6 years agotests: check decoding of IFLA_EVENT netlink attribute
Eugene Syromyatnikov [Fri, 25 May 2018 12:36:35 +0000 (14:36 +0200)]
tests: check decoding of IFLA_EVENT netlink attribute

* tests/nlattr_ifinfomsg.c (main): Add a check for IFLA_EVENT attribute
decoding.

6 years agoxlat: handle xlat constants that are not identifiers
Dmitry V. Levin [Tue, 5 Jun 2018 11:04:09 +0000 (11:04 +0000)]
xlat: handle xlat constants that are not identifiers

Extend xlat generator to support such input lines as
IPV4_DEVCONF_FORWARDING-1 0

This is going to be used later in IFLA_AF_SPEC decoding.

* xlat/gen.sh (cond_def): If the xlat value is not an identifier name,
extract an identifier name from the beginning of xlat value.

6 years agoxlat.c: handle NULL xlat in lookup routines as incremental search
Eugene Syromyatnikov [Mon, 7 May 2018 05:57:27 +0000 (07:57 +0200)]
xlat.c: handle NULL xlat in lookup routines as incremental search

This is going to be used later in IFLA_AF_SPEC decoding.

* xlat.c (xlookup): Add static variable pos, store xlat there when it is
non-NULL, use pos for lookup.
(xlat_search, xlat_idx): Add static variables pos and memb_left, store
xlat and nmemb there when xlat is non-NULL, use them for lookup.
(printxvals_ex): Store the last non-NULL xlat in static variable "last".
If the first xlat argument is NULL, use "last" instead.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat.c: cleanup printxvals_ex a bit
Eugene Syromyatnikov [Mon, 7 May 2018 06:51:06 +0000 (08:51 +0200)]
xlat.c: cleanup printxvals_ex a bit

* xlat.c (printxvals_ex): Change "str" variable visibility to the whole
function, jump to va_end instead of duplicating call and return, return
!!str.

6 years agoLeverage the fact that inet_protocols xlat is sorted
Eugene Syromyatnikov [Wed, 23 May 2018 16:48:26 +0000 (18:48 +0200)]
Leverage the fact that inet_protocols xlat is sorted

* defs.h (inet_protocols): Move up, add description.
(inet_protocols_size): New declaration.
* net.c (inet_protocols_size): New constant variable.
* nlattr.c (decode_nla_ip_proto): Specify xlat_size, set xt to XT_SORTED.

6 years agoPrint arp_hardware_types as a sorted xlat
Eugene Syromyatnikov [Wed, 30 May 2018 13:26:09 +0000 (15:26 +0200)]
Print arp_hardware_types as a sorted xlat

* rtnl_link.c (DECL_NETLINK_ROUTE_DECODER(decode_ifinfomsg)): Use
PRINT_FIELD_XVAL_SORTED_SIZED instead of PRINT_FIELD_XVAL for
arp_hardware_types.
* sock.c (print_ifreq): Likewise.

6 years agoProvide a value for arp_hardware_types_size array
Eugene Syromyatnikov [Mon, 7 May 2018 06:52:30 +0000 (08:52 +0200)]
Provide a value for arp_hardware_types_size array

* defs.h (arp_hardware_types_size): New declaration.
* sockaddr.c (arp_hardware_types_size): New variable.

6 years agoprint_fields.h: introduce PRINT_FIELD_XVAL_SORTED_SIZED
Eugene Syromyatnikov [Wed, 30 May 2018 13:23:37 +0000 (15:23 +0200)]
print_fields.h: introduce PRINT_FIELD_XVAL_SORTED_SIZED

For those cases when array definition is not readily available
and should be provided separately.

* print_fields.h (PRINT_FIELD_XVAL_SORTED_SIZED): New macro.

6 years agotests/opipe.test: remove unneeded run_prog call
Eugene Syromyatnikov [Sun, 3 Jun 2018 08:23:56 +0000 (10:23 +0200)]
tests/opipe.test: remove unneeded run_prog call

There is no need to invoke grep using run_prog.

* tests/opipe.test: Remove run_prog decoration for the grep invocation.

6 years agotests: check BPF_OBJ_GET_INFO_BY_FD decoding
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:55:21 +0000 (02:55 +0200)]
tests: check BPF_OBJ_GET_INFO_BY_FD decoding

* tests/bpf-obj_get_info_by_fd-prog-v.c: New file.
* tests/bpf-obj_get_info_by_fd-prog.c: Likewise.
* tests/bpf-obj_get_info_by_fd-v.c: Likewise.
* tests/bpf-obj_get_info_by_fd.c: Likewise.
* configure.ac (AC_CHECK_HEADERS): Check for struct bpf_insn,
struct bpf_map_info, and struct bpf_prog_info.
* tests/pure_executables.list: Add bpf-obj_get_info_by_fd,
bpf-obj_get_info_by_fd-v, bpf-obj_get_info_by_fd-prog, and
bpf-obj_get_info_by_fd-prog-v.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (bpf-obj_get_info_by_fd,
bpf-obj_get_info_by_fd-v, bpf-obj_get_info_by_fd-prog,
bpf-obj_get_info_by_fd-prog-v): New tests.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder further
Dmitry V. Levin [Mon, 4 Jun 2018 01:11:05 +0000 (01:11 +0000)]
bpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder further

* bpf.c (print_ebpf_prog): Remove "decode" argument, all users updated.
(print_bpf_prog_info): Use the minimum of xlated_prog_len values on
entering and exiting syscall as the size of xlated_prog_insns array
to be decoded.  Likewise, use the minimum of nr_map_ids values on entering
and exiting syscall as the size of map_ids array to be decoded.

6 years agobpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:53:00 +0000 (02:53 +0200)]
bpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder

* bpf.c (print_bpf_map_info): Print only those fields that are
present in the structure, as it has been growing over time.
(print_bpf_prog_info): Likewise.  Print map_ids field as an array
of uint32_t instead of uint64_t; print "name" field.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: move handling of the saved state to BPF_OBJ_GET_INFO_BY_FD decoder
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:49:09 +0000 (02:49 +0200)]
bpf: move handling of the saved state to BPF_OBJ_GET_INFO_BY_FD decoder

As it is needed for proper info_len printing on exiting.

* bpf.c (print_bpf_obj_info_fn): Change return type to void, add "saved"
argument.
(struct obj_get_info_saved): New type definition.
(print_bpf_map_info, print_bpf_prog_info): Change return type to void,
add "saved" argument, do not handle private tcb data allocation and
obtainment.
(print_bpf_obj_info_addr): Change return type to void, add tcb argument,
print the address only on exiting.
(print_bpf_obj_info): Change return type to void, add "saved" argument.
(BEGIN_BPF_CMD_DECODER(BPF_OBJ_GET_INFO_BY_FD)): Handle private data
allocation/saving/restoring, use it for storing/printing info_len field.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: print log_buf field as a string
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:38:35 +0000 (02:38 +0200)]
bpf: print log_buf field as a string

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print log_buf field
as a string.
* tests/bpf.c: Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: print xlated_prog_insns only when xlated_prog_len had not been 0
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:44:04 +0000 (02:44 +0200)]
bpf: print xlated_prog_insns only when xlated_prog_len had not been 0

If xlated_prog_len is zero on entering syscall and non-zero on exiting,
the program itself is not written into xlated_prog_insns.

* bpf.c (print_ebpf_prog): Add decode argument, print the address only
if decode is false.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Specify decode == true argument
to print_ebpf_prog.
(print_bpf_prog_info): Specify saved xlated_prog_len as decode argument
to print_ebpf_prog.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: move print_big_u64_addr inside print_ebpf_prog
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:36:59 +0000 (02:36 +0200)]
bpf: move print_big_u64_addr inside print_ebpf_prog

* bpf.c (print_ebpf_prog): Add static qualifier.  Change the type
of "addr" argument from kernel_ulong_t to uint64_t, print it using
print_big_u64_addr.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD), print_bpf_prog_info): Do not call
print_big_u64_addr before print_ebpf_prog.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf_attr.h: add ATTRIBUTE_ALIGNED(8) to all fields of type uint64_t
Dmitry V. Levin [Fri, 1 Jun 2018 19:43:35 +0000 (19:43 +0000)]
bpf_attr.h: add ATTRIBUTE_ALIGNED(8) to all fields of type uint64_t

Our policy is that all fields of type uint64_t in this header file
must have this attribute.

This shouldn't cause any contradictions with <linux/bpf.h>
unless the latter is buggy.

By word "buggy" I mean containing such changes as Linux kernel commit
v4.16-rc1~123^2~109^2~5^2~4.

* bpf_attr.h (struct BPF_MAP_UPDATE_ELEM_struct): Add
ATTRIBUTE_ALIGNED(8) to "flags" field.
(struct bpf_prog_info_struct): Add ATTRIBUTE_ALIGNED(8) to "load_time"
field.

6 years agotests: cast printf arguments to short when %h format qualifier is used
Eugene Syromyatnikov [Sat, 2 Jun 2018 16:25:56 +0000 (18:25 +0200)]
tests: cast printf arguments to short when %h format qualifier is used

Reported by clang.

* tests/mknod.c (main): Cast printf argument for %#03ho format to short.
* tests/mknodat.c (main): Likewise.
* tests/net-sockaddr.c (main): Cast printf argument for %hu format
to short.
* tests/semop.c (main): Likewise.

6 years agoxlat/evdev_keycode.in: remove constants with duplicating values
Eugene Syromyatnikov [Sat, 2 Jun 2018 08:37:01 +0000 (10:37 +0200)]
xlat/evdev_keycode.in: remove constants with duplicating values

Those are used for describing input device category and not specific
button.

Reported by clang.

* xlat/evdev_keycode.in (BTN_MOUSE, BTN_JOYSTICK, BTN_GAMEPAD, BTN_DIGI,
BTN_WHEEL, BTN_TRIGGER_HAPPY): Remove.

6 years agoconfigure.ac: include <sys/socket.h> before <linux/rtnetlink.h>
Eugene Syromyatnikov [Fri, 1 Jun 2018 13:29:25 +0000 (15:29 +0200)]
configure.ac: include <sys/socket.h> before <linux/rtnetlink.h>

This is needed for old Linux UAPI headers that do no contain commit
v3.1-rc2~19^2~29.

* configure.ac: Include <sys/socket.h> before <linux/rtnetlink.h>
in AC_CHECK_* invocations.

6 years agoconfigure.ac: check for linux/rtnetlink.h instead of linux/if_link.h for declarations
Eugene Syromyatnikov [Fri, 1 Jun 2018 10:13:52 +0000 (12:13 +0200)]
configure.ac: check for linux/rtnetlink.h instead of linux/if_link.h for declarations

Historically, type definitions and declarations related to netlink route
interface attributes were in linux/rtnetlink.h, later they were moved
elsewhere (first linux/if.h, then linux/if_link.h) with the inclusion
of the corresponding header file in linux/rtnetlink.h.

* configure.ac: Use <linux/rtnetlink.h> instead of <linux/if_link.h>
in checks for interface netlink attributes-related declarations
and definitions.

6 years agom4: move the gawk script from m4/gen_bpf_attr_m4.sh into a separate file
Eugene Syromyatnikov [Fri, 1 Jun 2018 12:05:48 +0000 (14:05 +0200)]
m4: move the gawk script from m4/gen_bpf_attr_m4.sh into a separate file

As it turns out, old versions of gawk do not support -e option.

* m4/gen_bpf_attr_m4.sh: Move the gawk script ...
* m4/gen_bpf_attr_m4.awk: ... here.

6 years agos390: wire up kexec_file_load syscall
Eugene Syromyatnikov [Fri, 1 Jun 2018 01:20:18 +0000 (03:20 +0200)]
s390: wire up kexec_file_load syscall

* linux/s390/syscallent.h ([381]): Add kexec_file_load syscall.
* linux/s390/syscallent.h ([381]): Likewise.

6 years agotests: check short read of struct flock/flock64
Zhibin Li [Wed, 30 May 2018 11:21:59 +0000 (19:21 +0800)]
tests: check short read of struct flock/flock64

* tests/fcntl-common.c (test_flock_einval): Check short read
of struct flock.
(test_flock64_einval): Check short read of struct flock64.

6 years agotests: extend struct flock/flock64 decoding checks
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: extend struct flock/flock64 decoding checks

* tests/fcntl-common.c (test_flock_einval, test_flock): Create
struct_kernel_flock object using tail_alloc.
(test_flock64_einval): Create struct_kernel_flock64 object using
tail_alloc.
* tests/fcntl64.c (test_flock64_lk64): Likewise.

6 years agotests: extend F_OFD_* decoding checks
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: extend F_OFD_* decoding checks

Check that non-faulty F_OFD_* fcntl operations are decoded properly.

* tests/fcntl-common.c: Include <string.h>.
(test_flock64_ofd): New function.
(test_flock64): Invoke it, remove [F_OFD_SETLK].

6 years agotests/fcntl-common.c: define and initialize errstr
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests/fcntl-common.c: define and initialize errstr

Initialize errstr inside invoke_test_syscall so that its users
won't have to go into trouble of caring about clobbering errno.

* tests/fcntl-common.c (errstr): New variable.
(invoke_test_syscall): Initialize it.
(test_flock_einval, test_flock64_einval, test_flock,
test_f_owner_ex_type_pid): Use it.
* tests/fcntl.c (test_flock64_undecoded): Likewise.
* tests/fcntl64.c (test_flock64_lk64): Likewise.

6 years agotests/fcntl-common.c: add fd argument to invoke_test_syscall
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests/fcntl-common.c: add fd argument to invoke_test_syscall

Extend invoke_test_syscall for later use with different file
descriptors.

* tests/fcntl-common.c (invoke_test_syscall): Add fd argument, pass it
to TEST_SYSCALL_NR syscall.  All users updated.

6 years agotests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c

This change enables F_OFD_SETLK* tests for fcntl as well.

* tests/fcntl64.c (test_flock64): Rename to test_flock64_lk64.
[F_OFD_SETLK]: Remove.
(test_flock64_einval): Move ...
* tests/fcntl-common.c: ... here.
(test_flock64_lk64): New protype.
(test_flock64_einval, test_flock64): New functions.
* tests/fcntl.c (test_flock64_einval): Rename to test_flock64_undecoded.
(TEST_FLOCK64_UNDECODED): New macro.
(test_flock64): Rename to test_flock64_lk64, replace TEST_FLOCK64_EINVAL
with TEST_FLOCK64_UNDECODED.

6 years agotests: move F_OWNER_* tests to fcntl-common.c
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: move F_OWNER_* tests to fcntl-common.c

This change enables F_OWNER_* tests for fcntl64 as well.

* tests/fcntl.c: Move main, [TEST_FLOCK64_EINVAL],
and [TEST_F_OWNER_EX] ...
* tests/fcntl-common.c: ... here.
(test_flock64): New prototype.
* tests/fcntl64.c (main): Remove.

6 years agotests: rename struct_flock.c to fcntl-common.c
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: rename struct_flock.c to fcntl-common.c

It is not limited to struct flock, more fcntl tests are going to land
in this file.

* tests/struct_flock.c: Rename to fcntl-common.c.
* tests/Makefile.am (EXTRA_DIST): Rename struct_flock.c
to fcntl-common.c.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.

6 years agotests: check decoding of new FRA_* netlink attributes
Eugene Syromyatnikov [Wed, 23 May 2018 16:56:32 +0000 (18:56 +0200)]
tests: check decoding of new FRA_* netlink attributes

* configure.ac (AC_CHECK_TYPES): Check for struct fib_rule_port_range
in <linux/fib_rules.h>.
* tests/nlattr_fib_rule_hdr.c: Include <linux/in.h>.
(FRA_PROTOCOL, FRA_IP_PROTO, FRA_SPORT_RANGE, FRA_DPORT_RANGE): New
macro constants.
[!HAVE_STRUCT_FIB_RULE_PORT_RANGE] (struct fib_rule_port_range): New
type.
(main): Check decoding of new FRA_* netlink attributes.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agortnl_rule: decode new FRA_* attributes
Eugene Syromyatnikov [Mon, 16 Apr 2018 00:02:18 +0000 (02:02 +0200)]
rtnl_rule: decode new FRA_* attributes

* nlattr.h (DECL_NLA(ip_proto), DECL_NLA(rt_proto)): New declarations.
* nlattr.c (decode_nla_ip_proto): New function.
* rtnl_route.c (decode_nla_rt_proto): Likewise.
* rtnl_rule.c (decode_rule_port_rang): Likewise.
(fib_rule_hdr_nla_decoders) <[FRA_PROTOCOL]>: New attribute, introduced
by Linux commit v4.17-rc1~148^2~371.
(fib_rule_hdr_nla_decoders) <[FRA_IP_PROTO], [FRA_SPORT_RANGE],
[FRA_DPORT_RANGE]>: New attributes, introduced by Linux commit
v4.17-rc1~148^2~328^2~4.
* xlat/rtnl_rule_attrs.in (FRA_PROTOCOL, FRA_IP_PROTO, FRA_SPORT_RANGE,
FRA_DPORT_RANGE): New constants.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agonlattr: introduce decode_nla_xval helper
Eugene Syromyatnikov [Mon, 7 May 2018 06:40:02 +0000 (08:40 +0200)]
nlattr: introduce decode_nla_xval helper

* nlattr.c (decode_nla_xval): New function.
* nlattr.h: Include "xlat.h".
(struct decode_nla_xlat_opts): New type.
(DECL_NLA(xval)): New declaration.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoMove definitions of xlat_type and xlat_style from defs.h to xlat.h
Dmitry V. Levin [Wed, 30 May 2018 20:50:29 +0000 (20:50 +0000)]
Move definitions of xlat_type and xlat_style from defs.h to xlat.h

* defs.h (enum xlat_type, enum xlat_style, XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_VERBOSITY_MASK, XLAT_STYLE_FORMAT_MASK, XLAT_STYLE_SPEC_BITS,
XLAT_STYLE_MASK): Move ...
* xlat.h: ... here.