mbuf question

Hooman Fazaeli hoomanfazaeli at gmail.com
Sun Mar 16 15:00:51 UTC 2014


On 3/16/2014 9:01 AM, Rui Paulo wrote:
> On 15 Mar 2014, at 16:13, Ian Lepore <ian at FreeBSD.org> wrote:
>> How about an optimization that puts tags in that area when it's
>> available to avoid the allocation overhead?  I don't know much about the
>> network code, so maybe that's not a sensible idea.
> The problem with mbuf tags is that they are not fixed size, so they can't easily use UMA (although they use malloc which is backed by UMA, but the performance is lower).  If tags are not an option, I suppose Hooman could use fields from struct pkthdr, but this might come with risks if the code is not in the tree.
>
> --
> Rui Paulo

pkthdrdoes not seem to have any spare area for custom use.

I wanted to add L2 filtering capabilities to pf(4) firewall, and the first problem
I faced was how to make L2 headers (src/dst ethernet addresses) available to pf.
That (seemingly) unused part of mbuf+cluster seemed a good place to store ethernet
headers.

We already have vlan tag (a sort of L2 data) in pkthdr. What do you think
about the idea of having a dedicated area for L2 information in mbufs?
Something like:

struct pkthdr {
     ...
     struct  {
         int      link_type;
         uint8_t  link_hdr[LINKHDR_MAXLEN];
         uint16_t link_vtag;
         ...
    } link;
    ...
}




-- 

Best regards.
Hooman Fazaeli



More information about the freebsd-hackers mailing list