[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240506120400.712629-1-horatiu.vultur@microchip.com>
Date: Mon, 6 May 2024 14:04:00 +0200
From: Horatiu Vultur <horatiu.vultur@...rochip.com>
To: <edumazet@...gle.com>, <davem@...emloft.net>, <kuba@...nel.org>,
<pabeni@...hat.com>, <soheil@...gle.com>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Horatiu Vultur
<horatiu.vultur@...rochip.com>
Subject: [PATCH net] net: tcp: Update the type of scaling_ratio
It was noticed the following issue that sometimes the scaling_ratio was
getting a value of 0, meaning that window space was having a value of 0,
so then the tcp connection was stopping.
The reason why the scaling_ratio was getting a value of 0 is because
when it was calculated, it was truncated from a u64 to a u8. So for
example if it scaling_ratio was supposed to be 256 it was getting a
value of 0.
The fix consists in chaning the type of scaling_ratio from u8 to u16.
Fixes: dfa2f0483360 ("tcp: get rid of sysctl_tcp_adv_win_scale")
Signed-off-by: Horatiu Vultur <horatiu.vultur@...rochip.com>
---
include/linux/tcp.h | 2 +-
include/net/tcp.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 6a5e08b937b31..cc4fd1cbe6c12 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -221,7 +221,7 @@ struct tcp_sock {
u32 lost_out; /* Lost packets */
u32 sacked_out; /* SACK'd packets */
u16 tcp_header_len; /* Bytes of tcp header to send */
- u8 scaling_ratio; /* see tcp_win_from_space() */
+ u16 scaling_ratio; /* see tcp_win_from_space() */
u8 chrono_type : 2, /* current chronograph type */
repair : 1,
tcp_usec_ts : 1, /* TSval values in usec */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 0a51e6a45bce9..252ae24b0f1c7 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1510,7 +1510,7 @@ void tcp_select_initial_window(const struct sock *sk, int __space,
__u32 *window_clamp, int wscale_ok,
__u8 *rcv_wscale, __u32 init_rcv_wnd);
-static inline int __tcp_win_from_space(u8 scaling_ratio, int space)
+static inline int __tcp_win_from_space(u16 scaling_ratio, int space)
{
s64 scaled_space = (s64)space * scaling_ratio;
@@ -1523,7 +1523,7 @@ static inline int tcp_win_from_space(const struct sock *sk, int space)
}
/* inverse of __tcp_win_from_space() */
-static inline int __tcp_space_from_win(u8 scaling_ratio, int win)
+static inline int __tcp_space_from_win(u16 scaling_ratio, int win)
{
u64 val = (u64)win << TCP_RMEM_TO_WIN_SCALE;
--
2.34.1
Powered by blists - more mailing lists