Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Mar 2003 06:37:13 -0800
From:      Eivind Eklund <eivind@FreeBSD.org>
To:        Maxime Henrion <mux@freebsd.org>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/conf options src/sys/netinet ip_output.c
Message-ID:  <20030326063713.B70548@FreeBSD.org>
In-Reply-To: <20030325222016.GF57674@elvis.mu.org>; from mux@freebsd.org on Tue, Mar 25, 2003 at 11:20:16PM %2B0100
References:  <200303250545.h2P5j5PM008552@repoman.freebsd.org> <20030324234234.T6129@odysseus.silby.com> <20030325222016.GF57674@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Mar 25, 2003 at 11:20:16PM +0100, Maxime Henrion wrote:
> I think we should have some code like this before handing a packet to a
> network driver :
> 
> KASSERT(m0->m_pkthdr.len == m_length(m0, NULL), ("Bad packet header"));

This is a structure invariant check, and I'm strongly in favour of those -
however, I'd prefer if the logic for the invariant itself was located in
only one place.

Ie, define in a header (use of inline function instead of #define to avoid
problems with multiple evaluation of m):
static inline mbuf_invariant(struct mbuf *m) {
	return m->m.pkthdr.len == m_length(m, NULL);
}

then do
KASSERT(mbuf_invariant(m), ("Bad packet header");

Eivind.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030326063713.B70548>