RTENTRY(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’« RTENTRY πŸ’«

okay bestie, gather round because we're about to talk about rtentry β€” the structure of an entry in the kernel routing table, from the Kernel Developer's Manual, section 9. this is the blueprint for how your kernel keeps track of where packets go. it's giving infrastructure. it's giving backbone energy. let's get into it 🫢


🌸 SYNOPSIS 🌸

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

✨ DESCRIPTION ✨

so like, the kernel has this whole common mechanism where literally every protocol can store and retrieve entries from one central table of routes. iconic behavior honestly. parts of this mechanism also let user-level processes vibe with it through a socket in the route(4) pseudo-protocol family. the <net/route.h> header file is where all the structures and manifest constants for this whole facility live. it's the blueprint, the map, the whole vibe.

the basic structure of a route is defined by struct rtentry, which includes these fields:

  • struct radix_node rt_nodes[2]; β€” this is the glue that the radix-tree routines use. lowkey these members also include, in their whole substructure situation, the key (aka destination address) and mask that were used when the route was created. the rt_key(rt) and rt_mask(rt) macros can extract this info (as a struct sockaddr *) if you hand them a struct rtentry *. handy.
  • struct sockaddr *rt_gateway; β€” the "target" of the route. this can either represent a destination all on its own (some protocols will put a link-layer address here), or it can be some intermediate stop on the way to that destination (but only if the RTF_GATEWAY flag is set). it's giving layover vibes.
  • int rt_flags; β€” see below for all the flag bits. important note: if the RTF_UP flag is NOT present, the rtfree() function will delete the route from the radix tree once the last reference drops. so like, don't forget your RTF_UP bestie.
  • int rt_refcnt; β€” route entries are reference-counted, periodt. this field tells you the number of external (to the radix tree) references.
  • struct ifnet *rt_ifp; and struct ifaddr *rt_ifa; β€” these two fields are literally the "answer" to the question posed by a route lookup. they name the interface and interface address that get used when sending a packet to the destination (or set of destinations) that this route represents. main character answer energy.
  • u_long rt_mtu; β€” see description of rmx_mtu below.
  • u_long rt_weight; β€” see description of rmx_weight below.
  • u_long rt_expire; β€” see description of rmx_expire below.
  • counter64_t rt_pksent; β€” see description of rmx_pksent below.
  • struct rtentry *rt_gwroute; β€” this member is a reference to a route whose destination is rt_gateway. it's ONLY used for RTF_GATEWAY routes. exclusive club.
  • struct mtx rt_mtx; β€” mutex to lock this routing entry. safety first babes.

πŸŽ€ the flag bits πŸŽ€

these are defined as follows, and yes we're going through every single one:

  • RTF_UP β€” the route is not deleted. it's alive, it's thriving.
  • RTF_GATEWAY β€” the route points to an intermediate destination and NOT the ultimate recipient. the rt_gateway and rt_gwroute fields name that destination.
  • RTF_HOST β€” this is a host route. we love a specific queen.
  • RTF_REJECT β€” the destination is presently unreachable. this should result in an EHOSTUNREACH error from output routines. it's giving blocked.
  • RTF_DYNAMIC β€” this route was created dynamically by rtredirect().
  • RTF_MODIFIED β€” this route was modified by rtredirect().
  • RTF_DONE β€” used ONLY in the route(4) protocol, indicating that the request was executed. task complete slay.
  • RTF_XRESOLVE β€” when this route is returned as a result of a lookup, send a report on the route(4) interface requesting that an external process perform resolution for this route. outsourcing the work, we respect a delegator.
  • RTF_STATIC β€” indicates that this route was manually added by means of the route(8) command. handmade artisanal route.
  • RTF_BLACKHOLE β€” requests that output sent via this route be discarded. it goes into the void. bye.
  • RTF_PROTO1, RTF_PROTO2, RTF_PROTO3 β€” protocol-specific. the trio.
  • RTF_PINNED β€” indicates that this route is immutable to a routing protocol. nobody touches her.
  • RTF_LOCAL β€” indicates that the destination of this route is an address configured as belonging to this system. it's us. we're the destination.
  • RTF_BROADCAST β€” indicates that the destination is a broadcast address. yelling to everyone.
  • RTF_MULTICAST β€” indicates that the destination is a multicast address. yelling to a select group chat.

πŸ¦‹ the metrics πŸ¦‹

several metrics are supplied in struct rt_metrics, passed with routing control messages via the route(4) API. currently ONLY rmx_mtu, rmx_expire, and rmx_pksent metrics are actually supplied. all the others are ignored. rip to the ignored ones, we still respect you.

the following metrics are defined by struct rt_metrics:

  • u_long rmx_locks; β€” flag bits indicating which metrics the kernel is NOT permitted to dynamically modify. locked down, off limits.
  • u_long rmx_mtu; β€” MTU for this path.
  • u_long rmx_hopcount; β€” number of intermediate systems on the path to this destination. count the stops.
  • u_long rmx_expire; β€” the time (a la time(3)) at which this route should expire, or zero if it should never expire. bestie it is the responsibility of individual protocol suites to ensure that routes are ACTUALLY deleted once they expire. so like, the kernel doesn't handle that for you. don't be lazy.
  • u_long rmx_recvpipe; β€” nominally, the bandwidth-delay product for the path from the destination to this system. in practice, this value is used to set the size of the receive buffer (and thus the window in sliding-window protocols like TCP). it's giving buffer queen.
  • u_long rmx_sendpipe; β€” as before, but in the opposite direction. symmetrical icon.
  • u_long rmx_ssthresh; β€” the slow-start threshold used in TCP congestion-avoidance. pacing herself.
  • u_long rmx_rtt; β€” the round-trip time to this destination, in units of RMX_RTTUNIT per second.
  • u_long rmx_rttvar; β€” the average deviation of the round-trip time to this destination, in units of RMX_RTTUNIT per second. the variance bestie.
  • u_long rmx_pksent; β€” a count of packets successfully sent via this route. a little tally of wins.
  • u_long rmx_filler[4]; β€” empty space available for protocol-specific information. room to grow πŸ’…

πŸ‘€ SEE ALSO πŸ‘€

route(4), route(8)


πŸ“œ HISTORY πŸ“œ

the rtentry structure first appeared in 4.2BSD. the radix-tree representation of the routing table and the rt_metrics structure first appeared in 4.3BSD-Reno. vintage. historic. iconic lineage.


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Garrett Wollman. thank you king.


πŸ’€ BUGS πŸ’€

ngl there are a number of historical relics remaining in this interface. the rt_gateway and rmx_filler fields could be named better. it's giving legacy code energy. we still love her though.


okay that's the whole page bestie, i hope you learned something and felt something. this was Debian, March 5, 2014, and the manual page name is RTENTRY(9), section 9 of the Kernel Developer's Manual. periodt πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from