Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Jun 2002 12:55:53 -0700 (PDT)
From:      Archie Cobbs <archie@dellroad.org>
To:        freebsd-net@freebsd.org
Subject:   m->m_pkthdr.header
Message-ID:  <200206071955.g57JtrJ65814@arch20m.dellroad.org>

next in thread | raw e-mail | index | archive | help
Hi,

I'd like to get rid of this mbuf field "m->m_pkthdr.header".
Here are my reasons:

 - It's broken. Consider this code:

     copy = m_copypacket(m);
     m_freem(m);

   Typically m->m_pkthdr.header points into the data area of 'm'.
   So now copy->m_pkthdr.header points at the same data, which has
   already been freed and possibly reused.

 - It is an obscure thing most people don't know about and is
   ripe for causing hard to find bugs.

 - It's only used in two places, (a) for secret communication between
   the oltr driver and if_ether.c, and (b) as a temporary variable
   in ip_input.c:

    $ find . -type f -print | xargs grep -w m_pkthdr.header
    ./contrib/dev/oltr/if_oltr.c:      m0->m_pkthdr.header = (void *)th;
    ./netinet/if_ether.c:    th = (struct iso88025_header *)m->m_pkthdr.header;
    ./netinet/ip_input.c:    m->m_pkthdr.header = ip;
    ./netinet/ip_input.c:#define GETIP(m)   ((struct ip*)((m)->m_pkthdr.header))

My proposal:

   - Replace the obfuscating GETIP() macro in ip_input.c with a variable.
   - Rejigger the oltr driver to pass its "secret" information using
     an auxillary mbuf instead of m->m_pkthdr.header.

Any comments/objections?

Thanks,
-Archie

__________________________________________________________________________
Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206071955.g57JtrJ65814>