diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-02-17 21:16:54 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2021-02-21 08:20:38 +0000 |
commit | 9ab73a80b2b5185bf210ef0efd9d12fd72d184a4 (patch) | |
tree | 7cfc30122130bf03f790ef685778010b65a5d93e | |
parent | 57e2003982c31a24e86293cd54fe7514627a2d55 (diff) |
QNetworkInterface/Linux: make the IFLA_OPER_STATE set IsRunning
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: <NO-CARRIER,BROADCAST,MULTICAST,UP> 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<UP,BROADCAST,MULTICAST> 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 <marten.nordheim@qt.io>
(cherry picked from commit 7507d872856282f381354b13a3b50d865c9ce2f8)
-rw-r--r-- | src/network/kernel/qnetworkinterface_linux.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp index c9d22eb247..ce36bf2e11 100644 --- a/src/network/kernel/qnetworkinterface_linux.cpp +++ b/src/network/kernel/qnetworkinterface_linux.cpp @@ -303,9 +303,9 @@ static QList<QNetworkInterfacePrivate *> 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; } |