@@ -1232,43 +1232,29 @@ channel_pre_connecting(struct ssh *ssh, Channel *c)
12321232 c -> io_want = SSH_CHAN_IO_SOCK_W ;
12331233}
12341234
1235- #include <linux/tcp.h>
12361235static int
12371236channel_tcpwinsz (struct ssh * ssh )
12381237{
12391238 u_int32_t tcpwinsz = 0 ;
1239+ socklen_t optsz = sizeof (tcpwinsz );
12401240 int ret = -1 ;
12411241
12421242 /* if we aren't on a socket return 128KB */
12431243 if (!ssh_packet_connection_is_on_socket (ssh ))
12441244 return 128 * 1024 ;
12451245
1246- #ifdef TCP_INFO
1247- size_t tcpi_len ;
1248- struct tcp_info local_tcp_info ;
1249- tcpi_len = (size_t )sizeof (local_tcp_info );
1250- ret = getsockopt (ssh_packet_get_connection_in (ssh ), IPPROTO_TCP , TCP_INFO ,
1251- (void * )& local_tcp_info , (socklen_t * )& tcpi_len );
1252- tcpwinsz = local_tcp_info .tcpi_rcv_space ;
1253- #else
1254- socklen_t optsz = sizeof (tcpwinsz );
12551246 ret = getsockopt (ssh_packet_get_connection_in (ssh ),
12561247 SOL_SOCKET , SO_RCVBUF , & tcpwinsz , & optsz );
1257- #endif
1258-
12591248 /* return no more than SSHBUF_SIZE_MAX (currently 256MB) */
12601249 if ((ret == 0 ) && tcpwinsz > SSHBUF_SIZE_MAX )
12611250 tcpwinsz = SSHBUF_SIZE_MAX ;
1262-
1263- debug ("RCV SPACE = %d, winsz = %d" , local_tcp_info .tcpi_rcv_space , tcpwinsz );
12641251 /* if the remote side is OpenSSH after version 8.8 we need to restrict
12651252 * the size of the advertised window. Now this means that any HPN to non-HPN
12661253 * connection will be window limited to 15MB of receive space. This is a
12671254 * non-optimal solution.
12681255 */
12691256
1270- if ((ssh -> compat & SSH_RESTRICT_WINDOW ) &&
1271- (tcpwinsz > NON_HPN_WINDOW_MAX ))
1257+ if ((ssh -> compat & SSH_RESTRICT_WINDOW ) && (tcpwinsz > NON_HPN_WINDOW_MAX ))
12721258 tcpwinsz = NON_HPN_WINDOW_MAX ;
12731259 return (tcpwinsz );
12741260}
0 commit comments