Re: Networking: mbuf->m_hdr.mh_data doesn't include DLIL header?
Re: Networking: mbuf->m_hdr.mh_data doesn't include DLIL header?
- Subject: Re: Networking: mbuf->m_hdr.mh_data doesn't include DLIL header?
- From: Josh Graessley <email@hidden>
- Date: Mon, 18 Sep 2006 14:48:11 -0700
The packet header field is a big disaster.
When an ethernet driver inputs a packet it usually:
- has the whole packet copied in to the mbuf
- Sets the mbuf's packet header to point to where the ethernet frame
starts in the mbuf
- uses mbuf_adj or something similar to move the start of the mbuf
pointer to the end of the ethernet header
If you're doing to use mbuf_dup on one of these packets your best bet
is probably to:
- mbuf_prepend for the length of the ethernet header
- copy the ethernet header in to the preceeding space you just
created using mbuf_prepend
- duplicate the packet
- set the packet header's header field to the mbuf_data value
- mbuf_adj for the size of the ethernet header
If there was one thing I could undo it would be the wacky way in
which this header stuff is handled. It is especially frustrating when
you're working with interface filters. On the outbound path, you get
the entire packet in the mbuf chain. On the inbound path, the
ethernet header is separate, in the packet header's header field. It
usually points to some place in the allocated space for the first
mbuf, but there are no guarantees this will be the case.
-josh
On Sep 18, 2006, at 1:46 PM, Bhavesh Davda wrote:
For certain packets that my iff_input_func is receiving, when I looked
at the entire mbuf structure received in parameter 4, I noticed that
the m_hdr.mh_data field offsets 14 bytes beyond the start of the
ethernet frame.
This is causing my mbuf_dup() cloned mbuf to not contain the 14 bytes
of ethernet header in my NKE.
Looking in the original mbuf received in my iff_input_func, the 14
bytes of ethernet header are in the mbuf body at
mbuf->M_dat.MH.MH_dat.MH_databuf[0..13].
What am I doing wrong? How do I clone the mbuf to include the DLIL
header?
Thanks!
- Bhavesh
--
Bhavesh P. Davda
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden