sk_clone(9)
π 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 likeGFP_KERNEL,GFP_ATOMIC, etc. whatever your allocation vibes are rn βlockβ iftrue, the clonedskgets 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 π§:
sk_ns_capable(9)sk_capable(9)sk_net_capable(9)sk_set_memalloc(9)sk_alloc(9)skb_page_frag_refill(9)sk_wait_data(9)__sk_mem_raise_allocated(9)__sk_mem_schedule(9)__sk_mem_reduce_allocated(9)__sk_mem_reclaim(9)
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
- 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