Skip to content

Resolve TODO: Use IFLA_LINKINFO to detect tun/tap/wireguard/ppp interfaces#2242

Open
ayushrawat-10 wants to merge 2 commits intogreshake:masterfrom
ayushrawat-10:todo-update
Open

Resolve TODO: Use IFLA_LINKINFO to detect tun/tap/wireguard/ppp interfaces#2242
ayushrawat-10 wants to merge 2 commits intogreshake:masterfrom
ayushrawat-10:todo-update

Conversation

@ayushrawat-10
Copy link

This PR replaces the previous sysfs-based interface type detection with a netlink-based implementation using IFLA_LINKINFO.
This resolves the existing inline TODO in netlink.rs:
// TODO: use netlink for these too
Interface types such as tun, tap, wireguard, and ppp are now detected directly from netlink attributes instead of relying on /sys/class/net.

Things Changed

  1. Removed sysfs-based detection

The following logic was removed:

  • Probing /sys/class/net//tun_flags
  • Parsing /sys/class/net//uevent
  • String-based detection of wireguard and ppp
    This eliminates filesystem access and string scanning for interface classification.
  1. Added netlink-based link type detection

We now extract interface type from the IFLA_LINKINFO attribute:
Ifla::Linkinfo => link_type = extract_link_type(attr.payload().as_ref()),
And a fucntion
fn extract_link_type(linkinfo_bytes: &[u8]) -> Option<String>

Why This Change?

  1. More Correct
  • Netlink is the authoritative source of network interface metadata.
  • Relying on sysfs and filename heuristics is less robust and more indirect.
  1. More Efficient
  • Removes filesystem lookups
  • Avoids async file reads
  • Avoids string scanning of uevent.
    Everything is now derived directly from netlink data already being processed.

Impact
No functional changes are expected.
Interface classification now relies solely on netlink metadata instead of sysfs probing.

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.

1 participant