From db5c4ca34559582b057d407858cf99546e09419a Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Mon, 31 Dec 2012 13:45:15 +0000 Subject: Extend the sbcheck() function to make it work with socket buffers containing m_nextpkt chains. OK markus@ --- sys/kern/uipc_socket2.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 7a04f0d4c12..bd9a9e739d2 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket2.c,v 1.53 2012/04/13 09:38:32 deraadt Exp $ */ +/* $OpenBSD: uipc_socket2.c,v 1.54 2012/12/31 13:45:14 bluhm Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* @@ -573,16 +573,18 @@ sbappendstream(struct sockbuf *sb, struct mbuf *m) void sbcheck(struct sockbuf *sb) { - struct mbuf *m; + struct mbuf *m, *n; u_long len = 0, mbcnt = 0; - for (m = sb->sb_mb; m; m = m->m_next) { - len += m->m_len; - mbcnt += MSIZE; - if (m->m_flags & M_EXT) - mbcnt += m->m_ext.ext_size; - if (m->m_nextpkt) - panic("sbcheck nextpkt"); + for (m = sb->sb_mb; m; m = m->m_nextpkt) { + for (n = m; n; n = n->m_next) { + len += n->m_len; + mbcnt += MSIZE; + if (n->m_flags & M_EXT) + mbcnt += n->m_ext.ext_size; + if (m != n && n->m_nextpkt) + panic("sbcheck nextpkt"); + } } if (len != sb->sb_cc || mbcnt != sb->sb_mbcnt) { printf("cc %lu != %lu || mbcnt %lu != %lu\n", len, sb->sb_cc, -- cgit v1.2.3