diff mbox series

[mptcp-next,v15,06/19] mptcp: add sched_data_set_contexts helper

Message ID a95dd03e0cad84b3173381f0585bccb9f5cbba13.1666349129.git.geliang.tang@suse.com (mailing list archive)
State Superseded, archived
Delegated to: Mat Martineau
Headers show
Series BPF redundant scheduler | expand

Checks

Context Check Description
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
matttbe/build warning Build error with: make C=1 net/mptcp/protocol.o
matttbe/KVM_Validation__normal warning Unstable: 3 failed test(s): packetdrill_add_addr selftest_mptcp_join selftest_simult_flows

Commit Message

Geliang Tang Oct. 21, 2022, 10:59 a.m. UTC
Add a new helper mptcp_sched_data_set_contexts() to set the subflow
pointers array in struct mptcp_sched_data. It will be invoked by the
BPF schedulers to export the subflow pointers to the BPF contexts.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/sched.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 1ff2955c6f26..500ca89f6424 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -105,3 +105,22 @@  void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
 {
 	WRITE_ONCE(subflow->scheduled, scheduled);
 }
+
+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;
+	}
+
+	for (; i < MPTCP_SUBFLOWS_MAX; i++)
+		data->contexts[i] = NULL;
+}