summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/mbuf.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-06-02 15:59:09 +0000
committerbrian <brian@FreeBSD.org>1999-06-02 15:59:09 +0000
commit424e32a4e7c02e7d5783e442834efc3956b3c9b9 (patch)
tree0b2a42f17bd7f967733eaf5f44d7a14ad8da23fb /usr.sbin/ppp/mbuf.c
parentf45463e353039436955b563e295ed6eabeab0a6c (diff)
downloadFreeBSD-src-424e32a4e7c02e7d5783e442834efc3956b3c9b9.zip
FreeBSD-src-424e32a4e7c02e7d5783e442834efc3956b3c9b9.tar.gz
o Alter the mbuf type as it's processed by different layers.
o Show more information about missing MP fragments in ``show mp''. o Do away with mbuf_Log(). It was showing mbuf stats twice on receipt of LCP/CCP/IPCP packets.... ???!!? o Pre-allocate a bit extra when creating LQR packets to avoid having to allocate another mbuf in mbuf_Prepend().
Diffstat (limited to 'usr.sbin/ppp/mbuf.c')
-rw-r--r--usr.sbin/ppp/mbuf.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c
index 1dea2e2..49969d1 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.25 1999/05/08 11:07:07 brian Exp $
+ * $Id: mbuf.c,v 1.26 1999/05/09 20:02:24 brian Exp $
*
*/
#include <sys/types.h>
@@ -39,7 +39,7 @@
static struct memmap {
struct mbuf *queue;
int fragments, octets;
-} MemMap[MB_MAX + 2];
+} MemMap[MB_MAX + 1];
static int totalalloced;
static unsigned long long mbuf_Mallocs, mbuf_Frees;
@@ -59,8 +59,10 @@ mbuf_Alloc(int cnt, int type)
{
struct mbuf *bp;
- if (type > MB_MAX)
+ if (type > MB_MAX) {
log_Printf(LogERROR, "Bad mbuf type %d\n", type);
+ type = MB_UNKNOWN;
+ }
bp = malloc(sizeof(struct mbuf) + cnt);
if (bp == NULL) {
log_Printf(LogALERT, "failed to allocate memory: %ld\n",
@@ -168,7 +170,7 @@ mbuf_Prepend(struct mbuf *bp, const void *ptr, size_t len, size_t extra)
bp->offset = 0;
}
- head = mbuf_Alloc(len + extra, bp ? bp->type : MB_FSM);
+ head = mbuf_Alloc(len + extra, bp ? bp->type : MB_UNKNOWN);
head->offset = extra;
head->cnt -= extra;
memcpy(MBUF_CTOP(head), ptr, len);
@@ -219,18 +221,24 @@ mbuf_Show(struct cmdargs const *arg)
{
int i;
static const char *mbuftype[] = {
- "async", "fsm", "cbcp", "hdlcout", "ipin", "echo", "lqr", "vjcomp",
- "ipq", "mp" };
+ "ip in", "ip out", "alias in", "alias out", "mp in", "mp out",
+ "vj in", "vj out", "icompd in", "icompd out", "compd in", "compd out",
+ "lqr in", "lqr out", "echo in", "echo out", "proto in", "proto out",
+ "acf in", "acf out", "sync in", "sync out", "hdlc in", "hdlc out",
+ "async in", "async out", "cbcp in", "cbcp out", "chap in", "chap out",
+ "pap in", "pap out", "ccp in", "ccp out", "ipcp in", "ipcp out",
+ "lcp in", "lcp out", "unknown"
+ };
prompt_Printf(arg->prompt, "Fragments (octets) in use:\n");
- for (i = 1; i < MB_MAX; i += 2)
+ for (i = 0; i < MB_MAX; i += 2)
prompt_Printf(arg->prompt, "%10.10s: %04d (%06d)\t%10.10s: %04d (%06d)\n",
- mbuftype[i-1], MemMap[i].fragments, MemMap[i].octets, mbuftype[i],
- MemMap[i+1].fragments, MemMap[i+1].octets);
+ mbuftype[i], MemMap[i].fragments, MemMap[i].octets,
+ mbuftype[i+1], MemMap[i+1].fragments, MemMap[i+1].octets);
if (i == MB_MAX)
prompt_Printf(arg->prompt, "%10.10s: %04d (%06d)\n",
- mbuftype[i-1], MemMap[i].fragments, MemMap[i].octets);
+ mbuftype[i], MemMap[i].fragments, MemMap[i].octets);
prompt_Printf(arg->prompt, "Mallocs: %qu, Frees: %qu\n",
mbuf_Mallocs, mbuf_Frees);
@@ -238,18 +246,6 @@ mbuf_Show(struct cmdargs const *arg)
return 0;
}
-void
-mbuf_Log()
-{
- log_Printf(LogDEBUG, "mbuf_Log: mem alloced: %d\n", totalalloced);
- log_Printf(LogDEBUG, "mbuf_Log: 1: %d 2: %d 3: %d 4: %d\n",
- MemMap[1].octets, MemMap[2].octets, MemMap[3].octets, MemMap[4].octets);
- log_Printf(LogDEBUG, "mbuf_Log: 5: %d 6: %d 7: %d 8: %d\n",
- MemMap[5].octets, MemMap[6].octets, MemMap[7].octets, MemMap[8].octets);
- log_Printf(LogDEBUG, "mbuf_Log: 9: %d 10: %d 11: %d\n",
- MemMap[9].octets, MemMap[10].octets, MemMap[11].octets);
-}
-
struct mbuf *
mbuf_Dequeue(struct mqueue *q)
{
@@ -313,3 +309,16 @@ mbuf_Contiguous(struct mbuf *bp)
return bp;
}
+
+void
+mbuf_SetType(struct mbuf *bp, int type)
+{
+ for (; bp; bp = bp->next)
+ if (type != bp->type) {
+ MemMap[bp->type].fragments--;
+ MemMap[bp->type].octets -= bp->size;
+ bp->type = type;
+ MemMap[type].fragments++;
+ MemMap[type].octets += bp->size;
+ }
+}
OpenPOWER on IntegriCloud