Re: problems with modifying payload in iff_input_func
Re: problems with modifying payload in iff_input_func
- Subject: Re: problems with modifying payload in iff_input_func
- From: Brendan Creane <email@hidden>
- Date: Fri, 14 May 2010 13:05:55 -0700
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,
<email@hidden> wrote:
> Send Darwin-kernel mailing list submissions to
> email@hidden
>
> 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
> email@hidden
>
> You can reach the person managing the list at
> email@hidden
>
> 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 <email@hidden>
> To: ray dhurandhar <email@hidden>
> 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 <email@hidden>
> To: email@hidden
> 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 <email@hidden>
> To: email@hidden
> 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
> email@hidden
> http://lists.apple.com/mailman/listinfo/darwin-kernel
>
_______________________________________________
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