Bugfixes in Net branch:

- Fixed delayed ACK (misimplementation)
- Fixed zero window problem and checksum for TCP_respond_socket

git-svn-id: svn://kolibrios.org@1830 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2011-02-01 16:14:18 +00:00
parent 7a5537dc4f
commit 0d53bac040
5 changed files with 35 additions and 29 deletions

View File

@ -131,7 +131,6 @@ virtual at IP_SOCKET.end
;------- ;-------
; Timers ; Timers
.timer_retransmission dw ? ; rexmt .timer_retransmission dw ? ; rexmt
.timer_ack dw ?
.timer_persist dw ? .timer_persist dw ?
.timer_keepalive dw ? ; keepalive/syn timeout .timer_keepalive dw ? ; keepalive/syn timeout
.timer_timed_wait dw ? ; also used as 2msl timer .timer_timed_wait dw ? ; also used as 2msl timer
@ -1209,12 +1208,12 @@ SOCKET_ring_read:
.nd: .nd:
pop ecx pop ecx
; .no_data_at_all: .no_data_at_all:
ret ret
.less_data: .less_data:
mov ecx, [eax + RING_BUFFER.size] mov ecx, [eax + RING_BUFFER.size]
test ecx, ecx ; test ecx, ecx
; jz .no_data_at_all ; jz .no_data_at_all
jmp .copy jmp .copy

View File

@ -32,6 +32,7 @@ $Revision$
; OUT: / ; OUT: /
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
TCP_input: TCP_input:
@ -153,11 +154,15 @@ TCP_input:
;---------------- ;----------------
; Lock the socket ; Lock the socket
cmp [ebx + SOCKET.lock], 0
jne .drop_not_locked ;;; HACK ! HACK ! dirty fucking HACK ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
add ebx, SOCKET.lock add ebx, SOCKET.lock
DEBUGF 1,"lock: %x\n", [ebx] DEBUGF 1,"lock: %x\n", [ebx]
call wait_mutex call wait_mutex
sub ebx, SOCKET.lock sub ebx, SOCKET.lock
DEBUGF 1,"Socket locked\n" DEBUGF 1,"Socket locked\n"
;--------------------------------------- ;---------------------------------------
@ -371,7 +376,7 @@ TCP_input:
mov [ebx + TCP_SOCKET.SND_UNA], eax mov [ebx + TCP_SOCKET.SND_UNA], eax
; Stop retransmit timer ; Stop retransmit timer
mov [ebx + TCP_SOCKET.timer_ack], 0 mov [ebx + TCP_SOCKET.timer_retransmission], 0
; Awaken waiting processes ; Awaken waiting processes
mov [ebx + SOCKET.lock], 0 mov [ebx + SOCKET.lock], 0
@ -646,7 +651,7 @@ align 4
sub eax, [edx + TCP_segment.SequenceNumber] sub eax, [edx + TCP_segment.SequenceNumber]
jle .no_duplicate jle .no_duplicate
DEBUGF 1,"Uh oh.. %x bytes of duplicate data!\n", eax DEBUGF 1,"Uh oh.. %u bytes of duplicate data!\n", eax
test [edx + TCP_segment.Flags], TH_SYN test [edx + TCP_segment.Flags], TH_SYN
jz .no_dup_syn jz .no_dup_syn
@ -669,8 +674,6 @@ align 4
jz .no_duplicate jz .no_duplicate
.no_dup_syn: .no_dup_syn:
DEBUGF 1,"Going to drop %u out of %u bytes\n", eax, ecx
; eax holds number of bytes to drop ; eax holds number of bytes to drop
; Check for entire duplicate packet ; Check for entire duplicate packet
@ -678,6 +681,8 @@ align 4
cmp eax, ecx cmp eax, ecx
jge .duplicate jge .duplicate
DEBUGF 1,"Going to drop %u out of %u bytes\n", eax, ecx
;;; TODO: apply figure 28.30 ;;; TODO: apply figure 28.30
; Check for duplicate FIN ; Check for duplicate FIN
@ -718,7 +723,7 @@ align 4
;;; TODO ;;; TODO
jmp .drop ;;; DROP the packet ?? jmp .drop_after_ack
.no_duplicate: .no_duplicate:
@ -1456,8 +1461,8 @@ align 4
mov [ebx + SOCKET.lock], 0 mov [ebx + SOCKET.lock], 0
push ebx push ebx
mov eax, ebx mov cl, TH_ACK
call TCP_output call TCP_respond_socket
pop ebx pop ebx
call kernel_free call kernel_free
@ -1500,10 +1505,9 @@ align 4
.respond_ack: .respond_ack:
mov dl, TH_RST
push ebx push ebx
call TCP_respond_segment mov cl, TH_RST
call TCP_respond_socket
pop ebx pop ebx
jmp .destroy_new_socket jmp .destroy_new_socket
@ -1511,9 +1515,8 @@ align 4
.respond_syn: .respond_syn:
mov dl, TH_RST + TH_ACK
push ebx push ebx
mov cl, TH_RST + TH_ACK
call TCP_respond_socket call TCP_respond_socket
pop ebx pop ebx

View File

@ -361,7 +361,7 @@ TCP_output:
pushw 0 ; .UrgentPointer dw ? pushw 0 ; .UrgentPointer dw ?
pushw 0 ; .Checksum dw ? pushw 0 ; .Checksum dw ?
pushw 0x00a0 ; .Window dw ? ;;;;;;; pushw 0x00a0 ; .Window dw ? ;;;;;;; FIXME
shl edi, 2 ; .DataOffset db ? only 4 left-most bits shl edi, 2 ; .DataOffset db ? only 4 left-most bits
shl dx, 8 shl dx, 8
or dx, di ; .Flags db ? or dx, di ; .Flags db ?

View File

@ -228,7 +228,7 @@ TCP_outflags:
;--------------------------------------- ;---------------------------------------
; ;
; The easy way to send an ACK/RST/keepalive segment ; The fast way to send an ACK/RST/keepalive segment
; ;
; TCP_respond_socket: ; TCP_respond_socket:
; ;
@ -274,8 +274,9 @@ TCP_respond_socket:
stosb stosb
mov al, cl mov al, cl
stosb stosb
mov ax, [esi + TCP_SOCKET.RCV_WND] ; mov ax, [esi + TCP_SOCKET.RCV_WND]
rol ax, 8 ; rol ax, 8
mov ax, 0x00a0 ;;;;;;; FIXME
stosw ; window stosw ; window
xor eax, eax xor eax, eax
stosd ; checksum + urgentpointer stosd ; checksum + urgentpointer
@ -287,7 +288,7 @@ TCP_respond_socket:
sub edi, TCP_segment.Data sub edi, TCP_segment.Data
mov ecx, TCP_segment.Data mov ecx, TCP_segment.Data
xchg esi, edi xchg esi, edi
TCP_checksum (edi + IP_SOCKET.LocalIP), (esi + IP_SOCKET.RemoteIP) TCP_checksum (edi + IP_SOCKET.LocalIP), (edi + IP_SOCKET.RemoteIP)
mov [esi+TCP_segment.Checksum], dx mov [esi+TCP_segment.Checksum], dx
;-------------------- ;--------------------

View File

@ -24,23 +24,26 @@ macro TCP_timer_160ms {
local .loop local .loop
local .exit local .exit
mov eax, net_sockets mov ebx, net_sockets
.loop: .loop:
mov eax, [eax + SOCKET.NextPtr] mov ebx, [ebx + SOCKET.NextPtr]
or eax, eax or ebx, ebx
jz .exit jz .exit
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP ;;; We should also check if family is AF_INET cmp [ebx + SOCKET.Domain], AF_INET4
jne .loop jne .loop
dec [eax + TCP_SOCKET.timer_ack] cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP ;;; We should also check if family is AF_INET
jnz .loop jne .loop
DEBUGF 1,"TCP ack for socket %x expired, time to piggyback!\n", eax test [ebx + TCP_SOCKET.t_flags], TF_DELACK
jz .loop
and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
push eax push ebx
mov cl, TH_ACK
call TCP_respond_socket call TCP_respond_socket
pop eax pop ebx
jmp .loop jmp .loop