From dc27128930f013c3595245c24223eb7728873954 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 7 Jan 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-01-07 --- port/ipdat.h | 2 +- port/stil.c | 2 ++ port/stip.c | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/port/ipdat.h b/port/ipdat.h index 68b6f6916daad45f4911b74bc14952ac92bcf8f9..93f281c79fe4e385f9528c30e55526804dfc5eb3 100644 --- a/port/ipdat.h +++ b/port/ipdat.h @@ -437,7 +437,7 @@ Block *ip_reassemble(int, Block*, Etherhdr*); Ipconv *portused(Ipconv *, Port); Port nextport(Ipconv *, Port); Fragq *ipfragallo(void); -void ipfragfree(Fragq*); +void ipfragfree(Fragq*, int); void iproute(uchar*, uchar*); void initfrag(int); int ntohtcp(Tcp*, Block**); diff --git a/port/stil.c b/port/stil.c index 41ee9bba86e39a7f2054f3b4e79bea5afae53dbd..58ebb2ea35c8100c15a2437b37f2337a0a4a2041 100644 --- a/port/stil.c +++ b/port/stil.c @@ -635,6 +635,8 @@ ilsendctl(Ipconv *ipc, Ilhdr *inih, int type, ulong id, ulong ack) ih->proto = IP_ILPROTO; hnputl(ih->src, Myip); hnputs(ih->illen, IL_HDRSIZE); + ih->frag[0] = 0; + ih->frag[1] = 0; if(inih) { hnputl(ih->dst, nhgetl(inih->src)); hnputs(ih->ilsrc, nhgets(inih->ildst)); diff --git a/port/stip.c b/port/stip.c index a2dd323a7f1c58a89e073cfe0fa4c755a7fd8768..9dca0956a451ae5f2ce898d425ec95be48b96c6b 100644 --- a/port/stip.c +++ b/port/stip.c @@ -313,7 +313,7 @@ ipetheriput(Queue *q, Block *bp) /* Ensure we have enough data to process */ if(BLEN(bp) < (ETHER_HDR+ETHER_IPHDR)) { bp = pullup(bp, ETHER_HDR+ETHER_IPHDR); - if(!bp) + if(bp == 0) return; } @@ -391,6 +391,10 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) Block *bl, **l, *last, *prev; int ovlap, len, fragsize, pktposn; + /* Check lance has handed us a contiguous buffer */ + if(bp->next) + panic("ip: reass ?"); + src = nhgetl(ip->src); dst = nhgetl(ip->dst); id = nhgets(ip->id); @@ -407,7 +411,7 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) if(!ip->tos && (offset & ~(IP_MF|IP_DF)) == 0) { if(f != 0) { qlock(f); - ipfragfree(f); + ipfragfree(f, 1); } return(bp); } @@ -425,9 +429,6 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) f->dst = dst; f->blist = bp; - /* Check lance has handed us a contiguous buffer */ - if(bp->next) - panic("ip: reass ?"); qunlock(f); return 0; @@ -505,7 +506,7 @@ complete: last->flags |= S_DELIM; bl = f->blist; f->blist = 0; - ipfragfree(f); + ipfragfree(f, 1); ip = BLKIP(bl); hnputs(ip->length, len); @@ -518,7 +519,7 @@ complete: */ void -ipfragfree(Fragq *frag) +ipfragfree(Fragq *frag, int lockq) { Fragq *fl, **l; @@ -530,7 +531,8 @@ ipfragfree(Fragq *frag) frag->blist = 0; qunlock(frag); - qlock(&fraglock); + if(lockq) + qlock(&fraglock); l = &flisthead; for(fl = *l; fl; fl = fl->next) { @@ -544,7 +546,8 @@ ipfragfree(Fragq *frag) frag->next = fragfree; fragfree = frag; - qunlock(&fraglock); + if(lockq) + qunlock(&fraglock); } /* @@ -559,11 +562,9 @@ ipfragallo(void) while(fragfree == 0) { for(f = flisthead; f; f = f->next) if(canqlock(f)) { - qunlock(&fraglock); - ipfragfree(f); + ipfragfree(f, 0); break; } - qlock(&fraglock); } f = fragfree; fragfree = f->next;