@@ -663,27 +663,30 @@ static void test_default(void)
cleanup_netns(nstoken);
}
-static void test_bpf_sched(struct bpf_object *obj, char *sched,
+static void test_bpf_sched(struct bpf_map *map, char *sched,
bool addr1, bool addr2)
{
char bpf_sched[MPTCP_SCHED_NAME_MAX] = "bpf_";
struct nstoken *nstoken;
struct bpf_link *link;
- struct bpf_map *map;
+ int err;
if (!ASSERT_LT(strlen(bpf_sched) + strlen(sched),
MPTCP_SCHED_NAME_MAX, "Scheduler name too long"))
return;
- map = bpf_object__find_map_by_name(obj, sched);
link = bpf_map__attach_struct_ops(map);
- if (CHECK(!link, sched, "attach_struct_ops: %d\n", errno))
+ if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
return;
- nstoken = sched_init("subflow", strcat(bpf_sched, sched));
+ nstoken = create_netns();
if (!nstoken)
goto fail;
+ err = sched_init("subflow", strcat(bpf_sched, sched));
+ if (!ASSERT_OK(err, "sched_init"))
+ goto fail;
+
send_data_and_verify(sched, addr1, addr2);
fail:
@@ -699,7 +702,7 @@ static void test_first(void)
if (!ASSERT_OK_PTR(skel, "open_and_load: first"))
return;
- test_bpf_sched(skel->obj, "first", WITH_DATA, WITHOUT_DATA);
+ test_bpf_sched(skel->maps.first, "first", WITH_DATA, WITHOUT_DATA);
mptcp_bpf_first__destroy(skel);
}
@@ -42,6 +42,14 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
return subflow->tcp_sock;
}
+#define WRITE_ONCE(x, val) ((*(volatile typeof(x) *) &(x)) = (val))
+
+static __always_inline void
+mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, bool scheduled)
+{
+ WRITE_ONCE(subflow->scheduled, scheduled);
+}
+
/* ksym */
extern struct mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) __ksym;
extern void bpf_mptcp_sock_release(struct mptcp_sock *msk) __ksym;
@@ -52,10 +60,4 @@ bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym;
extern struct sock *
bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym;
-extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
- bool scheduled) __ksym;
-
-extern struct mptcp_subflow_context *
-bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) __ksym;
-
#endif
@@ -20,11 +20,11 @@ SEC("struct_ops")
int BPF_PROG(bpf_first_get_subflow, struct mptcp_sock *msk,
struct mptcp_sched_data *data)
{
- mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, 0), true);
+ mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx(msk->first), true);
return 0;
}
-SEC(".struct_ops")
+SEC(".struct_ops.link")
struct mptcp_sched_ops first = {
.init = (void *)mptcp_sched_first_init,
.release = (void *)mptcp_sched_first_release,