diff --git a/usr.sbin/ppp/cbcp.c b/usr.sbin/ppp/cbcp.c index 446f4642b2f5..a901ef946a8a 100644 --- a/usr.sbin/ppp/cbcp.c +++ b/usr.sbin/ppp/cbcp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cbcp.c,v 1.9 1999/01/28 01:56:30 brian Exp $ + * $Id: cbcp.c,v 1.10 1999/02/26 21:28:07 brian Exp $ */ #include @@ -608,6 +608,7 @@ cbcp_Input(struct physical *p, struct mbuf *bp) struct cbcp *cbcp = &p->dl->cbcp; int len; + bp = mbuf_Contiguous(bp); len = mbuf_Length(bp); if (len < sizeof(struct cbcp_header)) { mbuf_Free(bp); diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 149087c496ea..db4be6d80812 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.39 1999/02/26 21:28:11 brian Exp $ + * $Id: fsm.c,v 1.40 1999/03/01 02:52:39 brian Exp $ * * TODO: */ @@ -826,6 +826,7 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) struct physical *p = link2physical(fp->link); u_short *sp, proto; + bp = mbuf_Contiguous(bp); sp = (u_short *)MBUF_CTOP(bp); proto = ntohs(*sp); log_Printf(fp->LogLevel, "%s: -- Protocol 0x%04x (%s) was rejected!\n", diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index ff509b8f35e2..894b2b37a6b6 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.38 1999/02/06 02:54:45 brian Exp $ + * $Id: hdlc.c,v 1.39 1999/02/11 10:14:08 brian Exp $ * * TODO: */ @@ -174,7 +174,7 @@ hdlc_Output(struct link *l, int pri, u_short proto, struct mbuf *bp) mhp->cnt += 2; } - mhp->next = bp; + mhp->next = bp = mbuf_Contiguous(bp); if (!p) { /* @@ -188,11 +188,7 @@ hdlc_Output(struct link *l, int pri, u_short proto, struct mbuf *bp) return; } - /* Tack mfcs onto the end, then set bp back to the start of the data */ - while (bp->next != NULL) - bp = bp->next; - bp->next = mfcs; - bp = mhp->next; + bp->next = mfcs; /* Tack mfcs onto the end */ p->hdlc.lqm.OutOctets += mbuf_Length(mhp) + 1; p->hdlc.lqm.OutPackets++; diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index ac3b54a5dbe8..79ab1cadbeaf 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.54 1998/11/10 00:32:39 brian Exp $ + * $Id: ip.c,v 1.55 1999/01/28 01:56:32 brian Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -553,7 +553,7 @@ ip_FlushPacket(struct link *l, struct bundle *bundle) for (queue = &ipcp->Queue[PRI_FAST]; queue >= ipcp->Queue; queue--) if (queue->top) { - bp = mbuf_Dequeue(queue); + bp = mbuf_Contiguous(mbuf_Dequeue(queue)); if (bp) { struct ip *pip = (struct ip *)MBUF_CTOP(bp); diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index ff17a243f8aa..82bf6df34ea0 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.30 1998/08/07 18:42:49 brian Exp $ + * $Id: lqr.c,v 1.31 1999/01/28 01:56:33 brian Exp $ * * o LQR based on RFC1333 * @@ -171,7 +171,7 @@ lqr_Input(struct physical *physical, struct mbuf *bp) len, (long)sizeof(struct lqrdata)); else if (!IsAccepted(physical->link.lcp.cfg.lqr) && !(physical->hdlc.lqm.method & LQM_LQR)) { - bp->offset -= 2; + bp->offset -= 2; /* XXX: We have a bit too much knowledge here ! */ bp->cnt += 2; lcp_SendProtoRej(physical->hdlc.lqm.owner, MBUF_CTOP(bp), bp->cnt); } else { @@ -179,6 +179,7 @@ lqr_Input(struct physical *physical, struct mbuf *bp) struct lcp *lcp; u_int32_t lastLQR; + bp = mbuf_Contiguous(bp); lqr = (struct lqrdata *)MBUF_CTOP(bp); lcp = physical->hdlc.lqm.owner; if (ntohl(lqr->MagicNumber) != physical->hdlc.lqm.owner->his_magic) diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c index fa9440685e47..0e29c81c14f7 100644 --- a/usr.sbin/ppp/mbuf.c +++ b/usr.sbin/ppp/mbuf.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.c,v 1.22 1998/08/25 17:48:42 brian Exp $ + * $Id: mbuf.c,v 1.23 1999/02/06 02:54:47 brian Exp $ * */ #include @@ -72,8 +72,7 @@ mbuf_Alloc(int cnt, int type) totalalloced += cnt; bp->size = bp->cnt = cnt; bp->type = type; - bp->pnext = NULL; - return (bp); + return bp; } struct mbuf * @@ -87,9 +86,10 @@ mbuf_FreeSeg(struct mbuf * bp) MemMap[bp->type].octets -= bp->size; totalalloced -= bp->size; free(bp); - return (nbp); + bp = nbp; } - return (bp); + + return bp; } void @@ -192,7 +192,6 @@ mbuf_Dequeue(struct mqueue *q) return bp; } - void mbuf_Enqueue(struct mqueue *queue, struct mbuf *bp) { @@ -204,3 +203,30 @@ mbuf_Enqueue(struct mqueue *queue, struct mbuf *bp) queue->qlen++; log_Printf(LogDEBUG, "mbuf_Enqueue: len = %d\n", queue->qlen); } + +struct mbuf * +mbuf_Contiguous(struct mbuf *bp) +{ + /* Put it all in one contigous (aligned) mbuf */ + + if (bp->next != NULL) { + struct mbuf *nbp; + u_char *cp; + + nbp = mbuf_Alloc(mbuf_Length(bp), bp->type); + + for (cp = MBUF_CTOP(nbp); bp; bp = mbuf_FreeSeg(bp)) { + memcpy(cp, MBUF_CTOP(bp), bp->cnt); + cp += bp->cnt; + } + bp = nbp; + } +#ifndef __i386__ /* Do any other archs not care about alignment ? */ + else if ((bp->offset & 0x03) != 0) { + bcopy(MBUF_CTOP(bp), bp + 1, bp->cnt); + bp->offset = 0; + } +#endif + + return bp; +} diff --git a/usr.sbin/ppp/mbuf.h b/usr.sbin/ppp/mbuf.h index 2517eda39ba4..1ee8e6fcb354 100644 --- a/usr.sbin/ppp/mbuf.h +++ b/usr.sbin/ppp/mbuf.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.h,v 1.13 1998/08/07 18:42:50 brian Exp $ + * $Id: mbuf.h,v 1.14 1998/08/21 18:10:15 brian Exp $ * * TODO: */ @@ -64,3 +64,4 @@ extern void mbuf_Log(void); extern int mbuf_Show(struct cmdargs const *); extern void mbuf_Enqueue(struct mqueue *, struct mbuf *); extern struct mbuf *mbuf_Dequeue(struct mqueue *); +extern struct mbuf *mbuf_Contiguous(struct mbuf *); diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c index ee5100ad1121..5c257bf3ab06 100644 --- a/usr.sbin/ppp/vjcomp.c +++ b/usr.sbin/ppp/vjcomp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vjcomp.c,v 1.24 1999/01/28 01:56:34 brian Exp $ + * $Id: vjcomp.c,v 1.25 1999/02/06 02:54:47 brian Exp $ * * TODO: */ @@ -60,14 +60,15 @@ vj_SendFrame(struct link *l, struct mbuf * bp, struct bundle *bundle) { int type; u_short proto; + struct ip *pip; u_short cproto = bundle->ncp.ipcp.peer_compproto >> 16; log_Printf(LogDEBUG, "vj_SendFrame: COMPPROTO = %x\n", bundle->ncp.ipcp.peer_compproto); - if (((struct ip *) MBUF_CTOP(bp))->ip_p == IPPROTO_TCP - && cproto == PROTO_VJCOMP) { - type = sl_compress_tcp(bp, (struct ip *)MBUF_CTOP(bp), - &bundle->ncp.ipcp.vj.cslc, + bp = mbuf_Contiguous(bp); + pip = (struct ip *)MBUF_CTOP(bp); + if (pip->ip_p == IPPROTO_TCP && cproto == PROTO_VJCOMP) { + type = sl_compress_tcp(bp, pip, &bundle->ncp.ipcp.vj.cslc, &bundle->ncp.ipcp.vj.slstat, bundle->ncp.ipcp.peer_compproto & 0xff); log_Printf(LogDEBUG, "vj_SendFrame: type = %x\n", type); @@ -101,6 +102,7 @@ VjUncompressTcp(struct ipcp *ipcp, struct mbuf * bp, u_char type) struct mbuf *nbp; u_char work[MAX_HDR + MAX_VJHEADER]; /* enough to hold TCP/IP header */ + bp = mbuf_Contiguous(bp); olen = len = mbuf_Length(bp); if (type == TYPE_UNCOMPRESSED_TCP) {