Commit ec0aff17 authored by Geliang Tang's avatar Geliang Tang Committed by Gang Yan
Browse files

mptcp: add mptcp_space_from_win helper

mainline inclusion
from mainline-v6.11-rc1
commit 5cdedad62eaba22c45b9c45c8199bacd461afd87
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9VYQ9
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=5cdedad62eaba22c45b9c45c8199bacd461afd87



--------------------------------

As a wrapper of __tcp_space_from_win(), this patch adds a MPTCP dedicated
space_from_win helper mptcp_space_from_win() in protocol.h to paired with
mptcp_win_from_space().

Use it instead of __tcp_space_from_win() in both mptcp_rcv_space_adjust()
and mptcp_set_rcvlowat().

Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 6529c26d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2055,7 +2055,7 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
		do_div(grow, msk->rcvq_space.space);
		rcvwin += (grow << 1);

		rcvbuf = min_t(u64, __tcp_space_from_win(scaling_ratio, rcvwin),
		rcvbuf = min_t(u64, mptcp_space_from_win(sk, rcvwin),
			       READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[2]));

		if (rcvbuf > sk->sk_rcvbuf) {
+5 −0
Original line number Diff line number Diff line
@@ -384,6 +384,11 @@ static inline int mptcp_win_from_space(const struct sock *sk, int space)
	return __tcp_win_from_space(mptcp_sk(sk)->scaling_ratio, space);
}

static inline int mptcp_space_from_win(const struct sock *sk, int win)
{
	return __tcp_space_from_win(mptcp_sk(sk)->scaling_ratio, win);
}

static inline int __mptcp_space(const struct sock *sk)
{
	return mptcp_win_from_space(sk, READ_ONCE(sk->sk_rcvbuf) - __mptcp_rmem(sk));
+1 −1
Original line number Diff line number Diff line
@@ -1576,7 +1576,7 @@ int mptcp_set_rcvlowat(struct sock *sk, int val)
	if (sk->sk_userlocks & SOCK_RCVBUF_LOCK)
		return 0;

	space = __tcp_space_from_win(mptcp_sk(sk)->scaling_ratio, val);
	space = mptcp_space_from_win(sk, val);
	if (space <= sk->sk_rcvbuf)
		return 0;