diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-03-24 08:26:11 +0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-03-26 15:17:38 +0000 |
commit | 411a4cb67cd3d976ddbd94b37a0ce936bfb223e5 (patch) | |
tree | 13ae17b60f185301b561b15997012838f7bf7284 /src/network/kernel | |
parent | dbc983a513a6dff9973490d013b144812ec707aa (diff) |
QNetworkInterface/Linux: fix support for P-t-P tunnels
The kernel stores the local address in IFA_LOCAL and the peer's address
in IFA_ADDRESS. My testing with loopback, Ethernet, WiFi, OpenVPN TAP
and TUN and Openconnect shows IFA_LOCAL is always passed and always
correct, so we could have used just that, but let's leave the use of
IFA_ADDRESS because that's also what all libcs' getifaddrs() do.
[ChangeLog][QtNetwork][QNetworkInterface] Fixed a regression in
reporting the local address of a point-to-point tunnel network
interface.
Task-number: QTBUG-67226
Change-Id: I04a43ee94975482f9e32fffd151eb393d1775580
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qnetworkinterface_linux.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp index 01b2811070..5dc62bf7bb 100644 --- a/src/network/kernel/qnetworkinterface_linux.cpp +++ b/src/network/kernel/qnetworkinterface_linux.cpp @@ -382,7 +382,14 @@ static void getAddresses(int sock, char *buf, QList<QNetworkInterfacePrivate *> auto payloadPtr = reinterpret_cast<uchar *>(RTA_DATA(rta)); switch (rta->rta_type) { - case IFA_ADDRESS: // address + case IFA_ADDRESS: + // Local address (all interfaces except for point-to-point) + if (entry.ip().isNull()) + entry.setIp(makeAddress(payloadPtr, payloadLen)); + break; + + case IFA_LOCAL: + // Override the local address (point-to-point interfaces) entry.setIp(makeAddress(payloadPtr, payloadLen)); break; |