Re: mbuf_outbound_finalize bug?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=K9Gs8+Kj1FDKlTsMjnlcJDYRY/224FG+8XZuueF6HrD9Oo/xkbVOQGcpgNxsN8ECjIFS7vtgnaKGje0GRO9zJrkN5SeKVpG3j2s0ITTv0jVHMBofGyKa5i4k4mGfFIEnsCFZ6gWkNo7XN1o55AHXc2rWDMaT5TuRw1xzQcOHC90= 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Bhavesh Davda