RTENTRY(9)
π« 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. thert_key(rt)andrt_mask(rt)macros can extract this info (as astruct sockaddr *) if you hand them astruct 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 theRTF_GATEWAYflag is set). it's giving layover vibes.int rt_flags;β see below for all the flag bits. important note: if theRTF_UPflag is NOT present, thertfree()function will delete the route from the radix tree once the last reference drops. so like, don't forget yourRTF_UPbestie.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;andstruct 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 ofrmx_mtubelow.u_long rt_weight;β see description ofrmx_weightbelow.u_long rt_expire;β see description ofrmx_expirebelow.counter64_t rt_pksent;β see 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. 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. thert_gatewayandrt_gwroutefields 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 anEHOSTUNREACHerror from output routines. it's giving blocked.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. task complete slay.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. outsourcing the work, we respect a delegator.RTF_STATICβ indicates that this route was manually added by means of theroute(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 latime(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 ofRMX_RTTUNITper second.u_long rmx_rttvar;β the average deviation of the round-trip time to this destination, in units ofRMX_RTTUNITper 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 π
π 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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright 1996 Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms