Skip to content

Commit 71b5388

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
Squash to "selftests/bpf: Add bpf_first scheduler & test"
1. Update sched_init. 2. For drop bpf_object__find_map_by_name in test_bpf_sched(), change the first parameter of it as bpf_map. 3. Use .struct_ops.link instead of .struct_ops. Signed-off-by: Geliang Tang <[email protected]>
1 parent 893e75d commit 71b5388

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tools/testing/selftests/bpf/prog_tests/mptcp.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,27 +645,30 @@ static void test_default(void)
645645
netns_free(netns);
646646
}
647647

648-
static void test_bpf_sched(struct bpf_object *obj, char *sched,
648+
static void test_bpf_sched(struct bpf_map *map, char *sched,
649649
bool addr1, bool addr2)
650650
{
651651
char bpf_sched[MPTCP_SCHED_NAME_MAX] = "bpf_";
652652
struct netns_obj *netns;
653653
struct bpf_link *link;
654-
struct bpf_map *map;
654+
int err;
655655

656656
if (!ASSERT_LT(strlen(bpf_sched) + strlen(sched),
657657
MPTCP_SCHED_NAME_MAX, "Scheduler name too long"))
658658
return;
659659

660-
map = bpf_object__find_map_by_name(obj, sched);
661660
link = bpf_map__attach_struct_ops(map);
662-
if (CHECK(!link, sched, "attach_struct_ops: %d\n", errno))
661+
if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
663662
return;
664663

665-
netns = sched_init("subflow", strcat(bpf_sched, sched));
664+
netns = netns_new(NS_TEST, true);
666665
if (!netns)
667666
goto fail;
668667

668+
err = sched_init("subflow", strcat(bpf_sched, sched));
669+
if (!ASSERT_OK(err, "sched_init"))
670+
goto fail;
671+
669672
send_data_and_verify(sched, addr1, addr2);
670673

671674
fail:
@@ -681,7 +684,7 @@ static void test_first(void)
681684
if (!ASSERT_OK_PTR(skel, "open_and_load: first"))
682685
return;
683686

684-
test_bpf_sched(skel->obj, "first", WITH_DATA, WITHOUT_DATA);
687+
test_bpf_sched(skel->maps.first, "first", WITH_DATA, WITHOUT_DATA);
685688
mptcp_bpf_first__destroy(skel);
686689
}
687690

tools/testing/selftests/bpf/progs/mptcp_bpf_first.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int BPF_PROG(bpf_first_get_send, struct mptcp_sock *msk)
2929
return 0;
3030
}
3131

32-
SEC(".struct_ops")
32+
SEC(".struct_ops.link")
3333
struct mptcp_sched_ops first = {
3434
.init = (void *)mptcp_sched_first_init,
3535
.release = (void *)mptcp_sched_first_release,

0 commit comments

Comments
 (0)