• 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
MT_HEADER mbufs and SO_NREAD interaction?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MT_HEADER mbufs and SO_NREAD interaction?


  • Subject: MT_HEADER mbufs and SO_NREAD interaction?
  • From: Matt Darland <email@hidden>
  • Date: Thu, 15 Feb 2007 15:59:17 -0600

I'm running into an interaction between a 3rd party 10GbE driver and the NREAD getsockopt() call.

My kext is reading data from the TCP/IP stack using the sock_receivembuf() KPI. The received mbuf chain eventually gets relayed to another kext via a kern_control socket (also read using sock_receivembuf). Since sock_receivembuf() requires that the caller specify the number of bytes to return in the mbuf chain, the client has to call the SO_NREAD getsockopt (which is unfortunate since kern_control sockets are PR_ATOMIC) to determine this value.

My problem occurs when the TCP/IP stack returns an mbuf chain in which one of the mbufs has a type of MT_HEADER. The SO_NREAD only counts MT_DATA mbufs in the total byte count causing SO_NREAD to return a short value of what is actually buffered. Since the kern_control socket is PR_ATOMIC, the first read will consume the entire record (but only return the short-count of data), and I've lost the remaining data.

My question: Is this a bug where the TCP/IP stack or the 10GbE driver shouldn't be returning MT_HEADER mbufs that are carrying data, or SO_NREAD being too selective about what it considers data?

From uipc_socket.c: sogetopt()
case SO_NREAD:
{
int pkt_total;
struct mbuf *m1;

pkt_total = 0;
m1 = so->so_rcv.sb_mb;
   if (so->so_proto->pr_flags & PR_ATOMIC)
{
while (m1) {
if (m1->m_type == MT_DATA)
pkt_total += m1->m_len;
m1 = m1->m_next;
}
optval = pkt_total;
} else
optval = so->so_rcv.sb_cc;
goto integer;
}

----
Thanks,
Matt

 _______________________________________________
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: MT_HEADER mbufs and SO_NREAD interaction?
      • From: Josh Graessley <email@hidden>
  • Prev by Date: Re: Darwin and Xen?
  • Next by Date: Re: MT_HEADER mbufs and SO_NREAD interaction?
  • Previous by thread: virtual display driver for USB Monitor
  • Next by thread: Re: MT_HEADER mbufs and SO_NREAD interaction?
  • Index(es):
    • Date
    • Thread