summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2017-09-01 08:41:08 +0000
committerDmitry V. Levin <ldv@altlinux.org>2017-09-01 08:41:08 +0000
commitb738f44a524772498bb08093eb109d38b6510355 (patch)
treeb06a4bd543f2fbcd1e8db5bffe14369621666ebe
parentbf1a463c7924fb0ec1715e026ca51b63970a04a8 (diff)
downloadstrace-b738f44a524772498bb08093eb109d38b6510355.tar.gz
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.
-rw-r--r--rtnl_neightbl.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/rtnl_neightbl.c b/rtnl_neightbl.c
index 5db89ceb2..9d6cec2dd 100644
--- a/rtnl_neightbl.c
+++ b/rtnl_neightbl.c
@@ -113,10 +113,17 @@ decode_ndt_stats(struct tcb *const tcp,
{
#ifdef HAVE_STRUCT_NDT_STATS
struct ndt_stats ndtst;
-
- if (len < sizeof(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 (!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("}");
}