ref: 857f2528e0b014b6bd839535daaa6b53853703d9
parent: ea993877a96cd535199d0cd437e49f8d616615d9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Nov 7 17:05:29 EST 2016
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.
--- a/sys/src/9/ip/arp.c
+++ b/sys/src/9/ip/arp.c
@@ -375,7 +375,7 @@
}
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);
--- a/sys/src/9/ip/devip.c
+++ b/sys/src/9/ip/devip.c
@@ -1195,9 +1195,6 @@
if(c->wq == nil)
error(Eperm);
- if(bp->next)
- bp = concatblock(bp);
-
return qbwrite(c->wq, bp);
default:
return devbwrite(ch, bp, offset);
--- a/sys/src/9/ip/ethermedium.c
+++ b/sys/src/9/ip/ethermedium.c
@@ -298,8 +298,6 @@
/* 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;
--- a/sys/src/9/ip/ip.c
+++ b/sys/src/9/ip/ip.c
@@ -208,7 +208,7 @@
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 @@
lid = incref(&ip->id4);
offset = IP4HDR;
- while(xp != nil && offset && offset >= BLEN(xp)) {
+ while(offset && offset >= BLEN(xp)) {
offset -= BLEN(xp);
xp = xp->next;
}
--- a/sys/src/9/ip/ipv6.c
+++ b/sys/src/9/ip/ipv6.c
@@ -118,7 +118,7 @@
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 @@
xp = bp;
offset = uflen;
- while (xp && offset && offset >= BLEN(xp)) {
+ while (offset && offset >= BLEN(xp)) {
offset -= BLEN(xp);
xp = xp->next;
}
--- a/sys/src/9/ip/netdevmedium.c
+++ b/sys/src/9/ip/netdevmedium.c
@@ -86,8 +86,6 @@
{
Netdevrock *er = ifc->arg;
- if(bp->next)
- bp = concatblock(bp);
if(BLEN(bp) < ifc->mintu)
bp = adjustblock(bp, ifc->mintu);
--- a/sys/src/9/ip/pktmedium.c
+++ b/sys/src/9/ip/pktmedium.c
@@ -51,7 +51,6 @@
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);