sock_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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:


✨ 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