sock_alloc(9)
β¨ sock_alloc(9) β¨ β from the Kernel API Manual, bestie π
Okay so picture this: you're deep in kernel land, you need a socket, and you don't have one yet. That's literally the whole plot of this page. Let's go π«Ά
πΈ SYNOPSIS πΈ
struct socket * sock_alloc (void );
π ARGUMENTS π
voidβ no arguments, bestie. Nothing. Zero. Nada. It takes no input whatsoever, so don't come for it with parameters, it's not that kind of function π
π DESCRIPTION π
So what it does is: it allocates a brand new inode and a brand new socket object, and the two of them are bound together and initialised. Like, they're a matched set now. Iconic duo behaviour π
Then the socket gets returned to you. That's it, that's the gift π
β οΈ But listen β if we're all out of inodes, you get NULL back. Not a socket. Nothing. So please, for the love of everything, check your return value, bestie π
Also, lowkey important: this function uses GFP_KERNEL internally. That's just facts, no cap.
π¦ SEE ALSO π¦
Like, go read the whole friend group honestly β they're all in Kernel file ./net/socket.c:
move_addr_to_kernel(9)move_addr_to_user(9)sock_read_xattr(9)sock_alloc_file(9)sock_from_file(9)sockfd_lookup(9)sock_release(9)sock_sendmsg(9)kernel_sendmsg(9)sock_recvmsg(9)kernel_recvmsg(9)sock_create_lite(9)__sock_create(9)sock_create(9)sock_create_kern(9)sock_register(9)sock_unregister(9)kernel_bind(9)kernel_listen(9)kernel_accept(9)kernel_connect(9)kernel_getsockname(9)kernel_getpeername(9)kernel_sock_shutdown(9)kernel_sock_ip_overhead(9)
β¨ k bye ily, this page lives in ./net and it's timestamped October 2026 β signed, sealed, delivered, sock_alloc(9) πβ¨
π¦ 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