Skip to content

VRF association in NetClassIface #405

Open
@bluecmd

Description

@bluecmd

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 :-).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions