Subject: Re: disable m_dup()
To: Darren Reed <darrenr@reed.wattle.id.au>
From: None <itojun@iijlab.net>
List: tech-net
Date: 08/18/2000 23:15:57
>> 	the false assumption: if a mbuf has M_EXT bit raised,
>> 	m_ext.ext_siz == MCLBYTES (cluster memory region allocated via MCLGET).
>> 	the assumption does not hold
>So are you saying that code like this is wrong ?
>                MCLGET(m, M_DONTWAIT);
>                if ((m->m_flags & M_EXT) == 0) {
>                        m_freem(m);
>                        return ENOBUFS;
>                }
>                avail = (m->m_flags & M_EXT) ? MCLBYTES : MHLEN;
>If it is, what is correct here ?

	the safer way is (for the last line):
		m->m_len = 0;
		avail = M_TRAILINGSPACE(m);
	or
		avail = m->m_ext.ext_size;	/* less recommended */

	if you are sure that you have allocated cluster region with "MCLGET",
	you may be able to assume that it has m->m_ext.ext_size == MCLBYTES.
	however, if someone changes MCLGET code, you will be hosed.

itojun