Skip to content

Commit 260897f

Browse files
liu-song-6kernel-patches-bot
authored andcommitted
libbpf: introduce bpf_prog_test_run_xattr_opts
This API supports new field cpu_plus in bpf_attr.test. Acked-by: John Fastabend <[email protected]> Signed-off-by: Song Liu <[email protected]>
1 parent 92a8408 commit 260897f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

tools/lib/bpf/bpf.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@ int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size,
684684
return ret;
685685
}
686686

687-
int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr)
687+
int bpf_prog_test_run_xattr_opts(struct bpf_prog_test_run_attr *test_attr,
688+
const struct bpf_prog_test_run_opts *opts)
688689
{
689690
union bpf_attr attr;
690691
int ret;
@@ -693,6 +694,11 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr)
693694
return -EINVAL;
694695

695696
memset(&attr, 0, sizeof(attr));
697+
if (opts) {
698+
if (!OPTS_VALID(opts, bpf_prog_test_run_opts))
699+
return -EINVAL;
700+
attr.test.cpu_plus = opts->cpu_plus;
701+
}
696702
attr.test.prog_fd = test_attr->prog_fd;
697703
attr.test.data_in = ptr_to_u64(test_attr->data_in);
698704
attr.test.data_out = ptr_to_u64(test_attr->data_out);
@@ -712,6 +718,11 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr)
712718
return ret;
713719
}
714720

721+
int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr)
722+
{
723+
return bpf_prog_test_run_xattr_opts(test_attr, NULL);
724+
}
725+
715726
static int bpf_obj_get_next_id(__u32 start_id, __u32 *next_id, int cmd)
716727
{
717728
union bpf_attr attr;

tools/lib/bpf/bpf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ struct bpf_prog_bind_opts {
251251

252252
LIBBPF_API int bpf_prog_bind_map(int prog_fd, int map_fd,
253253
const struct bpf_prog_bind_opts *opts);
254+
255+
struct bpf_prog_test_run_opts {
256+
size_t sz; /* size of this struct for forward/backward compatibility */
257+
__u32 cpu_plus;
258+
};
259+
#define bpf_prog_test_run_opts__last_field cpu_plus
260+
261+
LIBBPF_API
262+
int bpf_prog_test_run_xattr_opts(struct bpf_prog_test_run_attr *test_attr,
263+
const struct bpf_prog_test_run_opts *opts);
264+
254265
#ifdef __cplusplus
255266
} /* extern "C" */
256267
#endif

tools/lib/bpf/libbpf.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ LIBBPF_0.1.0 {
303303
LIBBPF_0.2.0 {
304304
global:
305305
bpf_prog_bind_map;
306+
bpf_prog_test_run_xattr_opts;
306307
bpf_program__section_name;
307308
perf_buffer__buffer_cnt;
308309
perf_buffer__buffer_fd;

0 commit comments

Comments
 (0)