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.
This commit is contained in:
Anubhab Ghosh
2026-04-02 19:54:19 +05:30
parent 1e965ccce0
commit 16886117b3
+5 -2
View File
@@ -677,12 +677,15 @@ int waybar::modules::Network::handleEvents(struct nl_msg* msg, void* data) {
changed_cidr); changed_cidr);
} }
} else { } else {
if (ifa->ifa_family == AF_INET) {
net->ipaddr_.clear(); net->ipaddr_.clear();
net->ipaddr6_.clear();
net->cidr_ = 0; net->cidr_ = 0;
net->cidr6_ = 0;
net->netmask_.clear(); net->netmask_.clear();
} else if (ifa->ifa_family == AF_INET6) {
net->ipaddr6_.clear();
net->cidr6_ = 0;
net->netmask6_.clear(); net->netmask6_.clear();
}
spdlog::debug("network: {} addr deleted {}/{}", net->ifname_, spdlog::debug("network: {} addr deleted {}/{}", net->ifname_,
inet_ntop(ifa->ifa_family, RTA_DATA(ifa_rta), ipaddr, sizeof(ipaddr)), inet_ntop(ifa->ifa_family, RTA_DATA(ifa_rta), ipaddr, sizeof(ipaddr)),
ifa->ifa_prefixlen); ifa->ifa_prefixlen);