handshake_req_submit(9)
β¨ handshake_req_submit(9) β¨
okay so this is a page from the Kernel API Manual β section 9, bestie, we're in kernel-internals territory π β and honestly? it's giving "one function, a LOT of emotional weight." Stay with me.
π NAME π
handshake_req_submit β literally just submit a handshake request. that's the whole vibe. π«Ά
πΈ SYNOPSIS πΈ
int handshake_req_submit (struct socket *sock , struct handshake_req
*req , gfp_t flags );
π¦ ARGUMENTS π¦
sockβ the open socket where the handshake is gonna happen. it has to be open, okay? this is not a "make it work anyway" situation β¨reqβ the handshake arguments π like, the whole point of the callflagsβ memory allocation flags. yes thegfp_tones. no i will not elaborate, they're flags, they flag π©
π DESCRIPTION π
okay so here's the return-value tea, and ngl there is a LOT of it, so buckle up π
Return values:
0β Request queued π-EINVALβ Invalid argument π-EBUSYβ A handshake is already under way for this socket π (it's occupied, respectfully back off)-ESRCHβ No handshake agent is available π (nobody's home)-EAGAINβ Too many pending handshake requests π« (the queue said "no more")-ENOMEMβ Failed to allocate memory π΅βπ«-EMSGSIZEβ Failed to construct notification message π-EOPNOTSUPPβ Handshake module not initialized β οΈ (the module didn't even show up)
the way that a zero return value from handshake_req_submit means that exactly one subsequent completion callback is guaranteed β exactly one, bestie, not zero, not two, ONE π that's the contract, periodt.
and here's the flip side, because the negative path is lowkey the spicy part πΆοΈ:
A negative return value fromhandshake_req_submitguarantees that no completion callback will occur and thatreqis no longer owned by the caller. If cancellation wins the completion race after the request has been published, final destruction is deferred until socket teardown. π so like. don't touchreqafter a fail, it's not yours anymore, it's the kernel's problem now.
now the reference-counting bit, which is highkey the most important part and also the easiest to fumble π§:
The caller must hold a reference onsock->filefor the duration of this call. Once the request is published to the accept side, a concurrent completion or cancellation may release the request's pin onsock->file; the caller's reference is what keepssock->skvalid untilhandshake_req_submitreturns.
read that again fr fr. your reference is the whole safety net. main character energy for your own sock->file pin π«Ά
π SEE ALSO π
- Kernel file
./net/handshake/request.c handshake_req_alloc(9)handshake_req_private(9)handshake_req_next(9)handshake_req_cancel(9)
that's the whole page, bestie, you ate it π mwah π
signed, sealed, and shipped from ./net/handshake β dated October 2026, syntax handshake_req_submit(9), and yes it's still the Kernel API Manual β¨
π¦ 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