Subject: Re: Some observations about DMA segment count
To: None <itojun@iijlab.net>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-net
Date: 07/26/2001 12:29:07
On Fri, Jul 27, 2001 at 04:25:19AM +0900, itojun@iijlab.net wrote:

 > 	traditionally it was a requirement for the caller of the M_*SPACE to
 > 	check if the mbuf is under M_READONLY situation or not.  the check
 > 	is not normally made on the input path as we are sure it is not
 > 	shared on input path (WARNING: some packet filter directives, like
 > 	"duplicate this traffic", break the assumption).
 > 	the above change can choke certain code (which uses M_LEADINGSPACE when
 > 	doing some mbuf length computation, not just for playing with m_data
 > 	for example), IMHO.

...except M_LEADINGSPACE() was already making a (broken) read-only check...
it was checking M_EXT, and if that was set, was assuming the buffer was
read-only.  M_TRAILINGSPACE() was not making this check, assuming that the
buffer was always writable.

Seems like making M_LEADINGSPACE() and M_TRAILINGSPACE() perform these checks
is better, esp. considering the "duplicate this traffic" filter example you
cite.

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>