m_dup oddity -- creates mbuf chains with cluster containing 208 bytes of data

John-Mark Gurney gurney_j at resnet.uoregon.edu
Wed Dec 14 10:44:53 PST 2005


Ed Maste wrote this message on Wed, Dec 14, 2005 at 13:07 -0500:
> A colleague discovered an oddity with m_dup(9), in that duping an
> mbuf with 209 or more bytes of data creates a chain with 208 bytes
> of data in a cluster attached to the first mbuf, with the rest of
> the data chained on the end.
> 
> It seemed this behaviour appeared in v 1.130 of uipc_mbuf.c.  The
> patch below restores the behaviour of putting MCLBYTES into the
> initial mbuf cluster.
> 
> Comments?

Looks correct to me... I assume you've tested this?  If so, I'll commit
it..

> Index: uipc_mbuf.c
> ===================================================================
> RCS file: /usr/cvs/src/sys/kern/uipc_mbuf.c,v
> retrieving revision 1.159
> diff -u -u -3 -r1.159 uipc_mbuf.c
> --- uipc_mbuf.c 8 Dec 2005 13:13:05 -0000       1.159
> +++ uipc_mbuf.c 14 Dec 2005 15:54:06 -0000
> @@ -849,7 +849,8 @@
>                                 m_free(n);
>                                 goto nospace;
>                         }
> -                       nsize = MHLEN;
> +                       if ((n->m_flags & M_EXT) == 0)
> +                               nsize = MHLEN;
>                 }
>                 n->m_len = 0;

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-net mailing list