sock_create_lite(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– sock_create_lite πŸ’–

okay so bestie, welcome to the Kernel API Manual, and today's main character is sock_create_lite(9) β€” yes she's a function, yes she makes a socket, and yes she's a little bit of a lite version (the name is literally telling you something, keep reading πŸ‘€).


✨ NAME ✨

sock_create_lite β€” creates a socket 🫢


✨ SYNOPSIS ✨

int sock_create_lite (int family , int type , int protocol , struct
socket **res );

like. four args. all int except the last one which is a double-pointer to a struct socket because we're doing the assign-it-for-you thing πŸ’…


✨ ARGUMENTS ✨

  • family β€” the protocol family, aka the vibe of the address world you're living in (AF_INET, ...)
  • type β€” the communication type, aka how this socket talks (SOCK_STREAM, ...)
  • protocol β€” the protocol, and honestly you can pass 0 a lot of the time (0, ...)
  • res β€” the new socket πŸŽ€ this is where the freshly made socket gets dropped off

✨ DESCRIPTION ✨

okay so here's the tea πŸ“: sock_create_lite creates a brand-new socket and assigns it to res, passing through LSM on the way. very demure, very security-conscious.

But β€” and this is the important part, don't skip it β€” the new socket's initialization is not complete. like, she's not finished getting ready. for the rest of the story you gotta look at kernel_accept.

she returns 0 or an error. that's it, that's the contract. on failure, res is set to NULL (so like, don't go dereferencing it, bestie 😭).

also, fun fact: this function internally uses GFP_KERNEL ✨

ngl the "initialization is not complete" bit is the one you actually have to remember. a lite socket is lite for a reason β€” check kernel_accept before you assume she's fully cooked πŸ”₯

✨ SEE ALSO ✨

the whole group chat, fr fr β€” go read these next:

and the kernel file she actually lives in: ./net/socket.c πŸ‘‘


k that's the whole page, ily, go write some kernel code responsibly πŸ’œ

shoutout to the ./net source and the October 2026 date stamp β€” that's the footer energy, periodt. 🌈⭐

πŸ“¦ where this page comes from