ip: always pass a single block to Medium.bwrite(), avoid concatblock() calls in Dev.bwrite()

the convention for Dev.bwrite() is that it accepts a *single* block,
and not a block chain. so we never have concatblock here.

to keep stuff consistent, we also guarantee thet Medium.bwrite()
will get a *single* block passed as well, as the callers are
few in number.
This commit is contained in:
cinap_lenrek 2016-11-07 22:05:29 +01:00
parent ea993877a9
commit 857f2528e0
7 changed files with 5 additions and 13 deletions

View file

@ -375,7 +375,7 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh)
}
rlock(ifc);
if(ifc->m != nil)
ifc->m->bwrite(ifc, bp, version, ip);
ifc->m->bwrite(ifc, concatblock(bp), version, ip);
else
freeblist(bp);
runlock(ifc);

View file

@ -1195,9 +1195,6 @@ ipbwrite(Chan* ch, Block* bp, ulong offset)
if(c->wq == nil)
error(Eperm);
if(bp->next)
bp = concatblock(bp);
return qbwrite(c->wq, bp);
default:
return devbwrite(ch, bp, offset);

View file

@ -298,8 +298,6 @@ etherbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip)
/* make it a single block with space for the ether header */
bp = padblock(bp, ifc->m->hsize);
if(bp->next)
bp = concatblock(bp);
if(BLEN(bp) < ifc->mintu)
bp = adjustblock(bp, ifc->mintu);
eh = (Etherhdr*)bp->rp;

View file

@ -208,7 +208,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
eh->cksum[0] = 0;
eh->cksum[1] = 0;
hnputs(eh->cksum, ipcsum(&eh->vihl));
ifc->m->bwrite(ifc, bp, V4, gate);
ifc->m->bwrite(ifc, concatblock(bp), V4, gate);
runlock(ifc);
poperror();
return 0;
@ -240,7 +240,7 @@ if((eh->frag[0] & (IP_DF>>8)) && !gating) print("%V: DF set\n", eh->dst);
lid = incref(&ip->id4);
offset = IP4HDR;
while(xp != nil && offset && offset >= BLEN(xp)) {
while(offset && offset >= BLEN(xp)) {
offset -= BLEN(xp);
xp = xp->next;
}

View file

@ -118,7 +118,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
medialen = ifc->maxtu - ifc->m->hsize;
if(len <= medialen) {
hnputs(eh->ploadlen, len - IP6HDR);
ifc->m->bwrite(ifc, bp, V6, gate);
ifc->m->bwrite(ifc, concatblock(bp), V6, gate);
runlock(ifc);
poperror();
return 0;
@ -161,7 +161,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
xp = bp;
offset = uflen;
while (xp && offset && offset >= BLEN(xp)) {
while (offset && offset >= BLEN(xp)) {
offset -= BLEN(xp);
xp = xp->next;
}

View file

@ -86,8 +86,6 @@ netdevbwrite(Ipifc *ifc, Block *bp, int, uchar*)
{
Netdevrock *er = ifc->arg;
if(bp->next)
bp = concatblock(bp);
if(BLEN(bp) < ifc->mintu)
bp = adjustblock(bp, ifc->mintu);

View file

@ -51,7 +51,6 @@ static void
pktbwrite(Ipifc *ifc, Block *bp, int, uchar*)
{
/* enqueue onto the conversation's rq */
bp = concatblock(bp);
if(ifc->conv->snoopers.ref > 0)
qpass(ifc->conv->sq, copyblock(bp, BLEN(bp)));
qpass(ifc->conv->rq, bp);