[BUG] LocalIP not shown due to unexpected inclusion of `lo` when detecting default routes

Read the FAQ first

  • I have checked the FAQ but the issue is not covered

Description

On systems where a local default dev lo route exists (maybe caused by network sharing of Networkmanager in my cause), fastfetch incorrectly identifies the loopback interface (lo) as the default route, which results in finding no interfaces. Not sure if this is intended.

Version used

fastfetch 2.56.1-16-debug (x86_64)

Bug prevalence

Always

Regression

Not sure

Installation

Built from source

Package manager

No response

Screenshots

ip addr:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
3: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 60:cf:84:ea:25:19 brd ff:ff:ff:ff:ff:ff
    altname enp10s0
    altname enx60cf84ea2519
4: wlp11s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether a8:e2:91:0b:6c:f8 brd ff:ff:ff:ff:ff:ff
    altname wlxa8e2910b6cf8
    inet 10.116.2.138/24 brd 10.116.2.255 scope global dynamic noprefixroute wlp11s0
       valid_lft 2788sec preferred_lft 2788sec
    inet6 fe80::5aad:8063:9974:c887/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

ip route show default:

default via 10.116.2.61 dev wlp11s0 proto dhcp src 10.116.2.138 metric 600 

ip route show table all:

local default dev lo table 100 scope host 
default via 10.116.2.61 dev wlp11s0 proto dhcp src 10.116.2.138 metric 600 
10.116.2.0/24 dev wlp11s0 proto kernel scope link src 10.116.2.138 metric 600 
local 10.116.2.138 dev wlp11s0 table local proto kernel scope host src 10.116.2.138 
broadcast 10.116.2.255 dev wlp11s0 table local proto kernel scope link src 10.116.2.138 
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1 
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1 
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1 
fe80::/64 dev wlp11s0 proto kernel metric 1024 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::5aad:8063:9974:c887 dev wlp11s0 table local proto kernel metric 0 pref medium
multicast ff00::/8 dev wlp11s0 table local proto kernel metric 256 pref medium

And with the debug build, I found the following info in log:

[localip_linux.c 280, 21:11:51.683] Starting local IP detection with showType=0x812, namePrefix=''
[localip_linux.c 290, 21:11:51.683] Successfully retrieved interface addresses
[localip_linux.c 312, 21:11:51.683] Skipping loopback interface lo
[localip_linux.c 305, 21:11:51.683] Skipping interface eno1 (not running)
[localip_linux.c 326, 21:11:51.683] Skipping interface wlp11s0 (unsupported address family 17)
[localip_linux.c 312, 21:11:51.683] Skipping loopback interface lo
[netif_linux.c  12, 21:11:51.683] Starting IPv4 default route detection
[netif_linux.c  20, 21:11:51.683] Created netlink socket: fd=3
[netif_linux.c  23, 21:11:51.683] Process PID: 33697
[netif_linux.c  36, 21:11:51.683] Successfully bound socket
[netif_linux.c  85, 21:11:51.683] Sent netlink request: 36 bytes
[netif_linux.c 108, 21:11:51.683] Received netlink response: 480 bytes
[netif_linux.c 154, 21:11:51.683] Processing IPv4 default route candidate #1
[netif_linux.c 173, 21:11:51.683] Found interface index: 1
[netif_linux.c 199, 21:11:51.683] Updated best route: ifindex=1, metric=0, prefsrc=0
[netif_linux.c 203, 21:11:51.683] Found zero metric route, stopping further processing
[netif_linux.c 108, 21:11:51.683] Received netlink response: 20 bytes
[netif_linux.c 128, 21:11:51.683] Received NLMSG_DONE, processed 1 routes
[netif_linux.c 213, 21:11:51.683] Found default IPv4 route: interface=lo, index=1, metric=0
[localip_linux.c 337, 21:11:51.683] Skipping interface wlp11s0 (not default route interface)
[localip_linux.c 312, 21:11:51.683] Skipping loopback interface lo
[localip_linux.c 337, 21:11:51.683] Skipping interface wlp11s0 (not default route interface)
[localip_linux.c 395, 21:11:51.683] Found 0 network adapters
[localip_linux.c 593, 21:11:51.683] Cleaned up interface address structures
[localip_linux.c1062, 21:11:51.683] Local IP detection completed, found 0 interfaces

Configuration

System information

Features built-in

threads
vulkan
wayland
xcb-randr
xrandr
drm
drm_amdgpu
gio
dconf
dbus
imagemagick7
zlib
sqlite3
egl
glx
libpulse
libddcutil
libelf
libzfs
linux/videodev2
linux/wireless