__skb_try_recv_datagram(9)
β¨ NAME β¨
__skb_try_recv_datagram β Receive a datagram skbuff π
okay bestie, this is a page from the Kernel API Manual (section 9), and weβre talking about __skb_try_recv_datagram. Itβs giving βdatagram skbuff receiverβ and itβs lowkey iconic. π
π¦ SYNOPSIS π¦
struct sk_buff * __skb_try_recv_datagram (struct sock *sk , struct
sk_buff_head *queue , unsigned int flags , int *off , int *err , struct
sk_buff **last );
π ARGUMENTS π
skβ socketqueueβ socket queue from which to receiveflagsβMSG_flagsoffβ an offset in bytes to peek skb from. Returns an offset within an skb where data actually startserrβ error code returnedlastβ set to last peeked message to inform the wait function what to look for when peeking
β¨ DESCRIPTION β¨
Get a datagram skbuff, bestie. This function understands the peeking, the nonblocking wakeups, and the possible races. It replaces identical code in packet, raw and udp, as well as the IPX AX.25 and Appletalk. It also finally fixes the long standing peek and read race for datagram sockets. π«Ά
β οΈ If you alter this routine remember it must be re-entrant. No cap.
This function will lock the socket if a skb is returned, so the caller needs to unlock the socket in that case (usually by calling skb_free_datagram). Returns NULL with err set to -EAGAIN if no data was available or to some other value if an error was detected. π
The original author note is very much part of the lore:
βIt does not lock socket since today. This function is free of race conditions. This measure should/can improve significantly datagram socket latencies at high loads, when data copying to user space takes lots of time. (BTW I've just killed the last cli in IP/IPv6/core/netlink/packet 8) Great win.) --ANK (980729)β
The order of the tests when we find no data waiting are specified quite explicitly by POSIX 1003.1g, don't change them without having the standard around please. π
π₯ SEE ALSO π₯
Kernel file ./net/core/datagram.c says hi to these besties:
skb_kill_datagram(9)skb_copy_and_crc32c_datagram_iter(9)skb_copy_datagram_iter(9)skb_copy_datagram_from_iter(9)zerocopy_sg_from_iter(9)skb_copy_and_csum_datagram(9)skb_copy_and_csum_datagram_msg(9)datagram_poll_queue(9)datagram_poll(9)
byeee bestie β sourced from ./net/core, dated October 2026, for __skb_try_recv_datagram(9) in the Kernel API Manual ππβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms