Change mptcp_sched_data_set_contexts as static function. Rename
mptcp_subflow_ctx_by_pos with bpf_ prefix, move it into bpf.c in
__diag_* section.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
net/mptcp/bpf.c | 17 +++++++++++++--
net/mptcp/protocol.h | 6 ++----
net/mptcp/sched.c | 50 +++++++++++++++++++-------------------------
3 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index 8109d9dfaf5e..18ddbd36faf3 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -163,15 +163,28 @@ static const struct btf_kfunc_id_set bpf_mptcp_fmodret_set = {
.set = &bpf_mptcp_fmodret_ids,
};
+__diag_push();
+__diag_ignore_all("-Wmissing-prototypes",
+ "kfuncs which will be used in BPF programs");
+
+__bpf_kfunc struct mptcp_subflow_context *
+bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos)
+{
+ if (pos >= MPTCP_SUBFLOWS_MAX)
+ return NULL;
+ return data->contexts[pos];
+}
+
__bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
{
return tcp_rtx_queue_empty(sk);
}
+__diag_pop();
+
BTF_SET8_START(bpf_mptcp_sched_kfunc_ids)
BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled)
-BTF_ID_FLAGS(func, mptcp_sched_data_set_contexts)
-BTF_ID_FLAGS(func, mptcp_subflow_ctx_by_pos)
+BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos)
BTF_ID_FLAGS(func, mptcp_subflow_active)
BTF_ID_FLAGS(func, mptcp_set_timeout)
BTF_ID_FLAGS(func, mptcp_wnd_end)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 12d70ce24843..ebf7566005c6 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -643,6 +643,8 @@ void mptcp_sock_graft(struct sock *sk, struct socket *parent);
u64 mptcp_wnd_end(const struct mptcp_sock *msk);
void mptcp_set_timeout(struct sock *sk);
bool bpf_mptcp_subflow_queues_empty(struct sock *sk);
+struct mptcp_subflow_context *
+bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos);
struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk);
bool __mptcp_close(struct sock *sk, long timeout);
void mptcp_cancel_work(struct sock *sk);
@@ -674,10 +676,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
int mptcp_sched_get_send(struct mptcp_sock *msk);
int mptcp_sched_get_retrans(struct mptcp_sock *msk);
-void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
- struct mptcp_sched_data *data);
-struct mptcp_subflow_context *
-mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos);
static inline bool __tcp_can_send(const struct sock *ssk)
{
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 2ae3f33bd244..a7e1c10b1984 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -121,6 +121,26 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
WRITE_ONCE(subflow->scheduled, scheduled);
}
+static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
+ struct mptcp_sched_data *data)
+{
+ struct mptcp_subflow_context *subflow;
+ int i = 0;
+
+ mptcp_for_each_subflow(msk, subflow) {
+ if (i == MPTCP_SUBFLOWS_MAX) {
+ pr_warn_once("too many subflows");
+ break;
+ }
+ mptcp_subflow_set_scheduled(subflow, false);
+ data->contexts[i++] = subflow;
+ }
+ data->subflows = i;
+
+ for (; i < MPTCP_SUBFLOWS_MAX; i++)
+ data->contexts[i] = NULL;
+}
+
int mptcp_sched_get_send(struct mptcp_sock *msk)
{
struct mptcp_subflow_context *subflow;
@@ -147,6 +167,7 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
data.reinject = false;
if (msk->sched == &mptcp_sched_default || !msk->sched)
return mptcp_sched_default_get_subflow(msk, &data);
+ mptcp_sched_data_set_contexts(msk, &data);
return msk->sched->get_subflow(msk, &data);
}
@@ -169,33 +190,6 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
data.reinject = true;
if (msk->sched == &mptcp_sched_default || !msk->sched)
return mptcp_sched_default_get_subflow(msk, &data);
+ mptcp_sched_data_set_contexts(msk, &data);
return msk->sched->get_subflow(msk, &data);
}
-
-void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
- struct mptcp_sched_data *data)
-{
- struct mptcp_subflow_context *subflow;
- int i = 0;
-
- mptcp_for_each_subflow(msk, subflow) {
- if (i == MPTCP_SUBFLOWS_MAX) {
- pr_warn_once("too many subflows");
- break;
- }
- mptcp_subflow_set_scheduled(subflow, false);
- data->contexts[i++] = subflow;
- }
- data->subflows = i;
-
- for (; i < MPTCP_SUBFLOWS_MAX; i++)
- data->contexts[i] = NULL;
-}
-
-struct mptcp_subflow_context *
-mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos)
-{
- if (pos >= MPTCP_SUBFLOWS_MAX)
- return NULL;
- return data->contexts[pos];
-}
--
2.35.3