From c20f1efa82188d8393f1708b8710ab04a526bc6a Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sat, 23 May 2020 15:20:41 +0000 Subject: [PATCH] TCP: Ack every other received full MSS segment, bugfixes. git-svn-id: svn://kolibrios.org@7974 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/network/socket.inc | 29 +++++++++++++++++++++-------- kernel/trunk/network/tcp_input.inc | 4 ++-- kernel/trunk/network/tcp_subr.inc | 21 +++++++++++---------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index 10ef347ea9..f997dc58b3 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2020. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; Part of the TCP/IP network stack for KolibriOS ;; @@ -292,7 +292,7 @@ sys_socket: align 4 socket_open: - DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi + DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x\n", ecx, edx, esi push ecx edx esi call socket_alloc @@ -301,7 +301,7 @@ socket_open: jz .nobuffs mov [esp+32], edi ; return socketnumber - DEBUGF DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi + DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: socknum=%u\n", edi test edx, SO_NONBLOCK jz @f @@ -374,7 +374,7 @@ align 4 .tcp: mov [eax + SOCKET.Protocol], IP_PROTO_TCP mov [eax + SOCKET.snd_proc], socket_send_tcp - mov [eax + SOCKET.rcv_proc], socket_receive_stream + mov [eax + SOCKET.rcv_proc], socket_receive_tcp mov [eax + SOCKET.connect_proc], tcp_connect tcp_init_socket eax @@ -896,6 +896,20 @@ socket_receive_dgram: @@: ret +align 4 +socket_receive_tcp: + + call socket_receive_stream + + test ecx, ecx + jz @f + push eax ebx ecx + call tcp_output + pop ecx ebx eax + @@: + + ret + align 4 socket_receive_local: @@ -1829,14 +1843,13 @@ socket_block: pushf cli - ; Set the 'socket is blocked' flag or [eax + SOCKET.state], SS_BLOCKED ; Suspend the thread push edx mov edx, [TASK_BASE] - mov [edx + TASKDATA.state], 1 ; Suspended + mov [edx + TASKDATA.state], TSTATE_RUN_SUSPENDED ; Remember the thread ID so we can wake it up again mov edx, [edx + TASKDATA.pid] @@ -1882,7 +1895,7 @@ socket_notify: cmp [esi + TASKDATA.pid], ebx je .found inc ecx - add esi, 0x20 + add esi, sizeof.TASKDATA cmp ecx, [TASK_COUNT] jbe .next @@ -1914,7 +1927,7 @@ socket_notify: ; Socket and thread exists and socket is of blocking type ; We'll try to unblock it. and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag - mov [esi + TASKDATA.state], 0 ; Run the thread + mov [esi + TASKDATA.state], TSTATE_RUNNING ; Run the thread DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" pop esi ecx ebx diff --git a/kernel/trunk/network/tcp_input.inc b/kernel/trunk/network/tcp_input.inc index 38de8a9136..2e274fb20d 100644 --- a/kernel/trunk/network/tcp_input.inc +++ b/kernel/trunk/network/tcp_input.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2020. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; Part of the TCP/IP network stack for KolibriOS ;; @@ -1275,7 +1275,7 @@ endl ; we'll hang forever. test [ebx + SOCKET.state], SS_CANTRCVMORE - jnz @f + jz @f mov eax, ebx call socket_is_disconnected mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle diff --git a/kernel/trunk/network/tcp_subr.inc b/kernel/trunk/network/tcp_subr.inc index 5e50a2d066..9268cd22d5 100644 --- a/kernel/trunk/network/tcp_subr.inc +++ b/kernel/trunk/network/tcp_subr.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2020. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; Part of the TCP/IP network stack for KolibriOS ;; @@ -102,6 +102,8 @@ macro tcp_init_socket socket { mov [socket + TCP_SOCKET.SND_CWND], TCP_max_win shl TCP_max_winshift mov [socket + TCP_SOCKET.SND_SSTHRESH], TCP_max_win shl TCP_max_winshift + mov [socket + TCP_SOCKET.RCV_SCALE], 0 + mov [socket + TCP_SOCKET.SND_SCALE], 0 } @@ -139,7 +141,9 @@ tcp_pull_out_of_band: ; ; ;-----------------------------------------------------------------; align 4 -tcp_drop: ; FIXME CHECKME TODO +tcp_drop: + +;;; TODO: check if error code is "Connection timed out' and handle accordingly DEBUGF DEBUG_NETWORK_VERBOSE, "tcp_drop: %x\n", eax @@ -152,19 +156,16 @@ tcp_drop: ; FIXME CHECKME TODO call tcp_output pop eax -;;; TODO: update stats + inc [TCPS_drops] + mov [eax + SOCKET.errorcode], ebx jmp tcp_close .no_syn_received: + inc [TCPS_conndrops] -;;; TODO: update stats - -;;; TODO: check if error code is "Connection timed out' and handle accordingly - -; mov [eax + SOCKET.errorcode], ebx - - + mov [eax + SOCKET.errorcode], ebx + jmp tcp_close ;-----------------------------------------------------------------;