Re: ENOBUFS calling ctl_enqueuembuf
Re: ENOBUFS calling ctl_enqueuembuf
- Subject: Re: ENOBUFS calling ctl_enqueuembuf
- From: Vincent Lubet <email@hidden>
- Date: Tue, 14 Jan 2014 10:36:47 -0800
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