1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>__skb_recv_datagram</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Networking and Network Devices APIs"><link rel="up" href="ch01s02.html" title="Socket Buffer Functions"><link rel="prev" href="API-lock-sock-fast.html" title="lock_sock_fast"><link rel="next" href="API-skb-kill-datagram.html" title="skb_kill_datagram"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">__skb_recv_datagram</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-lock-sock-fast.html">Prev</a> </td><th width="60%" align="center">Socket Buffer Functions</th><td width="20%" align="right"> <a accesskey="n" href="API-skb-kill-datagram.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API---skb-recv-datagram"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>__skb_recv_datagram — 2 Receive a datagram skbuff 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">struct sk_buff * <b class="fsfunc">__skb_recv_datagram </b>(</code></td><td>struct sock * <var class="pdparam">sk</var>, </td></tr><tr><td> </td><td>unsigned int <var class="pdparam">flags</var>, </td></tr><tr><td> </td><td>int * <var class="pdparam">peeked</var>, </td></tr><tr><td> </td><td>int * <var class="pdparam">off</var>, </td></tr><tr><td> </td><td>int * <var class="pdparam">err</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1096566900"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>sk</code></em></span></dt><dd><p> 4 socket 5 </p></dd><dt><span class="term"><em class="parameter"><code>flags</code></em></span></dt><dd><p> 6 MSG_ flags 7 </p></dd><dt><span class="term"><em class="parameter"><code>peeked</code></em></span></dt><dd><p> 8 returns non-zero if this packet has been seen before 9 </p></dd><dt><span class="term"><em class="parameter"><code>off</code></em></span></dt><dd><p> 10 an offset in bytes to peek skb from. Returns an offset 11 within an skb where data actually starts 12 </p></dd><dt><span class="term"><em class="parameter"><code>err</code></em></span></dt><dd><p> 13 error code returned 14 </p></dd></dl></div></div><div class="refsect1"><a name="idp1096572652"></a><h2>Description</h2><p> 15 Get a datagram skbuff, understands the peeking, nonblocking wakeups 16 and possible races. This replaces identical code in packet, raw and 17 udp, as well as the IPX AX.25 and Appletalk. It also finally fixes 18 the long standing peek and read race for datagram sockets. If you 19 alter this routine remember it must be re-entrant. 20 </p><p> 21 22 This function will lock the socket if a skb is returned, so the caller 23 needs to unlock the socket in that case (usually by calling 24 skb_free_datagram) 25 </p><p> 26 27 * It does not lock socket since today. This function is 28 * free of race conditions. This measure should/can improve 29 * significantly datagram socket latencies at high loads, 30 * when data copying to user space takes lots of time. 31 * (BTW I've just killed the last <code class="function">cli</code> in IP/IPv6/core/netlink/packet 32 * 8) Great win.) 33 * --ANK (980729) 34 </p><p> 35 36 The order of the tests when we find no data waiting are specified 37 quite explicitly by POSIX 1003.1g, don't change them without having 38 the standard around please. 39</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-lock-sock-fast.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01s02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-skb-kill-datagram.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">lock_sock_fast</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">skb_kill_datagram</span></td></tr></table></div></body></html> 40