__genl_sk_priv_get(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __genl_sk_priv_get β€” Kernel API Manual, bestie edition ✨

okay so picture this: we're deep in the kernel, in <pink>Kernel API Manual</pink> land, and there's this little function called __genl_sk_priv_get that's about to become your new hyperfixation. no cap. let's get into it 🫢


✨ NAME ✨

__genl_sk_priv_get β€” Get family private pointer for socket, if exists πŸŽ€

like, it goes and fetches the private pointer for a socket. if it exists. that "if exists" is doing a lot of heavy lifting, jsyk.


πŸ¦‹ SYNOPSIS πŸ¦‹

void * __genl_sk_priv_get (struct genl_family *family , struct sock *sk );

that's it. that's the whole vibe check. one return value, two args, zero drama. 🌸


πŸ’– ARGUMENTS πŸ’–

  • family β€” the family. literally just the family. a struct genl_family *, the Generic netlink family we're digging around in πŸ‘‘
  • sk β€” the socket. a struct sock *. the socket whose private stuff we're looking up 🧚

🌈 DESCRIPTION 🌈

so here's the tea β˜•: this function looks up a private memory for a Generic netlink family and the socket you specified. that's the whole job. family + socket β†’ private memory. mwah. πŸ’…

⚠️ but bestie, listen β€” the caller should make sure this is called in an RCU read locked section. that's not optional. that's not a suggestion. that's the rule. don't be the person who forgets the RCU read lock, i'm begging πŸ˜­πŸ™ˆ

⭐ RETURN ⭐

okay so what do you get back? three possible situations, and you need to know all of them:

  • a valid pointer on success β€” slay ✨
  • otherwise, a negative error value encoded by ERR_PTR πŸ’€
  • NULL in case priv does not exist 🫠

so like, check your return value properly. NULL is a real answer, not an error, and the error is a negative value wrapped up in ERR_PTR. two different things. don't conflate them, i'm on my knees 😭


πŸ”₯ SEE ALSO πŸ”₯

iykyk β€” go read the source, it's giving main character energy πŸ‘‘


and that's a wrap, bestie πŸŽ€βœ¨ this icon of a page came to you from the kernel source at ./net/netlink, dated October 2026, and it's literally the __genl_sk_priv_get(9) page, no cap. go forth and lock your RCU sections πŸ’–πŸ¦‹

πŸ“¦ where this page comes from