mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: tcp: Update the type of scaling_ratio
@ 2024-05-06 12:04 Horatiu Vultur
  2024-05-06 12:35 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Horatiu Vultur @ 2024-05-06 12:04 UTC (permalink / raw)
  To: edumazet, davem, kuba, pabeni, soheil
  Cc: netdev, linux-kernel, Horatiu Vultur

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@microchip.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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-07  6:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 12:04 [PATCH net] net: tcp: Update the type of scaling_ratio Horatiu Vultur
2024-05-06 12:35 ` Eric Dumazet
2024-05-06 12:42   ` Eric Dumazet
2024-05-06 13:13   ` Horatiu Vultur
2024-05-07  5:13 ` kernel test robot
2024-05-07  6:08 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®