diff mbox series

[mptcp-next,v9,01/13] mptcp: check sk_stream_memory_free in loop

Message ID 85e54452f647a887cdc1643629d06e017c3eef54.1730268415.git.tanggeliang@kylinos.cn (mailing list archive)
State Changes Requested
Headers show
Series use bpf_iter in bpf schedulers | expand

Checks

Context Check Description
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/build success Build and static analysis OK
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang Oct. 30, 2024, 6:10 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

In order to make it easier to implement similar logic to the burst
scheduler in BPF program, the sk_stream_memory_free() check is moved
forward into mptcp_for_each_subflow loop.

Assignment like "ssk = send_info[SSK_MODE_ACTIVE].ssk" is not allowed
in BPF, so bpf_core_cast() is used to cast it. But a casted pointer can't
pass to a kfunc (sk_stream_memory_free). To solve this, In BPF burst
scheduler sk_stream_memory_free check is moved forward to the position
before "send_info[backup].ssk = ssk;" in bpf_for_each() loop.

To keep mptcp_subflow_get_send() and BPF burst scheduler code consistent,
this patch also synchronizes the change in BPF burst scheduler into
mptcp_subflow_get_send().

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/mptcp/protocol.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 21bc3586c33e..2ae9b8012dcd 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1460,6 +1460,8 @@  struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 
 		linger_time = div_u64((u64)READ_ONCE(ssk->sk_wmem_queued) << 32, pace);
 		if (linger_time < send_info[backup].linger_time) {
+			if (!sk_stream_memory_free(ssk))
+				continue;
 			send_info[backup].ssk = ssk;
 			send_info[backup].linger_time = linger_time;
 		}
@@ -1482,7 +1484,7 @@  struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 	 * to check that subflow has a non empty cwin.
 	 */
 	ssk = send_info[SSK_MODE_ACTIVE].ssk;
-	if (!ssk || !sk_stream_memory_free(ssk))
+	if (!ssk)
 		return NULL;
 
 	burst = min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt);