From 16886117b3645db1cc32055a9732b4b9cf1562d9 Mon Sep 17 00:00:00 2001 From: Anubhab Ghosh Date: Thu, 2 Apr 2026 19:54:19 +0530 Subject: [PATCH] Network: fix: delete correct address type Only delete the corresponding address type (IPv4 or IPv6) when an event about a specific type (AF_INET or AF_INET6) is received This fixes situations where only one type of the address is deleted (and possibly added again) but Waybar still thinks the interface is in "linked" (no IP) state. --- src/modules/network.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index a39a5ed3..6dbb8bf0 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -677,12 +677,15 @@ int waybar::modules::Network::handleEvents(struct nl_msg* msg, void* data) { changed_cidr); } } else { - net->ipaddr_.clear(); - net->ipaddr6_.clear(); - net->cidr_ = 0; - net->cidr6_ = 0; - net->netmask_.clear(); - net->netmask6_.clear(); + if (ifa->ifa_family == AF_INET) { + net->ipaddr_.clear(); + net->cidr_ = 0; + net->netmask_.clear(); + } else if (ifa->ifa_family == AF_INET6) { + net->ipaddr6_.clear(); + net->cidr6_ = 0; + net->netmask6_.clear(); + } spdlog::debug("network: {} addr deleted {}/{}", net->ifname_, inet_ntop(ifa->ifa_family, RTA_DATA(ifa_rta), ipaddr, sizeof(ipaddr)), ifa->ifa_prefixlen);