]> granicus.if.org Git - strace/commitdiff
rtnl_neightbl: enhance decoding of struct ndt_stats
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Sep 2017 08:41:08 +0000 (08:41 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Sep 2017 08:41:08 +0000 (08:41 +0000)
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.

rtnl_neightbl.c

index 5db89ceb2c0f09719b2797d6ebd35b99823552a4..9d6cec2ddbdbeb17fda921921e012fb465dfec53 100644 (file)
@@ -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("}");
        }