From owner-cvs-all@FreeBSD.ORG Wed Mar 26 06:37:13 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 683) id 938E137B404; Wed, 26 Mar 2003 06:37:13 -0800 (PST) Date: Wed, 26 Mar 2003 06:37:13 -0800 From: Eivind Eklund To: Maxime Henrion Message-ID: <20030326063713.B70548@FreeBSD.org> References: <200303250545.h2P5j5PM008552@repoman.freebsd.org> <20030324234234.T6129@odysseus.silby.com> <20030325222016.GF57674@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030325222016.GF57674@elvis.mu.org>; from mux@freebsd.org on Tue, Mar 25, 2003 at 11:20:16PM +0100 X-Spam-Status: No, hits=-32.5 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) cc: cvs-src@FreeBSD.org cc: Mike Silbersack cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/conf options src/sys/netinet ip_output.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Mar 2003 14:37:15 -0000 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.