Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/in_cksum add code to dump the mbuf contents
details: https://anonhg.NetBSD.org/src/rev/5fee9e6ac2ce
branches: trunk
changeset: 341114:5fee9e6ac2ce
user: christos <christos%NetBSD.org@localhost>
date: Sun Oct 18 18:26:55 2015 +0000
description:
add code to dump the mbuf contents
diffstat:
tests/net/in_cksum/in_cksum.c | 53 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 2 deletions(-)
diffs (81 lines):
diff -r 83f665073530 -r 5fee9e6ac2ce tests/net/in_cksum/in_cksum.c
--- a/tests/net/in_cksum/in_cksum.c Sun Oct 18 17:13:32 2015 +0000
+++ b/tests/net/in_cksum/in_cksum.c Sun Oct 18 18:26:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_cksum.c,v 1.3 2015/01/06 21:36:38 joerg Exp $ */
+/* $NetBSD: in_cksum.c,v 1.4 2015/10/18 18:26:55 christos Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_cksum.c,v 1.3 2015/01/06 21:36:38 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_cksum.c,v 1.4 2015/10/18 18:26:55 christos Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@@ -99,6 +99,49 @@
return m;
}
+#ifdef MBUFDUMP
+static void
+dump_mbuf(const struct mbuf *m, int len, int off)
+{
+ int x = 0;
+ if (len <= 0)
+ return;
+
+ printf("Starting len=%d off=%d:\n", len, off);
+ if (off > 0) {
+ for (; m; m = m->m_next)
+ if (off > m->m_len)
+ off -= m->m_len;
+ else
+ break;
+ if (m == NULL || off > m->m_len)
+ errx(1, "out of data");
+ }
+
+ unsigned char *ptr = mtod(m, unsigned char *) + off;
+ unsigned char *eptr = ptr + m->m_len;
+ printf("[");
+ for (;;) {
+ if (ptr == eptr) {
+ m = m->m_next;
+ if (m == NULL)
+ errx(1, "out of data");
+ ptr = mtod(m, unsigned char *);
+ eptr = ptr + m->m_len;
+ printf("]\n[");
+ x = 0;
+ }
+ printf("%.2x ", *ptr++);
+ if (++x % 16 == 0)
+ printf("\n");
+ if (--len == 0)
+ break;
+ }
+ printf("]\n");
+ fflush(stdout);
+}
+#endif
+
static void
randomise_mbuf_chain(struct mbuf *m)
{
@@ -181,6 +224,12 @@
len -= off;
old_sum = portable_cpu_in_cksum(m, len, off, init_sum);
#ifdef HAVE_CPU_IN_CKSUM
+ if (len == 10041)
+ m = m->m_next;
+#ifdef MBUFDUMP
+ printf("m->m_len=%d len=%d off=%d\n", m->m_len, len, off);
+ dump_mbuf(m, len, off);
+#endif
new_sum = cpu_in_cksum(m, len, off, init_sum);
if (old_sum != new_sum)
errx(1, "comparison failed: %x %x", old_sum, new_sum);
Home |
Main Index |
Thread Index |
Old Index