6864 Commits

Author SHA1 Message Date
Nikolay Marchuk
f1bba432e1 Implement inject and fault actions
* basic_actions.c (not_injected, apply_inject, parse_inject_common,
parse_inject, apply_fault, parse_fault): New functions.
* defs.h (struct inject_opts): Add init flag.
(qual_flags): Remove declaration.
* filter_action.c (action_types): Add inject and fault action types.
(set_filter_action_priv_data): New function.
* filter_qualify.c (inject_set): Remove variable.
(parse_inject_expression): Remove function.
(parse_inject_common_args): Add function for inject/fault arguments parsing.
(qualify_inject_common): Use parse_inject_common_args instead of
parse_inject_expression, use new filtering API.
(qualify_fault, qualify_inject): Remove "argument" from description
argument of qualify_inject_common.
(qual_flags): Remove function.
* filter.h (parse_inject_common_args, not_injected,
set_filter_action_priv_data): New declarations.
(DECL_FILTER_ACTION): Declare inject and fault actions.
(DECL_FILTER_ACTION_PARSER): Declare inject and fault action parsers.
* strace.c (trace_syscall): Call filter_syscall only when tcp->qual_flg
is empty.
* syscall.c (decode_socket_subcall): Remove qual_flags from decoder.
(decode_ipc_subcall): Likewise.
(decode_mips_subcall): Likewise.
(get_scno): Likewise.
(inject_vec, tamper_with_syscall_entering): Remove inject_vec support code.

[ldv: fix segfault in parse_inject_common_args]
[ldv: simplify *_qualify_mode]
2018-06-13 15:05:09 +00:00
Nikolay Marchuk
f939d6d2b1 Introduce new filtering architecture
This change introduces new filtering architecture primitives: filter,
filter_action and bool_expression. Filtering is now done after decoding of
syscall and tcp->qual_flg stores filtering results.

* basic_actions.c: New file.
* filter_action.c: Likewise.
* filter_expression.c: Likewise.
* filter.c: Likewise.
* basic_filters.c (parse_syscall_filter, run_syscall_filter,
free_syscall_filter): New functions.
* defs.h (filter_syscall, filtering_parsing_finish): Add new declarations.
* filter.h: Add new declarations.
* filter_qualify.c (abbrev_set, raw_set, trace_set, verbose_set):
Remove set variables.
(qualify_trace, qualify_abbrev, qualify_verbose, qualify_raw):
Use new filtering API.
(qual_flags): Remove QUAL_* flags for trace, abbrev, verbose, raw.
* strace.c (init): Call filtering_parse_finish after command line parsing.
(trace_syscall): Add filtering after syscall decoding.
* Makefile.am (strace_SOURCES): Add new files.

[ldv: simplify *_qualify_mode]
[ldv: eliminate parse_null]
[ldv: introduce qualify_filter]
[ldv: use loop initial declarations]
2018-06-13 15:05:09 +00:00
7e0c7e0e88 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"
2018-06-13 15:05:09 +00:00
Eugene Syromyatnikov
525f70debe 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"
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
d2aa5046e9 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>
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
418625eaaa 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.
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
b178553f22 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.
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
49d030ab8a 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_.
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
193e5f6aff 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.
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
deeb2d42ae 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"
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
a781b2659f 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.
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
b870441f58 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"
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
9e85a344d7 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"
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
58c47fe58a 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"
2018-06-11 14:02:06 +00:00
Eugene Syromyatnikov
36b44f9380 Update NEWS
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-06-07 18:02:01 +00:00
Eugene Syromyatnikov
b6fec72d5e xlat: describe IPV4_DEVCONF_* weirdness
* xlat/inet_devconf_indices.in: Add a comment about fallback definitions.
2018-06-07 18:02:01 +00:00
e3e4a524a1 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.
2018-06-07 14:01:24 +00:00
762ee767f0 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
4f652c1ec4 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
6229d93cb2 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>
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
ce3bddf6c4 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
e62b6a5e92 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
4eab3a43fd 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".
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
1e6d5a84b8 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
c95426f6ae 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
7503a0f9e4 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
97eb4367e4 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
c0827b1ae9 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>
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
6d98338f09 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
f29c4f1319 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
fd0cd658cc nlattr: add ethernet protocol decoder
* nlattr.h (DECL_NLA(ether_proto)): New declaration.
* nlattr.c (process_host_order, decode_nla_ether_proto): New functions.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
79a02d029c 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.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
bdc6ca9e56 nlattr: introduce decode_nla_flags
Similar to decode_nla_xval.

* nlattr.c (decode_nla_flags): New function.
* nlattr.h: (DECL_NLA(flags)): New declaration.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
dbc5d26b29 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.
2018-06-06 15:10:37 +00:00
88d6b7287c 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.
2018-06-06 10:10:43 +00:00
Eugene Syromyatnikov
f7c6046026 tests: check decoding of IFLA_EVENT netlink attribute
* tests/nlattr_ifinfomsg.c (main): Add a check for IFLA_EVENT attribute
decoding.
2018-06-06 10:10:43 +00:00
41bfa3bf5f 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.
2018-06-05 11:04:09 +00:00
Eugene Syromyatnikov
3a7d7d8f8c 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>
2018-06-05 11:04:09 +00:00
Eugene Syromyatnikov
9fd42fc53a 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.
2018-06-05 11:04:09 +00:00
Eugene Syromyatnikov
27850e48f3 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.
2018-06-05 11:04:09 +00:00
Eugene Syromyatnikov
e390ab2427 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.
2018-06-04 16:18:14 +00:00
Eugene Syromyatnikov
7d0396345d 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.
2018-06-04 16:18:14 +00:00
Eugene Syromyatnikov
fd3aa07209 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.
2018-06-04 16:18:14 +00:00
Eugene Syromyatnikov
56f3d28453 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.
2018-06-04 16:18:14 +00:00
Eugene Syromyatnikov
93ef3d32ab 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>
2018-06-04 01:11:05 +00:00
ebdc322480 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.
2018-06-04 01:11:05 +00:00
Eugene Syromyatnikov
05813058ed 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>
2018-06-02 16:32:10 +00:00
Eugene Syromyatnikov
ec27280cf3 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>
2018-06-02 16:32:10 +00:00
Eugene Syromyatnikov
712fd66dfb 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>
2018-06-02 16:32:10 +00:00
Eugene Syromyatnikov
bcac74438d 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>
2018-06-02 16:32:10 +00:00