From 5d6619a9181e92bf003047d9ffc6a0585a07720d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 20 Feb 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-02-20 --- pc/adaptec.c | 2 +- pc/trap.c | 5 ++++- port/ipdat.h | 36 ++++++++++++++++++------------------ port/tcpinput.c | 40 +++++++++++++++++++++++++--------------- port/tcpoutput.c | 2 +- 5 files changed, 49 insertions(+), 36 deletions(-) diff --git a/pc/adaptec.c b/pc/adaptec.c index 64a1309e49db8f0840987d88f78622c0e3761c97..18705fb1fa9e08188d0b8bc382f6f04f27325243 100644 --- a/pc/adaptec.c +++ b/pc/adaptec.c @@ -485,7 +485,7 @@ resetscsi(void) outb(port+Rc, Srst|Scrst); delay(500); if((rs = inb(port+Rs)) != (Init|Idle)){ - print("adaptec%d: reset status #%2.2ux\n", 0, rs); + /*print("adaptec%d: reset status #%2.2ux\n", 0, rs);/**/ return; } diff --git a/pc/trap.c b/pc/trap.c index a662f393c11f45d76d402f80731e843d5a82cc70..91f961724ab1b7c6c4d9c28189ea213af3fa0c56 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -43,6 +43,7 @@ int int1mask = 0xff; /* interrupts enabled for second 8259 */ * trap/interrupt gates */ Segdesc ilt[256]; +int badtrap[256]; typedef struct Handler Handler; struct Handler @@ -261,7 +262,9 @@ trap(Ureg *ur) panic("%s pc=0x%lux", excname[v], ur->pc); } } - print("bad trap type %d pc=0x%lux\n", v, ur->pc); + if(badtrap[v]++ < 10 || (badtrap[v]%1000) == 0) + print("bad trap type %d pc=0x%lux: total %d\n", v, ur->pc, + badtrap[v]); return; } diff --git a/port/ipdat.h b/port/ipdat.h index a82378f16a0ff289e00e013c761fe68bccf2b135..75eecccc90246ef6fedbff1b2fc2e60de3790a34 100644 --- a/port/ipdat.h +++ b/port/ipdat.h @@ -208,20 +208,20 @@ struct Tctl uchar type; /* Listening or active connection */ uchar code; /* Icmp code */ struct { - int una; /* Unacked data pointer */ - int nxt; /* Next sequence expected */ - int ptr; /* Data pointer */ + ulong una; /* Unacked data pointer */ + ulong nxt; /* Next sequence expected */ + ulong ptr; /* Data pointer */ ushort wnd; /* Tcp send window */ - int up; /* Urgent data pointer */ - int wl1; - int wl2; + ulong up; /* Urgent data pointer */ + ulong wl1; + ulong wl2; } snd; struct { ulong nxt; /* Receive pointer to next byte slot */ ushort wnd; /* Receive window incoming */ - int up; /* Urgent pointer */ + ulong up; /* Urgent pointer */ } rcv; - int iss; /* Initial sequence number */ + ulong iss; /* Initial sequence number */ ushort cwind; /* Congestion window */ ushort ssthresh; /* Slow start threshold */ int resent; /* Bytes just resent */ @@ -248,7 +248,7 @@ struct Tctl Timer timer; /* Activity timer */ Timer acktimer; /* Acknoledge timer */ Timer rtt_timer; /* Round trip timer */ - int rttseq; /* Round trip sequence */ + ulong rttseq; /* Round trip sequence */ int srtt; /* Shortened round trip */ int mdev; /* Mean deviation of round trip */ }; @@ -264,8 +264,8 @@ struct Tcp { Port source; Port dest; - int seq; - int ack; + ulong seq; + ulong ack; char flags; ushort wnd; ushort up; @@ -477,13 +477,13 @@ ushort ptcl_csum(Block*bp, int, int); int pullb(Block **, int); void reset(Ipaddr, Ipaddr, char, ushort, Tcp*); void tcpsndsyn(Tcpctl*); -int seq_ge(int, int); -int seq_gt(int, int); -int seq_gt(int, int); -int seq_le(int, int); -int seq_lt(int, int); -int seq_within(int, int, int); -int seq_within(int, int, int); +int seq_ge(ulong, ulong); +int seq_gt(ulong, ulong); +int seq_gt(ulong, ulong); +int seq_le(ulong, ulong); +int seq_lt(ulong, ulong); +int seq_within(ulong, ulong, ulong); +int seq_within(ulong, ulong, ulong); void tcpsetstate(Ipconv *, char); void tcpgo(Timer *); void tcphalt(Timer *); diff --git a/port/tcpinput.c b/port/tcpinput.c index cb33bcab11b96828bf1a2b2b4cd8d7b0e5f3ecb0..898572ebf15199b3d19b7471371cb21e3ac5cf95 100644 --- a/port/tcpinput.c +++ b/port/tcpinput.c @@ -308,6 +308,10 @@ tcpinput(Ipifc *ifc, Block *bp) goto output; } + /* + * keep looping till we've processed this packet plus any + * adjacent packets in the resequence queue + */ for(;;) { if(seg.flags & RST) { if(tcb->state == Syn_received @@ -461,16 +465,22 @@ tcpinput(Ipifc *ifc, Block *bp) } } - while(tcb->reseq) { + /* + * get next adjacent segment from the requence queue. + * dump/trim any overlapping segments + */ + for(;;) { + if(tcb->reseq == 0) + goto output; + if(seq_ge(tcb->rcv.nxt, tcb->reseq->seg.seq) == 0) - break; + goto output; get_reseq(tcb, &tos, &seg, &bp, &length); if(trim(tcb, &seg, &bp, &length) == 0) break; } - break; } output: tcpoutput(s); @@ -572,7 +582,7 @@ update(Ipconv *s, Tcp *seg) int in_window(Tcpctl *tcb, int seq) { - return seq_within(seq, tcb->rcv.nxt, (int)(tcb->rcv.nxt+tcb->rcv.wnd-1)); + return seq_within(seq, tcb->rcv.nxt, tcb->rcv.nxt+tcb->rcv.wnd-1); } void @@ -697,8 +707,8 @@ trim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length) accept++; else if(len != 0) { - if(in_window(tcb, (int)(seg->seq+len-1)) || - seq_within(tcb->rcv.nxt, seg->seq,(int)(seg->seq+len-1))) + if(in_window(tcb, seg->seq+len-1) || + seq_within(tcb->rcv.nxt, seg->seq,seg->seq+len-1)) accept++; } } @@ -864,7 +874,7 @@ localclose(Ipconv *s, char reason[]) } int -seq_within(int x, int low, int high) +seq_within(ulong x, ulong low, ulong high) { if(low <= high){ if(low <= x && x <= high) @@ -878,27 +888,27 @@ seq_within(int x, int low, int high) } int -seq_lt(int x, int y) +seq_lt(ulong x, ulong y) { - return (long)(x-y) < 0; + return x < y; } int -seq_le(int x, int y) +seq_le(ulong x, ulong y) { - return (long)(x-y) <= 0; + return x <= y; } int -seq_gt(int x, int y) +seq_gt(ulong x, ulong y) { - return (long)(x-y) > 0; + return x > y; } int -seq_ge(int x, int y) +seq_ge(ulong x, ulong y) { - return (long)(x-y) >= 0; + return x >= y; } void diff --git a/port/tcpoutput.c b/port/tcpoutput.c index 41dd8d11e366703ad5e784e4574d1d5b816f0a04..0b34e33db8d78e501b27cbe04bbd568c0e9a7b89 100644 --- a/port/tcpoutput.c +++ b/port/tcpoutput.c @@ -112,7 +112,7 @@ tcpoutput(Ipconv *s) /* * keep track of balance of resent data */ if(tcb->snd.ptr < tcb->snd.nxt) - tcb->resent += MIN((int)tcb->snd.nxt - (int)tcb->snd.ptr,(int)ssize); + tcb->resent += MIN(tcb->snd.nxt - tcb->snd.ptr,(int)ssize); tcb->snd.ptr += ssize;