RTALLOC(9)
π RTALLOC(9) β routing entry interface, but make it make sense
okay bestie, welcome to rtalloc(9) from the Kernel Developer's Manual π this is the whole routing-entry interface vibe β rtalloc, rtalloc_mpath, rtisvalid, rtref and rtfree β and yes, we're gonna go through every single one of them, no skipping, periodt β¨
πΈ NAME πΈ
rtalloc, rtalloc_mpath, rtisvalid, rtref, rtfree β the routing entry interface. that's the whole squad π«Ά
β¨ SYNOPSIS β¨
first you gotta bring in the headers, like inviting the right people to the group chat:
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
then the actual function signatures, exactly as they live:
struct rtentry *
rtalloc(struct sockaddr *dst, int flags, unsigned int rtableid);
struct rtentry *
rtalloc_mpath(struct sockaddr *dst, uint32_t *src,
unsigned int rtableid);
int
rtisvalid(struct rtentry *rt);
void
rtref(struct rtentry *rt);
void
rtfree(struct rtentry *rt);
look at them. iconic. no notes π
π¦ DESCRIPTION π¦
so here's the tea on each one:
rtalloc() π
rtalloc() goes looking in the routing table rtableid for an entry that matches dst. cute, right? and you can pass it these flags:
RT_RESOLVEβ ifdstdoesn't exist yet and the lookup came back with a cloning entry, this allocates and returns a cloned entry fordst. it's giving "make it work, make it exist" β¨
rtalloc_mpath() π
rtalloc_mpath() does the exact same thing as rtalloc() with the RT_RESOLVE flag β but when it's possible, it picks the multipath routing entry that corresponds to src. so it's rtalloc() but with main character energy and a source address π
rtisvalid() β
rtisvalid() checks whether the route entry rt is still valid and can actually be used. if you're holding onto a cached entry that's no longer valid, the move is to release it by calling rtfree(). don't just let it sit there, that's not the vibe π
rtref() π
rtref() bumps up a reference to the routing entry rt. one more friend in the count π
rtfree() π§
rtfree() releases a reference to the routing entry rt, and if the reference count drops to 0, it frees it. and if rt is a NULL pointer? no action occurs. nothing happens. it simply does not engage π
π₯ CONTEXT π₯
rtalloc(), rtalloc_mpath(), rtisvalid(), rtref(), and rtfree() can all be called during autoconf, from process context, or from interrupt context. flexible icons, honestly πβ¨
π RETURN VALUES π
rtisvalid() returns 1 if the route entry is valid, otherwise 0. short and sweet, fr fr π
π SEE ALSO π
go read these next, iykyk:
okay that's genuinely everything, bestie β every flag, every function, every value, nothing dropped, no cap π«Ά
π that's a wrap on RTALLOC(9) π this page came from Debian, dated July 12, 2019 β mwah, slay, periodt π π
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2014-2015 Martin Pieuchot
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms