Blame SOURCES/0066-rtnl_neightbl-always-decode-struct-ndt_config-and-st.patch

86f512
From 76f5cf99f83f38ce23be29ea470d4da3d525c859 Mon Sep 17 00:00:00 2001
86f512
From: Eugene Syromyatnikov <evgsyr@gmail.com>
86f512
Date: Thu, 17 Oct 2019 15:50:09 +0200
86f512
Subject: [PATCH 66/76] rtnl_neightbl: always decode struct ndt_config and
86f512
 struct ndt_stats
86f512
86f512
* rtnl_neightbl.c (struct_ndt_config, struct_ndt_stats): New typedefs.
86f512
[HAVE_STRUCT_NDT_CONFIG]: New static_assert to check
86f512
that sizeof(struct ndt_config) has the expected value.
86f512
[HAVE_STRUCT_NDT_STATS]: New static_assert to check
86f512
that sizeof(struct ndt_stats) has the expected value.
86f512
(decode_ndt_config) [HAVE_STRUCT_NDT_CONFIG]: Remove guard.
86f512
(decode_ndt_config): Change the type of ndtc variable
86f512
to struct_ndt_config.
86f512
(decode_ndt_stats) [HAVE_STRUCT_NDT_STATS]: Remove guard.
86f512
(decode_ndt_stats): Change the type of ndtst variable
86f512
to struct_ndt_stats.
86f512
86f512
References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
86f512
---
86f512
 rtnl_neightbl.c | 50 ++++++++++++++++++++++++++++++++++++++------------
86f512
 1 file changed, 38 insertions(+), 12 deletions(-)
86f512
86f512
diff --git a/rtnl_neightbl.c b/rtnl_neightbl.c
86f512
index f9f5756..0f5d6eb 100644
86f512
--- a/rtnl_neightbl.c
86f512
+++ b/rtnl_neightbl.c
86f512
@@ -21,14 +21,49 @@
86f512
 #include "xlat/rtnl_neightbl_attrs.h"
86f512
 #include "xlat/rtnl_neightbl_parms_attrs.h"
86f512
 
86f512
+typedef struct {
86f512
+	uint16_t ndtc_key_len;
86f512
+	uint16_t ndtc_entry_size;
86f512
+	uint32_t ndtc_entries;
86f512
+	uint32_t ndtc_last_flush;
86f512
+	uint32_t ndtc_last_rand;
86f512
+	uint32_t ndtc_hash_rnd;
86f512
+	uint32_t ndtc_hash_mask;
86f512
+	uint32_t ndtc_hash_chain_gc;
86f512
+	uint32_t ndtc_proxy_qlen;
86f512
+} struct_ndt_config;
86f512
+
86f512
+typedef struct {
86f512
+	uint64_t ndts_allocs;
86f512
+	uint64_t ndts_destroys;
86f512
+	uint64_t ndts_hash_grows;
86f512
+	uint64_t ndts_res_failed;
86f512
+	uint64_t ndts_lookups;
86f512
+	uint64_t ndts_hits;
86f512
+	uint64_t ndts_rcv_probes_mcast;
86f512
+	uint64_t ndts_rcv_probes_ucast;
86f512
+	uint64_t ndts_periodic_gc_runs;
86f512
+	uint64_t ndts_forced_gc_runs;
86f512
+	uint64_t ndts_table_fulls; /**< Added by v4.3-rc1~96^2~202 */
86f512
+} struct_ndt_stats;
86f512
+
86f512
+# ifdef HAVE_STRUCT_NDT_CONFIG
86f512
+static_assert(sizeof(struct ndt_config) == sizeof(struct_ndt_config),
86f512
+	      "Unexpected struct ndt_config size, please update the decoder");
86f512
+# endif
86f512
+# ifdef HAVE_STRUCT_NDT_STATS
86f512
+static_assert(sizeof(struct ndt_stats) <= sizeof(struct_ndt_stats),
86f512
+	      "Unexpected struct ndt_stats size, please update the decoder");
86f512
+# endif
86f512
+
86f512
+
86f512
 static bool
86f512
 decode_ndt_config(struct tcb *const tcp,
86f512
 		  const kernel_ulong_t addr,
86f512
 		  const unsigned int len,
86f512
 		  const void *const opaque_data)
86f512
 {
86f512
-#ifdef HAVE_STRUCT_NDT_CONFIG
86f512
-	struct ndt_config ndtc;
86f512
+	struct_ndt_config ndtc;
86f512
 
86f512
 	if (len < sizeof(ndtc))
86f512
 		return false;
86f512
@@ -46,9 +81,6 @@ decode_ndt_config(struct tcb *const tcp,
86f512
 	}
86f512
 
86f512
 	return true;
86f512
-#else
86f512
-	return false;
86f512
-#endif
86f512
 }
86f512
 
86f512
 static const nla_decoder_t ndt_parms_nla_decoders[] = {
86f512
@@ -91,8 +123,7 @@ decode_ndt_stats(struct tcb *const tcp,
86f512
 		 const unsigned int len,
86f512
 		 const void *const opaque_data)
86f512
 {
86f512
-#ifdef HAVE_STRUCT_NDT_STATS
86f512
-	struct ndt_stats ndtst;
86f512
+	struct_ndt_stats ndtst;
86f512
 	const unsigned int min_size =
86f512
 		offsetofend(struct ndt_stats, ndts_forced_gc_runs);
86f512
 	const unsigned int def_size = sizeof(ndtst);
86f512
@@ -114,17 +145,12 @@ decode_ndt_stats(struct tcb *const tcp,
86f512
 		PRINT_FIELD_U(", ", ndtst, ndts_rcv_probes_ucast);
86f512
 		PRINT_FIELD_U(", ", ndtst, ndts_periodic_gc_runs);
86f512
 		PRINT_FIELD_U(", ", ndtst, ndts_forced_gc_runs);
86f512
-# ifdef HAVE_STRUCT_NDT_STATS_NDTS_TABLE_FULLS
86f512
 		if (len >= def_size)
86f512
 			PRINT_FIELD_U(", ", ndtst, ndts_table_fulls);
86f512
-# endif
86f512
 		tprints("}");
86f512
 	}
86f512
 
86f512
 	return true;
86f512
-#else
86f512
-	return false;
86f512
-#endif
86f512
 }
86f512
 
86f512
 static const nla_decoder_t ndtmsg_nla_decoders[] = {
86f512
-- 
86f512
2.1.4
86f512