Browse Source

rtnl_neightbl: always decode struct ndt_config and struct ndt_stats

* rtnl_neightbl.c (struct_ndt_config, struct_ndt_stats): New typedefs.
[HAVE_STRUCT_NDT_CONFIG]: New static_assert to check
that sizeof(struct ndt_config) has the expected value.
[HAVE_STRUCT_NDT_STATS]: New static_assert to check
that sizeof(struct ndt_stats) has the expected value.
(decode_ndt_config) [HAVE_STRUCT_NDT_CONFIG]: Remove guard.
(decode_ndt_config): Change the type of ndtc variable
to struct_ndt_config.
(decode_ndt_stats) [HAVE_STRUCT_NDT_STATS]: Remove guard.
(decode_ndt_stats): Change the type of ndtst variable
to struct_ndt_stats.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
Eugene Syromyatnikov 1 month ago
parent
commit
46ee6345bb
1 changed files with 38 additions and 12 deletions
  1. 38
    12
      rtnl_neightbl.c

+ 38
- 12
rtnl_neightbl.c View File

@@ -21,14 +21,49 @@
21 21
 #include "xlat/rtnl_neightbl_attrs.h"
22 22
 #include "xlat/rtnl_neightbl_parms_attrs.h"
23 23
 
24
+typedef struct {
25
+	uint16_t ndtc_key_len;
26
+	uint16_t ndtc_entry_size;
27
+	uint32_t ndtc_entries;
28
+	uint32_t ndtc_last_flush;
29
+	uint32_t ndtc_last_rand;
30
+	uint32_t ndtc_hash_rnd;
31
+	uint32_t ndtc_hash_mask;
32
+	uint32_t ndtc_hash_chain_gc;
33
+	uint32_t ndtc_proxy_qlen;
34
+} struct_ndt_config;
35
+
36
+typedef struct {
37
+	uint64_t ndts_allocs;
38
+	uint64_t ndts_destroys;
39
+	uint64_t ndts_hash_grows;
40
+	uint64_t ndts_res_failed;
41
+	uint64_t ndts_lookups;
42
+	uint64_t ndts_hits;
43
+	uint64_t ndts_rcv_probes_mcast;
44
+	uint64_t ndts_rcv_probes_ucast;
45
+	uint64_t ndts_periodic_gc_runs;
46
+	uint64_t ndts_forced_gc_runs;
47
+	uint64_t ndts_table_fulls; /**< Added by v4.3-rc1~96^2~202 */
48
+} struct_ndt_stats;
49
+
50
+# ifdef HAVE_STRUCT_NDT_CONFIG
51
+static_assert(sizeof(struct ndt_config) == sizeof(struct_ndt_config),
52
+	      "Unexpected struct ndt_config size, please update the decoder");
53
+# endif
54
+# ifdef HAVE_STRUCT_NDT_STATS
55
+static_assert(sizeof(struct ndt_stats) <= sizeof(struct_ndt_stats),
56
+	      "Unexpected struct ndt_stats size, please update the decoder");
57
+# endif
58
+
59
+
24 60
 static bool
25 61
 decode_ndt_config(struct tcb *const tcp,
26 62
 		  const kernel_ulong_t addr,
27 63
 		  const unsigned int len,
28 64
 		  const void *const opaque_data)
29 65
 {
30
-#ifdef HAVE_STRUCT_NDT_CONFIG
31
-	struct ndt_config ndtc;
66
+	struct_ndt_config ndtc;
32 67
 
33 68
 	if (len < sizeof(ndtc))
34 69
 		return false;
@@ -46,9 +81,6 @@ decode_ndt_config(struct tcb *const tcp,
46 81
 	}
47 82
 
48 83
 	return true;
49
-#else
50
-	return false;
51
-#endif
52 84
 }
53 85
 
54 86
 static const nla_decoder_t ndt_parms_nla_decoders[] = {
@@ -91,8 +123,7 @@ decode_ndt_stats(struct tcb *const tcp,
91 123
 		 const unsigned int len,
92 124
 		 const void *const opaque_data)
93 125
 {
94
-#ifdef HAVE_STRUCT_NDT_STATS
95
-	struct ndt_stats ndtst;
126
+	struct_ndt_stats ndtst;
96 127
 	const unsigned int min_size =
97 128
 		offsetofend(struct ndt_stats, ndts_forced_gc_runs);
98 129
 	const unsigned int def_size = sizeof(ndtst);
@@ -114,17 +145,12 @@ decode_ndt_stats(struct tcb *const tcp,
114 145
 		PRINT_FIELD_U(", ", ndtst, ndts_rcv_probes_ucast);
115 146
 		PRINT_FIELD_U(", ", ndtst, ndts_periodic_gc_runs);
116 147
 		PRINT_FIELD_U(", ", ndtst, ndts_forced_gc_runs);
117
-# ifdef HAVE_STRUCT_NDT_STATS_NDTS_TABLE_FULLS
118 148
 		if (len >= def_size)
119 149
 			PRINT_FIELD_U(", ", ndtst, ndts_table_fulls);
120
-# endif
121 150
 		tprints("}");
122 151
 	}
123 152
 
124 153
 	return true;
125
-#else
126
-	return false;
127
-#endif
128 154
 }
129 155
 
130 156
 static const nla_decoder_t ndtmsg_nla_decoders[] = {

Loading…
Cancel
Save