ip: simplify code as packblock() and concatblock() will never error
This commit is contained in:
parent
75c6ab45e0
commit
055f837043
6 changed files with 13 additions and 38 deletions
|
@ -647,17 +647,7 @@ greiput(Proto *proto, Ipifc *, Block *bp)
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Can't delimit packet so pull it all into one block.
|
||||
*/
|
||||
if(qlen(c->rq) > GREqlen)
|
||||
freeb(bp);
|
||||
else{
|
||||
bp = concatblock(bp);
|
||||
if(bp == 0)
|
||||
panic("greiput");
|
||||
qpass(c->rq, bp);
|
||||
}
|
||||
qpass(c->rq, bp);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -923,17 +923,12 @@ ilpullup(Conv *s)
|
|||
bp->list = nil;
|
||||
dlen = nhgets(oh->illen)-IL_HDRSIZE;
|
||||
bp = trimblock(bp, IL_IPSIZE+IL_HDRSIZE, dlen);
|
||||
|
||||
/*
|
||||
* Upper levels don't know about multiple-block
|
||||
* messages so copy all into one (yick).
|
||||
*/
|
||||
bp = concatblock(bp);
|
||||
if(bp == 0)
|
||||
panic("ilpullup");
|
||||
bp = packblock(bp);
|
||||
if(bp == 0)
|
||||
panic("ilpullup2");
|
||||
qpass(s->rq, bp);
|
||||
qpass(s->rq, packblock(concatblock(bp)));
|
||||
}
|
||||
qunlock(&ic->outo);
|
||||
}
|
||||
|
|
|
@ -745,10 +745,7 @@ yes:
|
|||
/* tack on interface address */
|
||||
bp = padblock(bp, IPaddrlen);
|
||||
ipmove(bp->rp, ifc->lifc->local);
|
||||
bp = concatblock(bp);
|
||||
if(bp != nil)
|
||||
if(qpass(c->rq, bp) < 0)
|
||||
print("Q");
|
||||
qpass(c->rq, concatblock(bp));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -574,17 +574,16 @@ rudpiput(Proto *rudp, Ipifc *ifc, Block *bp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
if(bp->next)
|
||||
bp = concatblock(bp);
|
||||
|
||||
if(qfull(c->rq)) {
|
||||
netlog(f, Logrudp, "rudp: qfull %I.%d -> %I.%d\n", raddr, rport,
|
||||
laddr, lport);
|
||||
freeblist(bp);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
if(bp->next)
|
||||
bp = concatblock(bp);
|
||||
qpass(c->rq, bp);
|
||||
|
||||
}
|
||||
qunlock(ucb);
|
||||
}
|
||||
|
||||
|
|
|
@ -2437,10 +2437,7 @@ reset:
|
|||
* receive queue
|
||||
*/
|
||||
if(bp) {
|
||||
bp = packblock(bp);
|
||||
if(bp == nil)
|
||||
panic("tcp packblock");
|
||||
qpassnolim(s->rq, bp);
|
||||
qpassnolim(s->rq, packblock(bp));
|
||||
bp = nil;
|
||||
}
|
||||
tcb->rcv.nxt += length;
|
||||
|
|
|
@ -495,18 +495,15 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
|
|||
break;
|
||||
}
|
||||
|
||||
if(bp->next)
|
||||
bp = concatblock(bp);
|
||||
|
||||
if(qfull(c->rq)){
|
||||
qunlock(c);
|
||||
netlog(f, Logudp, "udp: qfull %I.%d -> %I.%d\n", raddr, rport,
|
||||
laddr, lport);
|
||||
freeblist(bp);
|
||||
return;
|
||||
} else {
|
||||
if(bp->next)
|
||||
bp = concatblock(bp);
|
||||
qpass(c->rq, bp);
|
||||
}
|
||||
|
||||
qpass(c->rq, bp);
|
||||
qunlock(c);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue