RTALLOC(9)

πŸ“¦ in nixpkgs unstable

πŸ’… 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 β€” if dst doesn't exist yet and the lookup came back with a cloning entry, this allocates and returns a cloned entry for dst. 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms