• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ENOBUFS calling ctl_enqueuembuf
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ENOBUFS calling ctl_enqueuembuf


  • Subject: Re: ENOBUFS calling ctl_enqueuembuf
  • From: Adam Schepis <email@hidden>
  • Date: Tue, 14 Jan 2014 15:42:47 -0500

Thanks for the response Vincent.  I think you got me moving in the right direction!

I used ctl_getenqueuespace primarily to determine the size i had available (it is printed in a debug statement).  I doubled checked the size of my mbuf by adding a mbuf_len(send_buf) and verifying that it is smaller than 8192 (it is 24 bytes.) 

Next i realized that i had chained that mbuf to an mbuf given to me by the networking stack. I decided that this may be a bad idea since i dont technically "own" that mbuf.  Instead i called mbuf_dup on the data from the stack and chained my mbuf to that.  After doing that the ctl_enqueuembuf calls started working again.

i'm still a bit concerned that i haven't fixed the real issue and that somehow the queue just got cleared (i crashed it once while testing hastily) but as of now its working correctly.

Thanks,
Adam


On Tue, Jan 14, 2014 at 1:36 PM, Vincent Lubet <email@hidden> wrote:
Adam,

The code is calling ctl_getenqueuespace() but the returned "space" value is not used. Are you sure the size of the "data" mbuf is less than the value of "space"?

Vincent

On Jan 14, 2014, at 5:56 AM, Adam Schepis <email@hidden> wrote:

> I’m writing a socket filter and when communicating with my daemon i’m now receiving ENOBUFS whenever i call ctl_enqueuembuf
>
> i ran netstat -mm and get:
>
> class        buf   active   ctotal    total cache   cached uncached    memory
> name        size     bufs     bufs     bufs state     bufs     bufs     usage
> ---------- ----- -------- -------- -------- ----- -------- -------- ---------
> mbuf         256     1206      340     1376    on       46      124   85.0 KB
> cl          2048     1034       28     1062    on        2       26   56.0 KB
> bigcl       4096        2      310      312    on        0      310    1.2 MB
> 16kcl      16384        1        7        8    on        0        7  112.0 KB
> mbuf_cl     2304     1025     1034     1034    on        9        0    2.3 MB
> mbuf_bigcl  4352        0        2        2    on        2        0    8.5 KB
> mbuf_16kcl 16640        0        1        1    on        1        0   16.2 KB
>
> 1194/1206 mbufs in use:
>       1060 mbufs allocated to data
>       113 mbufs allocated to ancillary data
>       21 mbufs allocated to socket names and addresses
>       12 mbufs allocated to caches
> 1025/1062 mbuf 2KB clusters in use
> 0/312 mbuf 4KB clusters in use
> 0/8 mbuf 16KB clusters in use
> 3844 KB allocated to network (61.1% in use)
> 0 requests for memory denied
> 0 requests for memory delayed
> 0 calls to drain routines
>
> This output changes very little and persists even after reboot.
>
> ctl_getenqueuespace reliably returns 8196 bytes
>
> The dev machine i’m running is Mavericks running in VMWare Fusion (so i can debug kernel panics)
>
> here is a paste of the code in question:
>
> kern_return_t control_socket_enqueue(mbuf_t data) {
>    LOGDEBUG("%s\n", __PRETTY_FUNCTION__);
>    kern_return_t res = KERN_SUCCESS;
>    size_t space = 0;
>
>    if (accountability_ctl_active_conn == NULL) {
>        LOGDEBUG("NO CONTROL SOCKET ATTACHED\n");
>        res = KERN_INVALID_ARGUMENT;
>    }
>    else {
>        LOGDEBUG("ENQUEING MBUF. %llu(unit_id: %d)\n",
>                 (u_int64_t)accountability_ctl_active_conn,
>                 accountability_ctl_active_conn->sc_unit);
>
>        res = ctl_getenqueuespace(accountability_ctlref,
>                                  accountability_ctl_active_conn->sc_unit,
>                                  &space);
>        if (res) {
>            LOGDEBUG("failed to get space remaining in queue. err=%d\n", res);
>        }
>        else {
>            LOGDEBUG("free in queue: %d\n", (int)space);
>        }
>
>        mbuf_t send_buf;
>        res = mbuf_dup(data, MBUF_WAITOK, &send_buf);
>        if (res) {
>            LOGDEBUG("failed to copy mbuf. err=%d\n", res);
>        }
>        else {
>            res = ctl_enqueuembuf(accountability_ctlref, accountability_ctl_active_conn->sc_unit, send_buf, CTL_DATA_EOR);
>            if (res) {
>                LOGDEBUG("failed to enqueue data to control socket. err=%d\n", res);
>                mbuf_freem(send_buf);
>            }
>            else {
>                LOGDEBUG("successfully enqueued data to control socket.\n");
>            }
>        }
>    }
>    return res;
> }
>
>
> pretty confused at this point as i’m not sure why exactly ENOBUFS is being returned.  The only thing i’m certain of is that it is my fault!
> Any help for tutelage would be much appreciated.


 _______________________________________________
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

  • Follow-Ups:
    • Re: ENOBUFS calling ctl_enqueuembuf
      • From: Phil Jordan <email@hidden>
References: 
 >ENOBUFS calling ctl_enqueuembuf (From: Adam Schepis <email@hidden>)
 >Re: ENOBUFS calling ctl_enqueuembuf (From: Vincent Lubet <email@hidden>)

  • Prev by Date: Zone information for address
  • Next by Date: Meaning of '->' in kernel panic log
  • Previous by thread: Re: ENOBUFS calling ctl_enqueuembuf
  • Next by thread: Re: ENOBUFS calling ctl_enqueuembuf
  • Index(es):
    • Date
    • Thread