Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add route table and route type label #2728

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

derrickhayashi
Copy link

@derrickhayashi derrickhayashi commented Jun 26, 2023

This PR adds labels to show the route table for a particular route as well as the route type.

On a router, it is common to use different route tables to differentiate and isolate networks (known as VRFs in the networking world) for multiple tenants. The original PR does not seem to differentiate between different route tables (no response to #1811 (comment)) so this PR adds this feature. It also looks up the route table id to a user friendly name as defined in rt_tables config.

Also, "blackhole" route types are a route to ensure that packets destined for networks which the router is not able to route to do not keep propagating. On Linux, there are two options to do this, either through the route type of "blackhole", which silently discards the packet, or "unreachable", which sends an ICMP unreachable message.

On a device functioning as a router, it is usable to be able to monitor and identify these routes and types.

Example output

$ ip r show table test
blackhole 192.0.2.1
unreachable 192.0.2.2
$ cat /etc/iproute2/rt_tables.d/
README     test.conf
$ cat /etc/iproute2/rt_tables.d/test.conf
32 test
$ ip r show table test
blackhole 192.0.2.1
unreachable 192.0.2.2
$ curl -s localhost:9100/metrics | grep node_network_route | grep "192\."
node_network_route_info{dest="192.0.2.1/32",device="",gw="",priority="0",proto="boot",src="",table="test",type="blackhole",weight=""} 1
node_network_route_info{dest="192.0.2.2/32",device="",gw="",priority="0",proto="boot",src="",table="test",type="unreachable",weight=""} 1
node_network_route_info{dest="192.168.1.0/24",device="enp0s31f6",gw="",priority="100",proto="kernel",src="192.168.1.11",table="main",type="unicast",weight=""} 1
node_network_route_info{dest="192.168.1.1/32",device="enp0s31f6",gw="",priority="100",proto="dhcp",src="192.168.1.11",table="main",type="unicast",weight=""} 1
node_network_route_info{dest="default",device="enp0s31f6",gw="192.168.1.1",priority="100",proto="dhcp",src="192.168.1.11",table="main",type="unicast",weight=""} 1
$

@derrickhayashi derrickhayashi force-pushed the route_tables branch 2 times, most recently from 6e5947f to 2be4244 Compare June 27, 2023 00:49
Signed-off-by: Derrick Hayashi <derrickhayashi@gmail.com>
Signed-off-by: Derrick Hayashi <derrickhayashi@gmail.com>
Comment on lines +232 to +233
rt_tablesConfigFile := "/etc/iproute2/rt_tables"
rt_tablesConfigDir := "/etc/iproute2/rt_tables.d"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These paths should be set as flags to make them configurable.

This allows users to change the paths, as well as we can then setup fixtures for the end-to-end tests.

--collector.network_route.config.file
--collector.network_route.config.dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants