kern/165903: mbuf leak

Jeremy Chadwick jdc at koitsu.org
Wed Apr 17 21:40:57 UTC 2013


On Wed, Apr 17, 2013 at 01:17:40PM -0700, Jeremy Chadwick wrote:
> On Wed, Apr 17, 2013 at 05:38:12PM +0000, Chris Forgeron wrote:
> > Hello,
> > 
> >  I'm happy to report that the patch from Gleb has fixed the problem.
> > 
> >  My system had 256 mbuf clusters in use at boot, and after a day, still only has 256 mbuf clusters in use.
> > 
> >  From the patch, I see we are now dropping these packets (?) - Was the issue that the packets were being queued up for further work, but nothing was being done with them?
> 
> ...
> 
> At line 538, a call to mtod() is performed, which is what allocates the
> memory for the mbuf used for the ARP header.
>
> ...

John Baldwin let me know that this isn't quite correct -- mtod() is
actually just a macro which would turn this:

538         ah = mtod(m, struct arphdr *);

Into this:

538         ah = (struct arphdr *)(m)->m_data;

The actual mbuf allocation is done within the device driver (em(4) in
this case), while the freeing of the mbuf is done within the network
layer (if_ether.c in this case).

I lazily chose to man mtod and found it was filed under MBUF(9) and made
the assumption it did the allocation.  The actual allocation itself
looks to be MGET(9) and other friends.

-- 
| Jeremy Chadwick                                   jdc at koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Mountain View, CA, US                                            |
| Making life hard for others since 1977.             PGP 4BD6C0CB |


More information about the freebsd-stable mailing list