Statistics
The routing code keeps statistics about different
aspects of the routing code, such as lookups and garbage collection. Statistics are
maintained on a per-processor basis. ip_rt_init,
described in the section "Routing Subsystem
Initialization" in Chapter 32,
allocates for each CPU a copy of the rt_cache_stat data
structure, where the CPU keeps its own statistics. The rt_cache_stat fields are incremented with the RT_CACHE_STAT_INC macro, which transparently updates the counter for the
right CPU. The section "rt_cache_stat
Structure" describes the fields of rt_cache_stat in detail.
The content of these statistics can be read by dumping the content of the /proc/net/stat/rt_cache file (see the section "The /proc/net and /proc/net/stat Directories"). The output you would get, however, is not formatted for easy reading. To get formatted output, you can use the lnstat tool that comes with the IPROUTE2 package.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access