Skip to content

Conversation

vatsalkeshav
Copy link
Contributor

@vatsalkeshav vatsalkeshav commented Mar 23, 2025

This pr changes the way the default route and corresponding default interface are chosen

possible problem in issue 2117

  1. default route is set by looking for any attrtibure that indicates the route being default route(by looking for Rta::Gateway)
  2. and simply took the first matching route’s interface index and the corresponding interface as default

What this fix does :

  1. Now, every default route(routes where rtm_dst_len == 0) is looked at
  2. and its interface index and a “metric” value is looked at
  3. whichever default route has the smallest metric, the interfave at its interface index is taken as the default interface

This should ensure that if multiple interfaces have “default routes,” the one with the lowest metric is chosen

@vatsalkeshav vatsalkeshav changed the title [fix] Fixed [issue 2117](https://github.com/greshake/i3status-rust/issues/2117) [fix] Updated the way default interfaces are chosen in netlink.rs Mar 23, 2025
@Stebalien
Copy link
Contributor

@greshake sorry to bug you, but is there any chance this could get reviewed?

In my case, this fixes my VPN block:

[[block]]
  block = "net"
  device = ".*-wg-.*"
  interval = 5
  format = "{ $ip.str(w:0)$icon $device |}"
  inactive_format = ""
  missing_format = ""

Given multiple VPN devices (where all but one are down):

  1. With this patch, i3status-rs prioritizes my active VPN.
  2. Without this patch, i3status-rs picks the first VPN, then displays nothing because it has no IP address.

@MaxVerevkin
Copy link
Collaborator

Sorry for such a late response! This looks good to me, thank you!

@MaxVerevkin MaxVerevkin merged commit bb1a479 into greshake:master Aug 2, 2025
13 checks passed
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.

3 participants