sk_clone(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sk_clone(9) β€” the Kernel API Manual moment πŸŽ€

okay so bestie, welcome to sk_clone(9), aka the little page where the kernel clones a socket for you. yes, clones it. main character energy but make it struct sock. let's go ✨


✨ NAME ✨

sk_clone β€” clone a socket 🫢


🌸 SYNOPSIS 🌸

struct sock *sk_clone(const struct sock *sk, const gfp_t priority, bool lock);

like… three args, one socket, zero drama (until you forget to unlock it, but we'll get there πŸ’€)


πŸ¦‹ ARGUMENTS πŸ¦‹

  • sk β€” the socket you wanna clone, bestie. the original. the blueprint. the source material πŸ‘‘
  • priority β€” the allocation priority, so like GFP_KERNEL, GFP_ATOMIC, etc. whatever your allocation vibes are rn ⭐
  • lock β€” if true, the cloned sk gets locked. periodt πŸ”’

πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜•: if lock is true, the clone is locked by bh_lock_sock, and ngl the caller must unlock the socket β€” even in the error path β€” by calling bh_unlock_sock.

lowkey the important part: error path is still a path. you still gotta unlock. no skipping. not me letting you leak a locked socket πŸ™ˆ

🌈 SEE ALSO 🌈

peep the kernel file ./net/core/sock.c and all these icons 🧚:


that's the whole vibe, bestie β€” go forth and clone responsibly πŸ’…βœ¨

shoutout to ./net/core for the source, dated October 2026 β€” and hey, this was sk_clone(9), ty for coming to my ted talk πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from