1 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
2 /* Copyright (C) 2020 Facebook, Inc. */
5 #include "testing_helpers.h"
7 int parse_num_list(const char *s
, bool **num_set
, int *num_set_len
)
9 int i
, set_len
= 0, new_len
, num
, start
= 0, end
= -1;
10 bool *set
= NULL
, *tmp
, parsing_end
= false;
15 num
= strtol(s
, &next
, 10);
24 if (!parsing_end
&& *next
== '-') {
28 } else if (*next
== ',') {
32 } else if (*next
== '\0') {
43 if (end
+ 1 > set_len
) {
45 tmp
= realloc(set
, new_len
);
50 for (i
= set_len
; i
< start
; i
++)
55 for (i
= start
; i
<= end
; i
++)
63 *num_set_len
= set_len
;
68 __u32
link_info_prog_id(const struct bpf_link
*link
, struct bpf_link_info
*info
)
70 __u32 info_len
= sizeof(*info
);
73 memset(info
, 0, sizeof(*info
));
74 err
= bpf_obj_get_info_by_fd(bpf_link__fd(link
), info
, &info_len
);
76 printf("failed to get link info: %d\n", -errno
);