TCP: Ack every other received full MSS segment, bugfixes.

git-svn-id: svn://kolibrios.org@7974 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2020-05-23 15:20:41 +00:00
parent d22e3a158e
commit c20f1efa82
3 changed files with 34 additions and 20 deletions

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;; ;; Part of the TCP/IP network stack for KolibriOS ;;
@ -292,7 +292,7 @@ sys_socket:
align 4 align 4
socket_open: 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 push ecx edx esi
call socket_alloc call socket_alloc
@ -301,7 +301,7 @@ socket_open:
jz .nobuffs jz .nobuffs
mov [esp+32], edi ; return socketnumber 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 test edx, SO_NONBLOCK
jz @f jz @f
@ -374,7 +374,7 @@ align 4
.tcp: .tcp:
mov [eax + SOCKET.Protocol], IP_PROTO_TCP mov [eax + SOCKET.Protocol], IP_PROTO_TCP
mov [eax + SOCKET.snd_proc], socket_send_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 mov [eax + SOCKET.connect_proc], tcp_connect
tcp_init_socket eax tcp_init_socket eax
@ -896,6 +896,20 @@ socket_receive_dgram:
@@: @@:
ret 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 align 4
socket_receive_local: socket_receive_local:
@ -1829,14 +1843,13 @@ socket_block:
pushf pushf
cli cli
; Set the 'socket is blocked' flag ; Set the 'socket is blocked' flag
or [eax + SOCKET.state], SS_BLOCKED or [eax + SOCKET.state], SS_BLOCKED
; Suspend the thread ; Suspend the thread
push edx push edx
mov edx, [TASK_BASE] 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 ; Remember the thread ID so we can wake it up again
mov edx, [edx + TASKDATA.pid] mov edx, [edx + TASKDATA.pid]
@ -1882,7 +1895,7 @@ socket_notify:
cmp [esi + TASKDATA.pid], ebx cmp [esi + TASKDATA.pid], ebx
je .found je .found
inc ecx inc ecx
add esi, 0x20 add esi, sizeof.TASKDATA
cmp ecx, [TASK_COUNT] cmp ecx, [TASK_COUNT]
jbe .next jbe .next
@ -1914,7 +1927,7 @@ socket_notify:
; Socket and thread exists and socket is of blocking type ; Socket and thread exists and socket is of blocking type
; We'll try to unblock it. ; We'll try to unblock it.
and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag 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" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
pop esi ecx ebx pop esi ecx ebx

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;; ;; Part of the TCP/IP network stack for KolibriOS ;;
@ -1275,7 +1275,7 @@ endl
; we'll hang forever. ; we'll hang forever.
test [ebx + SOCKET.state], SS_CANTRCVMORE test [ebx + SOCKET.state], SS_CANTRCVMORE
jnz @f jz @f
mov eax, ebx mov eax, ebx
call socket_is_disconnected call socket_is_disconnected
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;; ;; 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_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.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 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 DEBUGF DEBUG_NETWORK_VERBOSE, "tcp_drop: %x\n", eax
@ -152,19 +156,16 @@ tcp_drop: ; FIXME CHECKME TODO
call tcp_output call tcp_output
pop eax pop eax
;;; TODO: update stats inc [TCPS_drops]
mov [eax + SOCKET.errorcode], ebx
jmp tcp_close jmp tcp_close
.no_syn_received: .no_syn_received:
inc [TCPS_conndrops]
;;; TODO: update stats mov [eax + SOCKET.errorcode], ebx
jmp tcp_close
;;; TODO: check if error code is "Connection timed out' and handle accordingly
; mov [eax + SOCKET.errorcode], ebx
;-----------------------------------------------------------------; ;-----------------------------------------------------------------;