Commit Graph

12 Commits

Author SHA1 Message Date
300d9f1fee netlink: print descriptor attributes using printfd
* nlattr.h (DECL_NLA(fd)): New prototype.
* nlattr.c (decode_nla_fd): New function.
* rtnl_link.c (ifla_xdp_nla_decoders) <IFLA_XDP_FD>: Use it.
(ifinfomsg_nla_decoders) <IFLA_NET_NS_FD>: Likewise.
* rtnl_nsid.c (rtgenmsg_nla_decoders) <NETNSA_FD>: Likewise.
* NEWS: Mention this.
2017-11-15 15:30:49 +00:00
JingPiao Chen
19abd528fb rtnl_neigh: decode ndmsg netlink attributes
* nlattr.c: Include <netinet/in.h> and <arpa/inet.h>.
(decode_nla_be16): New function.
* nlattr.h (decode_nla_be16): New prototype.
* rtnl_neigh.c (decode_neigh_addr,
decode_nda_cacheinfo): New functions.
(ndmsg_nla_decoders): New array.
(decode_ndmsg): Use it.
2017-08-29 15:23:36 +08:00
JingPiao Chen
b9a437c147 rtnl_rule: decode fib_rule_hdr netlink attributes
* configure.ac (AC_CHECK_FUNCS): Add be64toh.
(AC_CHECK_TYPES): Check for struct fib_rule_uid_range
in <linux/fib_rules.h>.
* nlattr.c: Include <endian.h>.
(decode_nla_be64): New function.
* nlattr.h (decode_nla_be64): New prototype.
* rtnl_rule.c (decode_rule_addr,
decode_fib_rule_uid_range): New functions.
(fib_rule_hdr_nla_decoders): New array.
(decode_fib_rule_hdr): Use it.
2017-08-29 15:13:12 +08:00
JingPiao Chen
e8a856f4bd rtnl_route: decode rtmsg netlink attributes
* configure.ac (AC_CHECK_TYPES): Check for
rta_mfc_stats and rtvia structures in <linux/rtnetlink.h>.
* nlattr.c (decode_nla_ifindex): New function.
* nlattr.h (decode_nla_ifindex): New prototype.
* rtnl_route.c (decode_route_addr, decode_rta_metrics,
decode_rta_multipath, decode_rta_cacheinfo,
decode_rta_mfc_stats, decode_rtvia,
decode_rta_encap_type): New functions.
(rta_metrics_nla_decoders, rtmsg_nla_decoders): New arrays.
(decode_rtmsg): Use rtmsg_nla_decoders.
* xlat/lwtunnel_encap_types.in: New file.
* xlat/route_nexthop_flags.in: Likewise.
* xlat/rtnl_rta_metrics_attrs.in: Likewise.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-26 16:45:18 +00:00
239418b7f8 nlattr: fix printing of unrecognized attribute data
Do not print more than "nlattr.nla_len - NLA_HDRLEN" bytes
of unrecognized attribute data.

* nlattr.c (decode_nlattr_with_data): Specify "nla_len - NLA_HDRLEN"
instead of "len - NLA_HDRLEN" as the size of unrecognized attribute
data.
* tests/nlattr.c (test_nlattr): Check it.
2017-08-16 02:24:29 +00:00
bf24770d91 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.
2017-07-19 10:07:34 +00:00
c56a3c361c Adjust prototypes of netlink parsing functions
Change the type of "len" argument that is based
on struct nlmsghdr.nlmsg_len from kernel_ulong_t to unsigned int.

* defs.h (netlink_decoder_t, DECL_NETLINK): Change "len" argument type
from kernel_ulong_t to unsigned int.
* netlink.c (decode_nlmsgerr_attr_cookie, decode_nlmsgerr,
decode_payload): Likewise.
* netlink_selinux.c (decode_netlink_selinux): Likewise.
* netlink_sock_diag.c (decode_family, decode_unix_diag_req,
decode_meminfo, decode_unix_diag_vfs, decode_unix_diag_inode,
decode_unix_diag_rqlen, decode_unix_diag_msg, decode_netlink_diag_req,
print_group, decode_netlink_diag_ring, decode_netlink_diag_flags,
decode_netlink_diag_msg, decode_packet_diag_req,
decode_packet_diag_info, decode_packet_diag_mclist,
decode_packet_diag_ring, decode_packet_diag_filter,
decode_packet_diag_msg, decode_inet_addr, decode_inet_diag_hostcond,
decode_inet_diag_markcond, decode_bytecode_data, decode_inet_diag_bc_op,
decode_inet_diag_req_compat, decode_inet_diag_req_v2,
decode_inet_diag_req, decode_inet_diag_meminfo, decode_tcpvegas_info,
decode_tcp_dctcp_info, decode_tcp_bbr_info, decode_inet_diag_msg,
decode_smc_diag_req, decode_smc_diag_conninfo, decode_smc_diag_lgrinfo,
decode_smc_diag_msg, netlink_diag_decoder_t, decode_netlink_sock_diag):
Likewise.
* nlattr.c (fetch_nlattr, decode_nlattr_with_data, decode_nlattr,
decode_nla_str, decode_nla_strn, DECODE_NLA_INTEGER): Likewise.
* nlattr.h (nla_decoder_t, DECL_NLA, decode_nlattr): Likewise.
2017-07-19 10:07:34 +00:00
JingPiao Chen
d331383d7d netlink: print unrecognized nlattr in hex
* nlattr.c (fetch_nlattr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/nlattr.c (test_nlattr): Update expected output.
2017-07-07 16:43:41 +00:00
JingPiao Chen
73698eb8f1 netlink: print unrecognized attribute data in hex
* nlattr.c (decode_nlattr_with_data): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/tests.h (print_quoted_hex): New prototype.
* tests/print_quoted_string.c (print_quoted_hex): New function.
* tests/test_nlattr.h (TEST_NLATTR_OBJECT, TEST_NLATTR_ARRAY): Use it
for updated expected output.  Change the type of "plen" variable
to unsigned int.
* tests/nlattr.c (test_nlattr): Update expected output.
2017-07-07 16:43:41 +00:00
91b87e65ff nlattr: add const qualifiers to auto variables and function arguments
This change does not affect the code generated by the compiler,
the purpose of these "const" qualifiers is to highlight the intent.

* nlattr.c (decode_nlattr_with_data, decode_nla_str, decode_nla_strn,
decode_nla_##name): Add const qualifier to tcp, addr, and len arguments.
2017-06-30 21:38:49 +00:00
JingPiao Chen
745ead6451 netlink: introduce nla_decoder_t to parse netlink attributes data
* nlattr.h (nla_decoder_t): New typedef.
(DECL_NLA): New macro.
(decode_nlattr): Add decoders, size and opaque_data argument.
* nlattr.c: (decode_nlattr_with_data): Likewise.
(decode_nla_*): New functions.
* netlink_sock_diag.c (decode_inet_diag_req_compat)
(decode_inet_diag_req_v2, decode_inet_diag_msg)
(decode_netlink_diag_msg, (decode_packet_diag_msg)
(decode_smc_diag_msg, decode_unix_diag_msg): Add decoders,
size and opaque_data arguments. All callers updated.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-30 21:38:49 +00:00
JingPiao Chen
d851f5695d netlink: introduce a basic netlink attributes parser
* linux/unix_diag.h (UNIX_DIAG_*): New enum.
* nlattr.c: New file.
* nlattr.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* netlink_sock_diag.c: Include "nlattr.h" and "xlat/unix_diag_attrs.h".
(decode_unix_diag_msg): Use decode_nlattr.
* xlat/unix_diag_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-06-21 16:36:33 +00:00