* configure.ac (AC_CHECK_TYPES): Check for ndt_config
and ndt_stats structures in <linux/neighbour.h>.
(AC_CHECK_MEMBERS): Check for ndts_table_fulls field in struct ndt_stats.
* rtnl_neightbl.c: Include "xlat/rtnl_neightbl_parms_attrs.h".
(decode_ndt_config, decode_ndta_parms, decode_ndta_parms): New functions.
(ndt_parms_nla_decoders, ndtmsg_nla_decoders): New arrays.
(decode_ndtmsg): Use ndtmsg_nla_decoders.
* xlat/rtnl_neightbl_parms_attrs.in: New file.
---
 configure.ac                      |   6 ++
 rtnl_neightbl.c                   | 115 +++++++++++++++++++++++++++++++++++++-
 xlat/rtnl_neightbl_parms_attrs.in |  19 +++++++
 3 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 xlat/rtnl_neightbl_parms_attrs.in

diff --git a/configure.ac b/configure.ac
index bcf5129..28e9a34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -454,6 +454,12 @@ AC_CHECK_TYPES(m4_normalize([
        struct rtvia
 ]),,, [#include <linux/rtnetlink.h>])
 
+AC_CHECK_MEMBERS([struct ndt_stats.ndts_table_fulls],,, [#include 
<linux/neighbour.h>])
+AC_CHECK_TYPES(m4_normalize([
+       struct ndt_config,
+       struct ndt_stats
+]),,, [#include <linux/neighbour.h>])
+
 AC_CHECK_TYPES([struct rtnl_link_stats64],,, [#include <linux/if_link.h>])
 AC_CHECK_MEMBERS(m4_normalize([
        struct rtnl_link_stats.rx_nohandler,
diff --git a/rtnl_neightbl.c b/rtnl_neightbl.c
index 41f8c92..bf4d98e 100644
--- a/rtnl_neightbl.c
+++ b/rtnl_neightbl.c
@@ -39,6 +39,117 @@
 #endif
 
 #include "xlat/rtnl_neightbl_attrs.h"
+#include "xlat/rtnl_neightbl_parms_attrs.h"
+
+static bool
+decode_ndt_config(struct tcb *const tcp,
+                 const kernel_ulong_t addr,
+                 const unsigned int len,
+                 const void *const opaque_data)
+{
+#ifdef HAVE_STRUCT_NDT_CONFIG
+       struct ndt_config ndtc;
+
+       if (len < sizeof(ndtc))
+               return false;
+       else if (!umove_or_printaddr(tcp, addr, &ndtc)) {
+               PRINT_FIELD_U("{", ndtc, ndtc_key_len);
+               PRINT_FIELD_U(", ", ndtc, ndtc_entry_size);
+               PRINT_FIELD_U(", ", ndtc, ndtc_entries);
+               PRINT_FIELD_U(", ", ndtc, ndtc_last_flush);
+               PRINT_FIELD_U(", ", ndtc, ndtc_last_rand);
+               PRINT_FIELD_U(", ", ndtc, ndtc_hash_rnd);
+               PRINT_FIELD_0X(", ", ndtc, ndtc_hash_mask);
+               PRINT_FIELD_U(", ", ndtc, ndtc_hash_chain_gc);
+               PRINT_FIELD_U(", ", ndtc, ndtc_proxy_qlen);
+               tprints("}");
+       }
+
+       return true;
+#else
+       return false;
+#endif
+}
+
+static const nla_decoder_t ndt_parms_nla_decoders[] = {
+       [NDTPA_IFINDEX]                 = decode_nla_ifindex,
+       [NDTPA_REFCNT]                  = decode_nla_u32,
+       [NDTPA_REACHABLE_TIME]          = decode_nla_u64,
+       [NDTPA_BASE_REACHABLE_TIME]     = decode_nla_u64,
+       [NDTPA_RETRANS_TIME]            = decode_nla_u64,
+       [NDTPA_GC_STALETIME]            = decode_nla_u64,
+       [NDTPA_DELAY_PROBE_TIME]        = decode_nla_u64,
+       [NDTPA_QUEUE_LEN]               = decode_nla_u32,
+       [NDTPA_APP_PROBES]              = decode_nla_u32,
+       [NDTPA_UCAST_PROBES]            = decode_nla_u32,
+       [NDTPA_MCAST_PROBES]            = decode_nla_u32,
+       [NDTPA_ANYCAST_DELAY]           = decode_nla_u64,
+       [NDTPA_PROXY_DELAY]             = decode_nla_u64,
+       [NDTPA_PROXY_QLEN]              = decode_nla_u32,
+       [NDTPA_LOCKTIME]                = decode_nla_u64,
+       [NDTPA_QUEUE_LENBYTES]          = decode_nla_u32,
+       [NDTPA_MCAST_REPROBES]          = decode_nla_u32,
+       [NDTPA_PAD]                     = NULL
+};
+
+static bool
+decode_ndta_parms(struct tcb *const tcp,
+                 const kernel_ulong_t addr,
+                 const unsigned int len,
+                 const void *const opaque_data)
+{
+       decode_nlattr(tcp, addr, len, rtnl_neightbl_parms_attrs, "NDTPA_???",
+                     ndt_parms_nla_decoders,
+                     ARRAY_SIZE(ndt_parms_nla_decoders), opaque_data);
+
+       return true;
+}
+
+static bool
+decode_ndt_stats(struct tcb *const tcp,
+                const kernel_ulong_t addr,
+                const unsigned int len,
+                const void *const opaque_data)
+{
+#ifdef HAVE_STRUCT_NDT_STATS
+       struct ndt_stats ndtst;
+
+       if (len < sizeof(ndtst))
+               return false;
+       else if (!umove_or_printaddr(tcp, addr, &ndtst)) {
+               PRINT_FIELD_U("{", ndtst, ndts_allocs);
+               PRINT_FIELD_U(", ", ndtst, ndts_destroys);
+               PRINT_FIELD_U(", ", ndtst, ndts_hash_grows);
+               PRINT_FIELD_U(", ", ndtst, ndts_res_failed);
+               PRINT_FIELD_U(", ", ndtst, ndts_lookups);
+               PRINT_FIELD_U(", ", ndtst, ndts_hits);
+               PRINT_FIELD_U(", ", ndtst, ndts_rcv_probes_mcast);
+               PRINT_FIELD_U(", ", ndtst, ndts_rcv_probes_ucast);
+               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);
+#endif
+               tprints("}");
+       }
+
+       return true;
+#else
+       return false;
+#endif /* HAVE_STRUCT_NDT_STATS */
+}
+
+static const nla_decoder_t ndtmsg_nla_decoders[] = {
+       [NDTA_NAME]             = decode_nla_str,
+       [NDTA_THRESH1]          = decode_nla_u32,
+       [NDTA_THRESH2]          = decode_nla_u32,
+       [NDTA_THRESH3]          = decode_nla_u32,
+       [NDTA_CONFIG]           = decode_ndt_config,
+       [NDTA_PARMS]            = decode_ndta_parms,
+       [NDTA_STATS]            = decode_ndt_stats,
+       [NDTA_GC_INTERVAL]      = decode_nla_u64,
+       [NDTA_PAD]              = NULL,
+};
 
 DECL_NETLINK_ROUTE_DECODER(decode_ndtmsg)
 {
@@ -51,6 +162,8 @@ DECL_NETLINK_ROUTE_DECODER(decode_ndtmsg)
        if (len > offset) {
                tprints(", ");
                decode_nlattr(tcp, addr + offset, len - offset,
-                             rtnl_neightbl_attrs, "NDTA_???", NULL, 0, NULL);
+                             rtnl_neightbl_attrs, "NDTA_???",
+                             ndtmsg_nla_decoders,
+                             ARRAY_SIZE(ndtmsg_nla_decoders), NULL);
        }
 }
diff --git a/xlat/rtnl_neightbl_parms_attrs.in 
b/xlat/rtnl_neightbl_parms_attrs.in
new file mode 100644
index 0000000..9fcbff0
--- /dev/null
+++ b/xlat/rtnl_neightbl_parms_attrs.in
@@ -0,0 +1,19 @@
+NDTPA_UNSPEC                   0
+NDTPA_IFINDEX                  1
+NDTPA_REFCNT                   2
+NDTPA_REACHABLE_TIME           3
+NDTPA_BASE_REACHABLE_TIME      4
+NDTPA_RETRANS_TIME             5
+NDTPA_GC_STALETIME             6
+NDTPA_DELAY_PROBE_TIME         7
+NDTPA_QUEUE_LEN                        8
+NDTPA_APP_PROBES               9
+NDTPA_UCAST_PROBES             10
+NDTPA_MCAST_PROBES             11
+NDTPA_ANYCAST_DELAY            12
+NDTPA_PROXY_DELAY              13
+NDTPA_PROXY_QLEN               14
+NDTPA_LOCKTIME                 15
+NDTPA_QUEUE_LENBYTES           16
+NDTPA_MCAST_REPROBES           17
+NDTPA_PAD                      18
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to