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

VRF association in NetClassIface #405

Open
bluecmd opened this issue Aug 2, 2021 · 1 comment
Open

VRF association in NetClassIface #405

bluecmd opened this issue Aug 2, 2021 · 1 comment

Comments

@bluecmd
Copy link
Contributor

bluecmd commented Aug 2, 2021

Hi,

One metric dimension that I am missing from Node Exporter is the VRF association for interfaces.

It looks like the current implementation relies on reading /sys/class/net. For VRFs this is visible as a generic upper (or master) / lower hierarchy.

Example:

bluecmd@adele:/sys/class/net/Ethernet92$ ls -lah
total 0
drwxr-xr-x   5 root root    0 Aug  2 15:06 .
drwxr-xr-x 122 root root    0 Aug  2 15:06 ..
-r--r--r--   1 root root 4.0K Aug  2 15:06 addr_assign_type
-r--r--r--   1 root root 4.0K Aug  2 15:06 address
[..]
-r--r--r--   1 root root 4.0K Aug  2 15:06 iflink
-r--r--r--   1 root root 4.0K Aug  2 15:06 link_mode
lrwxrwxrwx   1 root root    0 Aug  2 15:06 master -> ../VrfKamel
-rw-r--r--   1 root root 4.0K Aug  2 15:06 mtu
[..]
-rw-r--r--   1 root root 4.0K Aug  2 15:06 uevent
lrwxrwxrwx   1 root root    0 Aug  2 15:06 upper_VrfKamel -> ../VrfKamel

However, sadly, the VrfKamel master directory does not contain anything saying that it is a VRF interface. The type file would be my first guess but that appears to be more "What kind of protocol does this interface handle?" which is both 1 for EthernetX and VrfX.

The better way appears to use netlink to find the VRFs:

bluecmd@adele:/sys/class/net/eth0$ ip link show type vrf
9: mgmt: <NOARP,MASTER,UP,LOWER_UP> mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether d6:1e:f6:a2:87:b9 brd ff:ff:ff:ff:ff:ff
12: VrfKamel: <NOARP,MASTER,UP,LOWER_UP> mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 66:d8:f1:b8:0f:96 brd ff:ff:ff:ff:ff:ff
14: VrfMainframe: <NOARP,MASTER,UP,LOWER_UP> mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 8e:37:34:f5:bd:e3 brd ff:ff:ff:ff:ff:ff

Happy to take any questions or suggestions! Might even end up making a PR for it if the stars align and we can figure out a design :-).

@discordianfish
Copy link
Member

Yeah using netlink would be the way to go. Seems reasonable to add!

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

No branches or pull requests

2 participants