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>
This commit is contained in:
parent
64a878e36b
commit
7507d87285
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user