rtnl_neightbl: enhance decoding of struct ndt_stats

Add support of kernels that operate with older definition of
struct ndt_stats than the definition used to build strace.

* rtnl_neightbl.c (decode_ndt_stats): Add runtime detection
of struct ndt_stats.ndts_table_fulls field, print the field
when it is available.
This commit is contained in:
Дмитрий Левин 2017-09-01 08:41:08 +00:00
parent bf1a463c79
commit b738f44a52

@ -113,10 +113,17 @@ decode_ndt_stats(struct tcb *const tcp,
{
#ifdef HAVE_STRUCT_NDT_STATS
struct ndt_stats ndtst;
const unsigned int min_size =
offsetofend(struct ndt_stats, ndts_forced_gc_runs);
const unsigned int def_size = sizeof(ndtst);
const unsigned int size =
(len >= def_size) ? def_size :
((len == min_size) ? min_size : 0);
if (len < sizeof(ndtst))
if (!size)
return false;
else if (!umove_or_printaddr(tcp, addr, &ndtst)) {
if (!umoven_or_printaddr(tcp, addr, size, &ndtst)) {
PRINT_FIELD_U("{", ndtst, ndts_allocs);
PRINT_FIELD_U(", ", ndtst, ndts_destroys);
PRINT_FIELD_U(", ", ndtst, ndts_hash_grows);
@ -128,7 +135,8 @@ decode_ndt_stats(struct tcb *const tcp,
PRINT_FIELD_U(", ", ndtst, ndts_periodic_gc_runs);
PRINT_FIELD_U(", ", ndtst, ndts_forced_gc_runs);
#ifdef HAVE_STRUCT_NDT_STATS_NDTS_TABLE_FULLS
PRINT_FIELD_U(", ", ndtst, ndts_table_fulls);
if (len >= def_size)
PRINT_FIELD_U(", ", ndtst, ndts_table_fulls);
#endif
tprints("}");
}