summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2004-09-28 18:40:18 +0000
committerjmg <jmg@FreeBSD.org>2004-09-28 18:40:18 +0000
commit0d1f936e786e73bd039b6c59438d854bdbe9be0c (patch)
tree1f81477be87de6e5071e81d84c523f851be8d253 /sys/kern/uipc_mbuf.c
parent2f2f7359cc2aba3a3344e8b341e920fdcb52a1e1 (diff)
downloadFreeBSD-src-0d1f936e786e73bd039b6c59438d854bdbe9be0c.zip
FreeBSD-src-0d1f936e786e73bd039b6c59438d854bdbe9be0c.tar.gz
improve the mbuf m_print function.. Only pull length from pkthdr if there
is one, detect mbuf loops and stop, add an extra arg so you can only print the first x bytes of the data per mbuf (print all if arg is -1), print flags using %b (bitmask)... No code in the tree appears to use m_print, and it's just a maner of adding -1 as an additional arg to m_print to restore original behavior.. MFC after: 4 days
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a1449d8..1c2e410 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -995,18 +995,33 @@ m_getptr(struct mbuf *m, int loc, int *off)
}
void
-m_print(const struct mbuf *m)
+m_print(const struct mbuf *m, int maxlen)
{
int len;
+ int pdata;
const struct mbuf *m2;
- len = m->m_pkthdr.len;
+ if (m->m_flags & M_PKTHDR)
+ len = m->m_pkthdr.len;
+ else
+ len = -1;
m2 = m;
- while (len) {
- printf("%p %*D\n", m2, m2->m_len, (u_char *)m2->m_data, "-");
- len -= m2->m_len;
+ while (m2 != NULL && (len == -1 || len)) {
+ pdata = m2->m_len;
+ if (maxlen != -1 && pdata > maxlen)
+ pdata = maxlen;
+ printf("mbuf: %p len: %d, next: %p, %b%s", m2, m2->m_len,
+ m2->m_next, m2->m_flags, "\20\20freelist\17skipfw"
+ "\11proto5\10proto4\7proto3\6proto2\5proto1\4rdonly"
+ "\3eor\2pkthdr\1ext", pdata ? "" : "\n");
+ if (pdata)
+ printf(", %*D\n", m2->m_len, (u_char *)m2->m_data, "-");
+ if (len != -1)
+ len -= m2->m_len;
m2 = m2->m_next;
}
+ if (len > 0)
+ printf("%d bytes unaccounted for.\n", len);
return;
}
OpenPOWER on IntegriCloud