Mbuf memory handling

Lino Sanfilippo lsanfil at marvell.com
Wed Feb 6 19:43:26 UTC 2013


John, Jacques,

thank you very much for your help. An mbuf cluster seems to be the right direction.
So I would have to do something like

mbuf = m_getjcl(how, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
left_for_next_rcv = m_split(mbuf, chunksize);
if_input(ifp, mbuf);

right?

>I agree that read-only buffers may be ok in this case but would like to point out that the M_WRITABLE() macro will evaluate to 0 if the refcount on the cluster is >1

The fact that the resulting mbufs returned by m_split() are not writeable any more is indeed a problem:
What I would like to do is keep the 'left_for_next_rcv' mbuf until the next packet arrives and
then fill it with the next packets data only up to 'chunksize', split it again to pass the new mbuf to
the protocol stack and so on until 'left_for_next_rcv' becomes too small to be splitted further.
Only then I would want to allocate a new "fresh" jumbo sized mbuf. Is it possible to
realize this with cluster mbufs?

Thx,
Lino




More information about the freebsd-hackers mailing list