Re: mbuf_outbound_finalize bug?
Re: mbuf_outbound_finalize bug?
- Subject: Re: mbuf_outbound_finalize bug?
- From: "Bhavesh Davda" <email@hidden>
- Date: Fri, 22 Dec 2006 09:58:54 -0800
Hi!
Your filter shouldn't assume that the headers are in a contiguous span;
instead, you should probably use mbuf_copydata() to be safe. In
addition,
your code above compares the result of mbuf_pkthdr_len() against the
*network* byte-order value of IP length; the ntohs() part should be
done before that check.
I compare the result of mbuf_pkthdr_len agains the network-byte-order
value of IP length on purpose, to know whether indeed the value of IP
length in the packet is *not* in host-byte-order, as I thought you
said mbuf_outbound_finalize() expects.
if (mbuf_copydata(*data, offset, sizeof (ip_len),
&ip_len) == 0) {
ip_len = ntohs(ip_len);
mbuf_copyback(*data, offset, sizeof (ip_len),
&ip_len, MBUF_WAITOK);
mbuf_outbound_finalize(*data, protocol,
sizeof (struct ether_header));
mbuf_copydata(*data, offset, sizeof
(ip_len), &ip_len);
ip_len = htons(ip_len);
mbuf_copyback(*data, offset, sizeof (ip_len),
&ip_len, MBUF_WAITOK);
Oh boy. This is going to get quite expensive to do on a per packet
basis. I thought I could simply get a pointer into the packet payload
to the IP length field in the IP header, and do a memory read/write,
rather than going through so many function calls and memcpy's, albeit
small (2 byte) ones.
Is there any other way to do it more optimally? I understand your
concern about non-linear mbufs, and not assuming that the IP header is
in the pkthdr mbuf. But realistically, is that ever going to be the
case?
Thanks!
--
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:
This email sent to email@hidden