Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-87118

On Linux, the QNetworkInterface::IsUp flag semantics has changed which breaks existing application code

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.2
    • Fix Version/s: None
    • Component/s: Network
    • Labels:
      None
    • Platform/s:
      Linux/Wayland, Linux/X11, Linux/Yocto

      Description

      On Linux, the  QNetworkInterface::IsUp flag semantics has changed which breaks existing application code.

       

      At some point Qt changed the way that QNetworkInterface::IsUp is obtained from the Linux kernel. Qt 5.12.2 obtains the QNetworkInterface::IsUp flags using a RTM_GETLINK request over a Netlink socket which returned the flags in a ifinfomsg as follows :-

       

      struct ifinfomsg {
          ...
          unsigned int   ifi_flags;  /* Device flags  */
          ...
      }
      

       

      However, if the response also includes a IFLA_OPERSTATE message, then QNetworkInterface::IsUp is overridden by the IFLA_OPERSTATE of the network interface. i.e.

       

      static QList<QNetworkInterfacePrivate *> getInterfaces(int sock, char *buf)
      {
      ...
                  case IFLA_OPERSTATE:    // operational state
                      if (*payloadPtr != IF_OPER_UNKNOWN) {
                          iface->flags &= ~QNetworkInterface::IsUp;
                          if (*payloadPtr == IF_OPER_UP)
                          {
                              iface->flags |= QNetworkInterface::IsUp;
                          }
                      }
                      break;
       
      

       

      In the situation where a network interface is ready aside from the cable being unplugged, then QNetworkInterface::IsUp is cleared whereas in previous Qt versions (e.g. 5.6), it would be set.

      I suggest that the operational state should be exposed using a separate and new attribute in QNetworkInterface rather than being used to modify QNetworkInterface::IsUp.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            tpochep Timur Pocheptsov
            Reporter:
            vaughan.mcpherson Vaughn McPherson
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes