blob: 761c73f0fb7d8610c5be9721d167466ce40a0282 [file] [log] [blame]
Ole Troan2fee1672018-08-23 13:00:53 +02001/*
2 *------------------------------------------------------------------
3 * stat_client.c - Library for access to VPP statistics segment
4 *
5 * Copyright (c) 2018 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
18 */
19
Ole Troan58492a82018-09-04 13:19:12 +020020#include <stdio.h>
21#include <errno.h>
22#include <sys/types.h>
23#include <sys/socket.h>
24#include <sys/un.h>
25#include <stdbool.h>
26#include <sys/stat.h>
Ole Troan2fee1672018-08-23 13:00:53 +020027#include <regex.h>
Ole Troan58492a82018-09-04 13:19:12 +020028#include <assert.h>
29#include <vppinfra/vec.h>
30#include <vppinfra/lock.h>
Ole Troan2fee1672018-08-23 13:00:53 +020031#include "stat_client.h"
Ole Troan58492a82018-09-04 13:19:12 +020032#include <stdatomic.h>
Ole Troan2152e1c2018-11-23 23:07:13 +010033#include <vpp/stats/stat_segment.h>
Ole Troan2fee1672018-08-23 13:00:53 +020034
Ole Troan2152e1c2018-11-23 23:07:13 +010035struct stat_client_main_t
36{
37 uint64_t current_epoch;
38 stat_segment_shared_header_t *shared_header;
39 stat_segment_directory_entry_t *directory_vector;
40 ssize_t memory_size;
41};
Ole Troan2fee1672018-08-23 13:00:53 +020042
43stat_client_main_t stat_client_main;
44
Paul Vinciguerra56421092018-11-21 16:34:09 -080045stat_client_main_t *
46stat_client_get (void)
47{
48 stat_client_main_t *sm;
49 sm = (stat_client_main_t *) malloc (sizeof (stat_client_main_t));
50 clib_memset (sm, 0, sizeof (stat_client_main_t));
51 return sm;
52}
53
54void
55stat_client_free (stat_client_main_t * sm)
56{
57 free (sm);
58}
59
Ole Troan58492a82018-09-04 13:19:12 +020060static int
61recv_fd (int sock)
62{
63 struct msghdr msg = { 0 };
64 struct cmsghdr *cmsg;
65 int fd = -1;
66 char iobuf[1];
67 struct iovec io = {.iov_base = iobuf,.iov_len = sizeof (iobuf) };
68 union
69 {
70 char buf[CMSG_SPACE (sizeof (fd))];
71 struct cmsghdr align;
72 } u;
73 msg.msg_iov = &io;
74 msg.msg_iovlen = 1;
75 msg.msg_control = u.buf;
76 msg.msg_controllen = sizeof (u.buf);
77
78 ssize_t size;
79 if ((size = recvmsg (sock, &msg, 0)) < 0)
80 {
81 perror ("recvmsg failed");
82 return -1;
83 }
84 cmsg = CMSG_FIRSTHDR (&msg);
85 if (cmsg && cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
86 {
87 memmove (&fd, CMSG_DATA (cmsg), sizeof (fd));
88 }
89 return fd;
90}
91
92static stat_segment_directory_entry_t *
Paul Vinciguerra56421092018-11-21 16:34:09 -080093get_stat_vector_r (stat_client_main_t * sm)
Ole Troan58492a82018-09-04 13:19:12 +020094{
Ole Troan58492a82018-09-04 13:19:12 +020095 ASSERT (sm->shared_header);
96 return stat_segment_pointer (sm->shared_header,
97 sm->shared_header->directory_offset);
98}
99
Paul Vinciguerra56421092018-11-21 16:34:09 -0800100static stat_segment_directory_entry_t *
101get_stat_vector (void)
Ole Troan2fee1672018-08-23 13:00:53 +0200102{
103 stat_client_main_t *sm = &stat_client_main;
Paul Vinciguerra56421092018-11-21 16:34:09 -0800104 return get_stat_vector_r (sm);
105}
106
107int
Neale Ranns318d7942018-12-03 01:53:32 -0800108stat_segment_connect_r (const char *socket_name, stat_client_main_t * sm)
Paul Vinciguerra56421092018-11-21 16:34:09 -0800109{
Ole Troan58492a82018-09-04 13:19:12 +0200110 int mfd = -1;
111 int sock;
Ole Troan2fee1672018-08-23 13:00:53 +0200112
Dave Barachb7b92992018-10-17 10:38:51 -0400113 clib_memset (sm, 0, sizeof (*sm));
Ole Troan58492a82018-09-04 13:19:12 +0200114 if ((sock = socket (AF_UNIX, SOCK_SEQPACKET, 0)) < 0)
Ole Troan2fee1672018-08-23 13:00:53 +0200115 {
Paul Vinciguerra56421092018-11-21 16:34:09 -0800116 perror ("Stat client couldn't open socket");
Ole Troan2fee1672018-08-23 13:00:53 +0200117 return -1;
118 }
119
Ole Troan58492a82018-09-04 13:19:12 +0200120 struct sockaddr_un un = { 0 };
121 un.sun_family = AF_UNIX;
122 strncpy ((char *) un.sun_path, socket_name, sizeof (un.sun_path) - 1);
123 if (connect (sock, (struct sockaddr *) &un, sizeof (struct sockaddr_un)) <
124 0)
125 {
Dave Barach819d5fd2018-10-02 16:33:56 -0400126 close (sock);
Paul Vinciguerra356824f2019-01-05 19:37:27 -0800127 return -2;
Ole Troan58492a82018-09-04 13:19:12 +0200128 }
Ole Troan2fee1672018-08-23 13:00:53 +0200129
Ole Troan58492a82018-09-04 13:19:12 +0200130 if ((mfd = recv_fd (sock)) < 0)
131 {
Dave Barach819d5fd2018-10-02 16:33:56 -0400132 close (sock);
Ole Troan58492a82018-09-04 13:19:12 +0200133 fprintf (stderr, "Receiving file descriptor failed\n");
Paul Vinciguerra356824f2019-01-05 19:37:27 -0800134 return -3;
Ole Troan58492a82018-09-04 13:19:12 +0200135 }
136 close (sock);
Ole Troan2fee1672018-08-23 13:00:53 +0200137
Ole Troan58492a82018-09-04 13:19:12 +0200138 /* mmap shared memory segment. */
139 void *memaddr;
140 struct stat st = { 0 };
141
142 if (fstat (mfd, &st) == -1)
143 {
Ole Troan8ae3a532019-03-10 21:26:14 +0100144 close (mfd);
Paul Vinciguerra56421092018-11-21 16:34:09 -0800145 perror ("mmap fstat failed");
Paul Vinciguerra356824f2019-01-05 19:37:27 -0800146 return -4;
Ole Troan58492a82018-09-04 13:19:12 +0200147 }
148 if ((memaddr =
149 mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, mfd, 0)) == MAP_FAILED)
150 {
Ole Troan8ae3a532019-03-10 21:26:14 +0100151 close (mfd);
Paul Vinciguerra56421092018-11-21 16:34:09 -0800152 perror ("mmap map failed");
Paul Vinciguerra356824f2019-01-05 19:37:27 -0800153 return -5;
Ole Troan58492a82018-09-04 13:19:12 +0200154 }
155
Ole Troan8ae3a532019-03-10 21:26:14 +0100156 close (mfd);
Ole Troan58492a82018-09-04 13:19:12 +0200157 sm->memory_size = st.st_size;
158 sm->shared_header = memaddr;
159 sm->directory_vector =
160 stat_segment_pointer (memaddr, sm->shared_header->directory_offset);
Ole Troan2fee1672018-08-23 13:00:53 +0200161
162 return 0;
163}
164
Paul Vinciguerra56421092018-11-21 16:34:09 -0800165int
Neale Ranns318d7942018-12-03 01:53:32 -0800166stat_segment_connect (const char *socket_name)
Paul Vinciguerra56421092018-11-21 16:34:09 -0800167{
168 stat_client_main_t *sm = &stat_client_main;
169 return stat_segment_connect_r (socket_name, sm);
170}
171
172void
173stat_segment_disconnect_r (stat_client_main_t * sm)
174{
175 munmap (sm->shared_header, sm->memory_size);
176 return;
177}
178
Ole Troan2fee1672018-08-23 13:00:53 +0200179void
180stat_segment_disconnect (void)
181{
182 stat_client_main_t *sm = &stat_client_main;
Paul Vinciguerra56421092018-11-21 16:34:09 -0800183 return stat_segment_disconnect_r (sm);
184}
Ole Troan58492a82018-09-04 13:19:12 +0200185
Paul Vinciguerra56421092018-11-21 16:34:09 -0800186double
187stat_segment_heartbeat_r (stat_client_main_t * sm)
188{
189 stat_segment_directory_entry_t *vec = get_stat_vector_r (sm);
190 double *hb = stat_segment_pointer (sm->shared_header, vec[4].offset);
191 return *hb;
Ole Troan2fee1672018-08-23 13:00:53 +0200192}
193
Ole Troan58492a82018-09-04 13:19:12 +0200194double
Ole Troan2fee1672018-08-23 13:00:53 +0200195stat_segment_heartbeat (void)
196{
Ole Troan2fee1672018-08-23 13:00:53 +0200197 stat_client_main_t *sm = &stat_client_main;
Paul Vinciguerra56421092018-11-21 16:34:09 -0800198 return stat_segment_heartbeat_r (sm);
Ole Troan2fee1672018-08-23 13:00:53 +0200199}
200
201stat_segment_data_t
Paul Vinciguerra56421092018-11-21 16:34:09 -0800202copy_data (stat_segment_directory_entry_t * ep, stat_client_main_t * sm)
Ole Troan2fee1672018-08-23 13:00:53 +0200203{
204 stat_segment_data_t result = { 0 };
Ole Troan2fee1672018-08-23 13:00:53 +0200205 int i;
206 vlib_counter_t **combined_c; /* Combined counter */
207 counter_t **simple_c; /* Simple counter */
Ole Troan58492a82018-09-04 13:19:12 +0200208 counter_t *error_base;
209 uint64_t *offset_vector;
210
211 assert (sm->shared_header);
212
Ole Troan2fee1672018-08-23 13:00:53 +0200213 result.type = ep->type;
Ole Troan58492a82018-09-04 13:19:12 +0200214 result.name = strdup (ep->name);
Ole Troan2fee1672018-08-23 13:00:53 +0200215 switch (ep->type)
216 {
Ole Troan58492a82018-09-04 13:19:12 +0200217 case STAT_DIR_TYPE_SCALAR_INDEX:
218 result.scalar_value = ep->value;
Ole Troan2fee1672018-08-23 13:00:53 +0200219 break;
220
221 case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
Ole Troanbf495902018-10-02 22:00:29 +0200222 if (ep->offset == 0)
223 return result;
Ole Troan58492a82018-09-04 13:19:12 +0200224 simple_c = stat_segment_pointer (sm->shared_header, ep->offset);
Ole Troan2fee1672018-08-23 13:00:53 +0200225 result.simple_counter_vec = vec_dup (simple_c);
Ole Troan58492a82018-09-04 13:19:12 +0200226 offset_vector =
227 stat_segment_pointer (sm->shared_header, ep->offset_vector);
Ole Troan2fee1672018-08-23 13:00:53 +0200228 for (i = 0; i < vec_len (simple_c); i++)
Ole Troan58492a82018-09-04 13:19:12 +0200229 {
230 counter_t *cb =
231 stat_segment_pointer (sm->shared_header, offset_vector[i]);
232 result.simple_counter_vec[i] = vec_dup (cb);
233 }
Ole Troan2fee1672018-08-23 13:00:53 +0200234 break;
235
236 case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
Ole Troanbf495902018-10-02 22:00:29 +0200237 if (ep->offset == 0)
238 return result;
Ole Troan58492a82018-09-04 13:19:12 +0200239 combined_c = stat_segment_pointer (sm->shared_header, ep->offset);
Ole Troan2fee1672018-08-23 13:00:53 +0200240 result.combined_counter_vec = vec_dup (combined_c);
Ole Troan58492a82018-09-04 13:19:12 +0200241 offset_vector =
242 stat_segment_pointer (sm->shared_header, ep->offset_vector);
Ole Troan2fee1672018-08-23 13:00:53 +0200243 for (i = 0; i < vec_len (combined_c); i++)
Ole Troan58492a82018-09-04 13:19:12 +0200244 {
245 vlib_counter_t *cb =
246 stat_segment_pointer (sm->shared_header, offset_vector[i]);
247 result.combined_counter_vec[i] = vec_dup (cb);
248 }
Ole Troan2fee1672018-08-23 13:00:53 +0200249 break;
250
251 case STAT_DIR_TYPE_ERROR_INDEX:
Ole Troan58492a82018-09-04 13:19:12 +0200252 error_base =
253 stat_segment_pointer (sm->shared_header,
254 sm->shared_header->error_offset);
255 result.error_value = error_base[ep->index];
Ole Troan2fee1672018-08-23 13:00:53 +0200256 break;
257
Ole Troan703908a2019-02-26 16:37:03 +0100258 case STAT_DIR_TYPE_NAME_VECTOR:
259 if (ep->offset == 0)
260 return result;
261 uint8_t **name_vector =
262 stat_segment_pointer (sm->shared_header, ep->offset);
263 result.name_vector = vec_dup (name_vector);
264 offset_vector =
265 stat_segment_pointer (sm->shared_header, ep->offset_vector);
266 for (i = 0; i < vec_len (name_vector); i++)
267 {
268 if (offset_vector[i])
269 {
270 u8 *name =
271 stat_segment_pointer (sm->shared_header, offset_vector[i]);
272 result.name_vector[i] = vec_dup (name);
273 }
274 else
275 result.name_vector[i] = 0;
276 }
277 break;
278
Ole Troan2fee1672018-08-23 13:00:53 +0200279 default:
Ole Troan703908a2019-02-26 16:37:03 +0100280 fprintf (stderr, "Unknown type: %d\n", ep->type);
Ole Troan2fee1672018-08-23 13:00:53 +0200281 }
282 return result;
283}
284
Ole Troan2fee1672018-08-23 13:00:53 +0200285void
286stat_segment_data_free (stat_segment_data_t * res)
287{
288 int i, j;
289 for (i = 0; i < vec_len (res); i++)
290 {
291 switch (res[i].type)
292 {
293 case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
294 for (j = 0; j < vec_len (res[i].simple_counter_vec); j++)
295 vec_free (res[i].simple_counter_vec[j]);
296 vec_free (res[i].simple_counter_vec);
297 break;
298 case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
299 for (j = 0; j < vec_len (res[i].combined_counter_vec); j++)
300 vec_free (res[i].combined_counter_vec[j]);
301 vec_free (res[i].combined_counter_vec);
302 break;
303 default:
304 ;
305 }
Ole Troan58492a82018-09-04 13:19:12 +0200306 free (res[i].name);
Ole Troan2fee1672018-08-23 13:00:53 +0200307 }
308 vec_free (res);
309}
310
Ole Troan58492a82018-09-04 13:19:12 +0200311
312typedef struct
313{
314 uint64_t epoch;
315} stat_segment_access_t;
316
317static void
Paul Vinciguerra56421092018-11-21 16:34:09 -0800318stat_segment_access_start (stat_segment_access_t * sa,
319 stat_client_main_t * sm)
Ole Troan2fee1672018-08-23 13:00:53 +0200320{
Ole Troan58492a82018-09-04 13:19:12 +0200321 stat_segment_shared_header_t *shared_header = sm->shared_header;
322 sa->epoch = shared_header->epoch;
323 while (shared_header->in_progress != 0)
324 ;
325}
326
327static bool
Paul Vinciguerra56421092018-11-21 16:34:09 -0800328stat_segment_access_end (stat_segment_access_t * sa, stat_client_main_t * sm)
Ole Troan58492a82018-09-04 13:19:12 +0200329{
Ole Troan58492a82018-09-04 13:19:12 +0200330 stat_segment_shared_header_t *shared_header = sm->shared_header;
331
332 if (shared_header->epoch != sa->epoch || shared_header->in_progress)
333 return false;
334 return true;
335}
336
337uint32_t *
Paul Vinciguerra56421092018-11-21 16:34:09 -0800338stat_segment_ls_r (uint8_t ** patterns, stat_client_main_t * sm)
Ole Troan58492a82018-09-04 13:19:12 +0200339{
Ole Troan58492a82018-09-04 13:19:12 +0200340 stat_segment_access_t sa;
341
342 uint32_t *dir = 0;
Ole Troan2fee1672018-08-23 13:00:53 +0200343 regex_t regex[vec_len (patterns)];
344
Ole Troan58492a82018-09-04 13:19:12 +0200345 int i, j;
Ole Troan2fee1672018-08-23 13:00:53 +0200346 for (i = 0; i < vec_len (patterns); i++)
347 {
Mohsin Kazmi90a9fdf2018-12-04 14:31:15 +0000348 int rv = regcomp (&regex[i], (const char *) patterns[i], 0);
Ole Troan2fee1672018-08-23 13:00:53 +0200349 if (rv)
350 {
351 fprintf (stderr, "Could not compile regex %s\n", patterns[i]);
352 return dir;
353 }
354 }
355
Paul Vinciguerra56421092018-11-21 16:34:09 -0800356 stat_segment_access_start (&sa, sm);
Ole Troan2fee1672018-08-23 13:00:53 +0200357
Paul Vinciguerra56421092018-11-21 16:34:09 -0800358 stat_segment_directory_entry_t *counter_vec = get_stat_vector_r (sm);
Ole Troan58492a82018-09-04 13:19:12 +0200359 for (j = 0; j < vec_len (counter_vec); j++)
360 {
361 for (i = 0; i < vec_len (patterns); i++)
362 {
363 int rv = regexec (&regex[i], counter_vec[j].name, 0, NULL, 0);
364 if (rv == 0)
365 {
366 vec_add1 (dir, j);
367 break;
368 }
369 }
370 if (vec_len (patterns) == 0)
371 vec_add1 (dir, j);
Ole Troan2fee1672018-08-23 13:00:53 +0200372 }
Ole Troan2fee1672018-08-23 13:00:53 +0200373
374 for (i = 0; i < vec_len (patterns); i++)
375 regfree (&regex[i]);
376
Paul Vinciguerra56421092018-11-21 16:34:09 -0800377 if (!stat_segment_access_end (&sa, sm))
Ole Troan58492a82018-09-04 13:19:12 +0200378 {
379 /* Failed, clean up */
380 vec_free (dir);
381 return 0;
382
383 }
384
385 /* Update last version */
386 sm->current_epoch = sa.epoch;
Ole Troan2fee1672018-08-23 13:00:53 +0200387 return dir;
388}
389
Paul Vinciguerra56421092018-11-21 16:34:09 -0800390uint32_t *
391stat_segment_ls (uint8_t ** patterns)
392{
393 stat_client_main_t *sm = &stat_client_main;
394 return stat_segment_ls_r ((uint8_t **) patterns, sm);
395}
396
Ole Troan2fee1672018-08-23 13:00:53 +0200397stat_segment_data_t *
Paul Vinciguerra56421092018-11-21 16:34:09 -0800398stat_segment_dump_r (uint32_t * stats, stat_client_main_t * sm)
Ole Troan2fee1672018-08-23 13:00:53 +0200399{
400 int i;
Ole Troan2fee1672018-08-23 13:00:53 +0200401 stat_segment_directory_entry_t *ep;
402 stat_segment_data_t *res = 0;
Ole Troan58492a82018-09-04 13:19:12 +0200403 stat_segment_access_t sa;
Ole Troan2fee1672018-08-23 13:00:53 +0200404
Ole Troan58492a82018-09-04 13:19:12 +0200405 /* Has directory been update? */
406 if (sm->shared_header->epoch != sm->current_epoch)
407 return 0;
Ole Troan2fee1672018-08-23 13:00:53 +0200408
Paul Vinciguerra56421092018-11-21 16:34:09 -0800409 stat_segment_access_start (&sa, sm);
Ole Troan2fee1672018-08-23 13:00:53 +0200410 for (i = 0; i < vec_len (stats); i++)
411 {
Ole Troan2fee1672018-08-23 13:00:53 +0200412 /* Collect counter */
Ole Troan58492a82018-09-04 13:19:12 +0200413 ep = vec_elt_at_index (sm->directory_vector, stats[i]);
Paul Vinciguerra56421092018-11-21 16:34:09 -0800414 vec_add1 (res, copy_data (ep, sm));
Ole Troan2fee1672018-08-23 13:00:53 +0200415 }
Ole Troan2fee1672018-08-23 13:00:53 +0200416
Paul Vinciguerra56421092018-11-21 16:34:09 -0800417 if (stat_segment_access_end (&sa, sm))
Ole Troan58492a82018-09-04 13:19:12 +0200418 return res;
419
420 fprintf (stderr, "Epoch changed while reading, invalid results\n");
421 // TODO increase counter
422 return 0;
Ole Troan2fee1672018-08-23 13:00:53 +0200423}
424
Paul Vinciguerra56421092018-11-21 16:34:09 -0800425stat_segment_data_t *
426stat_segment_dump (uint32_t * stats)
427{
428 stat_client_main_t *sm = &stat_client_main;
429 return stat_segment_dump_r (stats, sm);
430}
431
Ole Troan73202102018-08-31 00:29:48 +0200432/* Wrapper for accessing vectors from other languages */
433int
434stat_segment_vec_len (void *vec)
435{
436 return vec_len (vec);
437}
438
Ole Troan82540182018-10-22 09:41:29 +0200439void
440stat_segment_vec_free (void *vec)
441{
442 vec_free (vec);
443}
444
Ole Troan73202102018-08-31 00:29:48 +0200445/* Create a vector from a string (or add to existing) */
Mohsin Kazmi90a9fdf2018-12-04 14:31:15 +0000446uint8_t **
447stat_segment_string_vector (uint8_t ** string_vector, const char *string)
Ole Troan73202102018-08-31 00:29:48 +0200448{
Mohsin Kazmi90a9fdf2018-12-04 14:31:15 +0000449 uint8_t *name = 0;
450 size_t len = strlen (string);
451
452 vec_validate_init_c_string (name, string, len);
453 vec_add1 (string_vector, name);
Ole Troan73202102018-08-31 00:29:48 +0200454 return string_vector;
455}
456
Ole Troan58492a82018-09-04 13:19:12 +0200457stat_segment_data_t *
Paul Vinciguerra56421092018-11-21 16:34:09 -0800458stat_segment_dump_entry_r (uint32_t index, stat_client_main_t * sm)
Ole Troan58492a82018-09-04 13:19:12 +0200459{
Ole Troan58492a82018-09-04 13:19:12 +0200460 stat_segment_directory_entry_t *ep;
461 stat_segment_data_t *res = 0;
462 stat_segment_access_t sa;
463
Paul Vinciguerra56421092018-11-21 16:34:09 -0800464 stat_segment_access_start (&sa, sm);
Ole Troan58492a82018-09-04 13:19:12 +0200465
466 /* Collect counter */
467 ep = vec_elt_at_index (sm->directory_vector, index);
Paul Vinciguerra56421092018-11-21 16:34:09 -0800468 vec_add1 (res, copy_data (ep, sm));
Ole Troan58492a82018-09-04 13:19:12 +0200469
Paul Vinciguerra56421092018-11-21 16:34:09 -0800470 if (stat_segment_access_end (&sa, sm))
Ole Troan58492a82018-09-04 13:19:12 +0200471 return res;
472 return 0;
473}
474
Paul Vinciguerra56421092018-11-21 16:34:09 -0800475stat_segment_data_t *
476stat_segment_dump_entry (uint32_t index)
477{
478 stat_client_main_t *sm = &stat_client_main;
479 return stat_segment_dump_entry_r (index, sm);
480}
481
Ole Troan58492a82018-09-04 13:19:12 +0200482char *
483stat_segment_index_to_name (uint32_t index)
484{
485 char *name;
486 stat_segment_directory_entry_t *counter_vec = get_stat_vector ();
487 stat_segment_directory_entry_t *ep;
488 ep = vec_elt_at_index (counter_vec, index);
489 name = strdup (ep->name);
490 return name;
491}
492
Ole Troan2fee1672018-08-23 13:00:53 +0200493/*
494 * fd.io coding-style-patch-verification: ON
495 *
496 * Local Variables:
497 * eval: (c-set-style "gnu")
498 * End:
499 */