Better TCP timestamp, fixed stack corruption if PAWS fails.

git-svn-id: svn://kolibrios.org@3252 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-02-17 19:43:01 +00:00
parent 72f758c218
commit 629fb2b3e1

View File

@ -23,7 +23,7 @@ $Revision$
; Add a segment to the incoming TCP queue ; Add a segment to the incoming TCP queue
; ;
; IN: [esp] = ptr to buffer ; IN: [esp] = ptr to buffer
; [esp+4] = buffer size ; [esp+4] = buffer size (dont care)
; ebx = ptr to device struct ; ebx = ptr to device struct
; ecx = segment size ; ecx = segment size
; esi = ptr to TCP segment ; esi = ptr to TCP segment
@ -36,14 +36,16 @@ $Revision$
align 4 align 4
TCP_input: TCP_input:
; record the current time
mov eax, [timer_ticks] ; in 1/100 seconds
mov [esp + 4], eax
push ebx ecx esi edi ; mind the order push ebx ecx esi edi ; mind the order
mov esi, esp mov esi, esp
pushf pushf
cli cli
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
popf popf
add esp, sizeof.TCP_queue_entry add esp, sizeof.TCP_queue_entry
@ -78,7 +80,7 @@ TCP_process_input:
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;
; IN: [esp] = ptr to buffer ; IN: [esp] = ptr to buffer
; [esp+4] = buffer size - actually, we dont care ; [esp+4] = timestamp when segment was received
; ebx = ptr to device struct ; ebx = ptr to device struct
; ecx = segment size ; ecx = segment size
; esi = ptr to TCP segment ; esi = ptr to TCP segment
@ -90,11 +92,7 @@ TCP_process_input:
DEBUGF 1,"TCP_input: size=%u time=%d\n", ecx, [timer_ticks] DEBUGF 1,"TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
; First, record the current time ; re-calculate the checksum (if not already done by hw)
mov eax, [timer_ticks] ; in 1/100 seconds
mov [esp + 4], eax ; from now on, we'll call this TCP_now
; then, re-calculate the checksum (if not already done by hw)
; test [ebx + NET_DEVICE.hwacc], HWACC_TCP_IPv4_IN ; test [ebx + NET_DEVICE.hwacc], HWACC_TCP_IPv4_IN
; jnz .checksum_ok ; jnz .checksum_ok
@ -247,7 +245,7 @@ TCP_process_input:
;-------------------- ;--------------------
; Process TCP options ; Process TCP options
push ecx push ecx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
movzx ecx, [edx + TCP_header.DataOffset] movzx ecx, [edx + TCP_header.DataOffset]
cmp ecx, sizeof.TCP_header ; Does header contain any options? cmp ecx, sizeof.TCP_header ; Does header contain any options?
@ -366,8 +364,11 @@ TCP_process_input:
mov eax, [esp+4+4] ; tcp_now mov eax, [esp+4+4] ; tcp_now
sub eax, [ebx + TCP_SOCKET.ts_recent_age] sub eax, [ebx + TCP_SOCKET.ts_recent_age]
pop ecx
cmp eax, TCP_PAWS_IDLE cmp eax, TCP_PAWS_IDLE
jle .drop_after_ack ; TODO: update stats jle .drop_after_ack ; TODO: update stats
push ecx
mov [ebx + TCP_SOCKET.ts_recent], 0 ; timestamp was invalid, fix it. mov [ebx + TCP_SOCKET.ts_recent], 0 ; timestamp was invalid, fix it.
.no_paws: .no_paws:
@ -375,7 +376,7 @@ TCP_process_input:
.no_options: .no_options:
pop ecx pop ecx;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;----------------------------------------------------------------------- ;-----------------------------------------------------------------------
; Time to do some header prediction (Original Principle by Van Jacobson) ; Time to do some header prediction (Original Principle by Van Jacobson)
@ -1537,6 +1538,7 @@ align 4
.need_output: .need_output:
DEBUGF 1,"TCP_input: need output\n" DEBUGF 1,"TCP_input: need output\n"
call TCP_output call TCP_output
.dumpit: .dumpit: