Re: Easy mbuf_pullup Question (I hope)
Re: Easy mbuf_pullup Question (I hope)
- Subject: Re: Easy mbuf_pullup Question (I hope)
- From: Andrew Gallatin <email@hidden>
- Date: Tue, 6 Feb 2007 08:49:11 -0500 (EST)
Jun-ichiro itojun Hagino writes:
> > mbuf_pullup makes the data in an mbuf chain contiguous in a single
> > mbuf, if I understand correctly. mbuf_pullup documentation always
> > comes with the warning that if there is not sufficient space, it will
> > free the mbuf. However, that documentation never explains this
> > limitation in any further detail. How does one properly check to make
> > sure that mbuf_pullup is not going to fail due to insufficient space?
>
> i assume mbuf_pullup() means m_pullup() in traditional BSD kernel.
> if my assumption is wrong, please ignore me...
Yes. It is a "kpi" wrapper around m_pullup() so as to keep the kernel
module ABI the same, regardless of any internal changes made to mbufs.
> (1) memory shortage - you can't catch this case beforehand
> (2) you have requested too big bytes to m_pullup() - you can't request
> bytes > MLEN.
The limit is actually MHLEN. This is a kernel compile-time constant
outside the mbuf kpi. You can get this at runtime by calling
mbuf_stats(&x), and looking at x.mhlen. However, you need to be
prepared to deal with a low memory induced failure, especially since
m_pullup allocates its mbufs with M_DONTWAIT.
And always assume the mbuf that comes back is a totally new one, and
never reference the old one again. Else you'll be cursed with random,
hard to track down 'freeing free mbuf' panics like I was.
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden