From 9ab73a80b2b5185bf210ef0efd9d12fd72d184a4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 17 Feb 2021 21:16:54 -0800 Subject: [PATCH] QNetworkInterface/Linux: make the IFLA_OPER_STATE set IsRunning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were setting IsUp for both the ifinfomsg::ifi_flags field and IFLA_OPER_STATE message. Turns out the second matches the "RUNNING" state that ifconfig used to return (IFF_RUNNING from SIOCIFFLAGS). Example: $ ip link show vboxnet0 4: vboxnet0: mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff $ ifconfig vboxnet0 vboxnet0: flags=4099 mtu 1500 ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 In this example, ifconfig is not showing "RUNNING", so its "UP" matches iproute2's in the <> section (that's the interface's ifi_flags). In an interface that ifconfig shows RUNNING, iproute2 will show "state UP", which is the IFLA_OPER_STATE. Exception: looks like the loopback has IF_OPER_UNKNOWN. Change-Id: Ic90d8429a0eb4837971dfffd1664bfc3f4b4e030 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 7507d872856282f381354b13a3b50d865c9ce2f8) --- src/network/kernel/qnetworkinterface_linux.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp index c9d22eb247d..ce36bf2e113 100644 --- a/src/network/kernel/qnetworkinterface_linux.cpp +++ b/src/network/kernel/qnetworkinterface_linux.cpp @@ -303,9 +303,9 @@ static QList getInterfaces(int sock, char *buf) case IFLA_OPERSTATE: // operational state if (*payloadPtr != IF_OPER_UNKNOWN) { // override the flag - iface->flags &= ~QNetworkInterface::IsUp; + iface->flags &= ~QNetworkInterface::IsRunning; if (*payloadPtr == IF_OPER_UP) - iface->flags |= QNetworkInterface::IsUp; + iface->flags |= QNetworkInterface::IsRunning; } break; }