RTENTRY(9)
π¦ rtentry(9) β kernel developer's manual, but make it a vibe β¨
okay bestie, buckle up, because we're about to read the manual page for rtentry β the structure of an entry in the kernel routing table π it's giving kernel-dev realness, and honestly? it ate.
πΈ NAME πΈ
rtentry β structure of an entry in the kernel routing table πΊοΈβ¨
π SYNOPSIS π
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
that's it, that's the whole synopsis, no cap π«Ά
π DESCRIPTION π
so the kernel has this whole common mechanism where literally every protocol can store and retrieve entries from one central table of routes π parts of that mechanism also get used to talk to user-level processes through a socket in the route(4) pseudo-protocol family. and the <net/route.h> header file is the main character here β it defines all the structures and manifest constants this facility uses β¨
π§ the basic structure
the basic structure of a route is defined by struct rtentry, and it includes these fields, bestie:
struct radix_node rt_nodes[2];β glue used by the radix-tree routines π§΅ and not me pointing out that these members also include in their substructure the key (i.e., destination address) and mask used when the route was created. you can pull that info out with thert_key(rt)andrt_mask(rt)macros, given astruct rtentry *, and it comes back in the form of astruct sockaddr *π«struct sockaddr *rt_gateway;β the "target" of the route π― which can either represent a destination in its own right (some protocols will put a link-layer address here), or some intermediate stop on the way to that destination (if theRTF_GATEWAYflag is set).int rt_flags;β see below β¬οΈ and heads up: if theRTF_UPflag is not present, thertfree()function will delete the route from the radix tree when the last reference drops πint rt_refcnt;β route entries are reference-counted, and this field is the number of external (to the radix tree) references π’struct ifnet *rt_ifp;struct ifaddr *rt_ifa;β these two fields together are, as it were, the "answer" to the question a route lookup asks π₯Ή like, they name the interface and interface address to be used when sending a packet to the destination (or set of destinations) that this route represents.u_long rt_mtu;β see the description ofrmx_mtubelow πu_long rt_weight;β see the description ofrmx_weightbelow πu_long rt_expire;β see the description ofrmx_expirebelow πcounter64_t rt_pksent;β see the description ofrmx_pksentbelow πstruct rtentry *rt_gwroute;β this member is a reference to a route whose destination isrt_gatewayπ£οΈ it's only used forRTF_GATEWAYroutes.struct mtx rt_mtx;β mutex to lock this routing entry π
π the flag bits, defined
RTF_UPβ the route is not deleted. it lives β¨RTF_GATEWAYβ the route points to an intermediate destination and not the ultimate recipient; thert_gatewayandrt_gwroutefields name that destination πRTF_HOSTβ this is a host route πRTF_REJECTβ the destination is presently unreachable π this should result in anEHOSTUNREACHerror from output routines.RTF_DYNAMICβ this route was created dynamically byrtredirect()π±RTF_MODIFIEDβ this route was modified byrtredirect()βοΈRTF_DONEβ used only in theroute(4)protocol, indicating that the request was executed βRTF_XRESOLVEβ when this route is returned as a result of a lookup, send a report on theroute(4)interface requesting that an external process perform resolution for this route π£RTF_STATICβ indicates that this route was manually added by means of theroute(8)command βοΈRTF_BLACKHOLEβ requests that output sent via this route be discarded π³οΈ bye!RTF_PROTO1RTF_PROTO2RTF_PROTO3β protocol-specific π¬RTF_PINNEDβ indicates that this route is immutable to a routing protocol πRTF_LOCALβ indicates that the destination of this route is an address configured as belonging to this system π»RTF_BROADCASTβ indicates that the destination is a broadcast address π‘RTF_MULTICASTβ indicates that the destination is a multicast address π (multicast, not multilevel, ok?)
π the metrics
several metrics get supplied in struct rt_metrics, passed along with routing control messages via the route(4) API π¨ currently only rmx_mtu, rmx_expire, and rmx_pksent metrics are supplied. all others are ignored π«₯ (yes, ignored. the disrespect.)
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 πu_long rmx_mtu;β MTU for this path πu_long rmx_hopcount;β number of intermediate systems on the path to this destination πͺu_long rmx_expire;β the time (a latime(3)) at which this route should expire, or zero if it should never expire β° and it is the responsibility of individual protocol suites to ensure that routes are actually deleted once they expire. so like, somebody has to do it, and it's not gonna be the kernel's problem.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).u_long rmx_sendpipe;β as before, but in the opposite direction πu_long rmx_ssthresh;β the slow-start threshold used in TCP congestion-avoidance π¦u_long rmx_rtt;β the round-trip time to this destination, in units ofRMX_RTTUNITper second β±οΈu_long rmx_rttvar;β the average deviation of the round-trip time to this destination, in units ofRMX_RTTUNITper second πu_long rmx_pksent;β a count of packets successfully sent via this route π¦u_long rmx_filler[4];β empty space available for protocol-specific information π«
π₯ SEE ALSO π₯
go read them, iykyk π
π 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 π
πΈ AUTHORS πΈ
this manual page was written by Garrett Wollman π«Ά ty king
π BUGS π
there are a number of historical relics remaining in this interface πΊ like, fossils. the rt_gateway and rmx_filler fields could be named better π fr fr, we said it.
and that's the whole page, bestie π this one's from the Debian crew, dated March 5, 2014 β so it's a classic, and yes it still slays. mwah π β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright 1996 Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms