Re: problems with modifying payload in iff_input_func
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=u2YeCv2OQ3BHYJxncZjEfxdX0c2MNvjhr7iC96b9Vik=; b=t33DWbIOIqSpXHTwSzWdYFBZDpE3epMK2ERS38VySnmpCh5ImSUOtUzTh/Lq1HZGn4 j8xCcg2PD7zZaeabq0rA1ttLq+IRfmoZ3mI4gtpnRHnGkqgaTFNYxGRRHc7uYRKU4w/E hbcMvm2xtWl/KjO3h8vtvzOh3yB3So9WDwSgw= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=oHPbjXEtl1QD1ovnvemRE0svNRE5iAiCCcPVv84+XWRKENsHMxSgyhnOsZSNeebk5D ew7IiRFMtUluaE8D1yCsXeFJXi6hUTJ1z7O9vAM2KOOGBNIhd0Tw/n40xLzLamPJK65z rBssGSqd89yK/mMeXnJzoAE4PhvOy2T0s2ezk= I believe mbuf_copyback() will return a partial mbuf list if it fails to allocate enough buffer space for the modified packet. Since you're not passing in MBUF_WAITOK, I'm guessing you're leaking mbufs rapidly. Try calling mbuf_freem() if copyback fails. You can also get some insight into the failure using two machine debugging via ethernet or firewire. regards, Brendan Creane On Fri, May 14, 2010 at 12:02 PM, <darwin-kernel-request@lists.apple.com> wrote:
Send Darwin-kernel mailing list submissions to darwin-kernel@lists.apple.com
To subscribe or unsubscribe via the World Wide Web, visit http://lists.apple.com/mailman/listinfo/darwin-kernel or, via email, send a message with subject or body 'help' to darwin-kernel-request@lists.apple.com
You can reach the person managing the list at darwin-kernel-owner@lists.apple.com
When replying, please edit your Subject line so it is more specific than "Re: Contents of Darwin-kernel digest..."
Today's Topics:
1. Re: processor_info x86 perf. counters (Wade Tregaskis) 2. problems with modifying payload in iff_input_func (Andy Huang) 3. Using OSKextRequestResouce from kext init routine? (Ken Hornstein)
---------- Forwarded message ---------- From: Wade Tregaskis <wadeslists@mac.com> To: ray dhurandhar <raydhurandhar@gmail.com> Date: Thu, 13 May 2010 12:09:49 -0700 Subject: Re: processor_info x86 perf. counters
What's the best way to access the performance counters programmatically ?
It's not exactly programmatic, or at least not necessarily in the way you mean, but, Shark. Note however that Shark will not work on the open source kernel.
Wade
---------- Forwarded message ---------- From: Andy Huang <andy.y.huang@gmail.com> To: darwin-kernel@lists.apple.com Date: Thu, 13 May 2010 14:35:07 -0500 Subject: problems with modifying payload in iff_input_func Hi,
I am trying to modify enetlognke NKE, and in it I try to modify the payload inside enet_input_func(iff_input_ func). Here is my code: static errno_t enet_input_func(void* cookie, ifnet_t interface, protocol_family_t protocol, mbuf_t *data, char **frame_ptr) {
mbuf_t m = *data; u_int32_t mbufs = 0, bytes = 0, ip_hdr_len = 0, ip_pkt_len = 0; errno_t err; struct ip ip_hdr, *pIpHdr; char buf[BUF_SIZE];
/* check whether we have seen this packet previously */ if (CheckTag(*data, INBOUND_DONE)) { /* we have processed this packet previously since the INBOUND_DONE bit was set. bail on further processing */ return 0; }
if (protocol != AF_INET) { //printf("protocol = %d, don't process it\n", protocol); return 0; }
err = SetTag(*data, INBOUND_DONE); if (err != 0) { printf("Error - mbuf_tag_allocate returned an error %d\n", err); return err; // stops processing and will cause the mbuf_t to be released }
do { mbufs++; bytes += mbuf_len(m); m = mbuf_next(m); } while (m != NULL);
if (bytes < BUF_SIZE) // BUF_SIZE is the size of 4096 { printf("bytes(%d) < BUF_SIZE, don't process it\n", bytes); return 0; }
err = mbuf_copydata(*data, 0, bytes, buf); if (err != 0) { printf("Error - mbuf_copydata failed\n"); return 0; }
// modify the payload in the buf ..........
// copy back err = mbuf_copyback(*data, 0, bytes, buf, MBUF_DONTWAIT); if (err != 0) { printf("Error - mbuf_copyback for %d bytes returned an error %d\n", bytes, err); return err; }
return 0; }
The code works most of the time. But when the mac (10.6.3) goes to sleep and then wake up, after a while, it goes to either freeze or panic. Any help will be greatly appreciated.
---------- Forwarded message ---------- From: Ken Hornstein <kenh@pobox.com> To: darwin-kernel@lists.apple.com Date: Fri, 14 May 2010 14:48:47 -0400 Subject: Using OSKextRequestResouce from kext init routine? I'm having an issue with using OSKextRequestResouce(), specifically from my kext initialization routine.
This function is unfortunately not well documented (hey, if there's documentation for it, point me to it!), but ... it seems like you can't use it from a kext initialization routine. More specifically, you can't expect the callback to be called until after your initialization routine exits (actually, it's worse than that, from what I can tell; I have a bunch of kexts that depend on each other, and none of the callbacks are called until after they all finish loading and are started). Is my understanding correct? (I would guess that's more of a limitation in kextd).
--Ken
_______________________________________________ Darwin-kernel mailing list Darwin-kernel@lists.apple.com http://lists.apple.com/mailman/listinfo/darwin-kernel
_______________________________________________ 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)
-
Brendan Creane