RT_IFA_ADD(9)

πŸ“¦ in nixpkgs unstable

πŸ’… RT_IFA_ADD β€” the kernel developer's manual, bestie edition πŸŽ€

okay so you're reading RT_IFA_ADD(9), which is section 9 of the Kernel Developer's Manual β€” aka the deep lore, the kernel-dev-only zone, no cap. These four functions are literally the bouncer squad for routing entries: rt_ifa_add, rt_ifa_del, rt_ifa_addlocal, and rt_ifa_dellocal. Their whole job? Add or delete the routing entries associated with an address. Iconic behavior, honestly. πŸ‘‘


✨ NAME ✨

rt_ifa_add, rt_ifa_del, rt_ifa_addlocal, rt_ifa_dellocal β€” add or delete routing entries associated with an address πŸ¦‹


πŸ“œ SYNOPSIS πŸ“œ

okay first, you gotta pull in the headers β€” all four of them, don't skip, they're the vibe check for your includes:

#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/route.h>

then the functions themselves, in their full glory:

int
rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst,
    unsigned int rdomain);

int
rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst,
    unsigned int rdomain);

int
rt_ifa_addlocal(struct ifaddr *ifa);

int
rt_ifa_dellocal(struct ifaddr *ifa);

look at those signatures bestie, they're giving main character energy ✨


🧚 DESCRIPTION 🧚

so basically these functions create and delete routing entries required by the network stack and managed by the kernel. that's the whole assignment, and they ate. πŸ’…

rt_ifa_add()

Creates and associates a connected routing entry with ifa in the routing domain specified by rdomain. 🫢

Now here's the part where you gotta pay attention, because there are two whole flavors of connected routing entry:

  • The prefix vibe β€” Connected routing entries represent routes to prefixes, and should be created with RTF_CLONING in flags and the address of ifa in dst.
  • The point-to-point vibe β€” But for Point-to-Point interfaces, connected routing entries represent routes to hosts, and should be created with RTF_HOST in flags and the destination address in dst.

Either way, connected routing entries have a priority of RTP_CONNECTED. ⭐

rt_ifa_del()

Removes the connected routing entry associated with ifa in the routing domain specified by rdomain. gone, deleted, blocked, unfollowed 😭

rt_ifa_addlocal()

Creates and associates a local routing entry with ifa. πŸŽ€

Local routing entries are used to not send packets destined to a local address on the wire, and instead redirect them to lo(4). literally "you're already home, why travel" energy. they have the lowest priority available, RTP_LOCAL, and contain a special flag, RTF_LOCAL, that can be checked to determine if the address is configured on the system. that flag is your iykyk detector fr fr

rt_ifa_dellocal()

Removes the local routing entry associated with ifa. bye bestie, the address is no longer configured on the system πŸ’€


🌈 CONTEXT 🌈

rt_ifa_add(), rt_ifa_del(), rt_ifa_addlocal(), and rt_ifa_dellocal() can be called during autoconf, from process context, or from interrupt context. three whole situations and they're flexible in all of them, we love a versatile queen πŸ‘‘


πŸ’– RETURN VALUES πŸ’–

rt_ifa_add(), rt_ifa_del(), rt_ifa_addlocal(), and rt_ifa_dellocal() will return 0 on success and the return value of rtrequest(9) otherwise. so 0 = slayed, anything else = go check what rtrequest(9) said πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹


πŸ’œ okay that's the whole page, go forth and configure addresses responsibly, bestie

and finally, the cute little sign-off: this page came from Debian, dated February 13, 2019. periodt. πŸŽ€βœ¨πŸŒΈ

πŸ“¦ where this page comes from