[Development] Qt5 Bearer: broken PPP support

Alexander Smirnov asmirnov at ilbers.de
Wed Sep 21 09:11:00 CEST 2016


Hi Thiago,

> On terça-feira, 20 de setembro de 2016 22:48:42 PDT Alexander Smirnov wrote:
>> After debugging I figured out, that the problem is in commit:
>>
>>     043f5d3eb52587831f643bc52c95079c36d984c7
>>
>> This commit allows to add to list:
>>
>>     QList<QNetworkInterfacePrivate *> interfaces;
>>
>> interfaces with no address field (ifa_addr == NULL).
>>
>> Then, I've checked the output from 'getifaddrs()' syscall on my board,
>> and it returns 2! instances of ppp0:
>>
>>    - one with AF_INET family
>>    - one with ifa_addr == NULL
> [cut]
>> So, is it a bug? :-)
>
> Probably. Can you give me a full dump of what getifaddrs gave you along with
>
> 	ip -d link show dev ppp0
> 	ip -d addr show dev ppp0
>

So, I've attached the following:

[ifconfig.log] - output from 'ifconfig -a'

[getifaddrs.c] - test app to show getifaddrs() output, derived from man 
page, but fixed to not to skip null addresses

[getifaddrs.log] - output from test app

[ip.log] - output from ip command as you requested

NOTE: I've also observed the same behavior for tun devices.

ppp0 interface is created by typical Linux pppd daemon.
tun2 interface is created by openvpn.

> I'll fix it.
>

Please let me know, if you need additional information.

-- 
With best regards,
Alexander Smirnov

ilbers GmbH
Baierbrunner Str. 28c
D-81379 München
+49 (89) 122 67 24-0
http://ilbers.de/
Commercial register Munich, HRB 214197
General manager: Baurzhan Ismagulov
-------------- next part --------------
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char** argv)
{
    struct ifaddrs *ifaddr, *ifa;
    int family, s;
    char host[NI_MAXHOST];

    if (getifaddrs(&ifaddr) == -1) {
        perror("getifaddrs");
        exit(EXIT_FAILURE);
    }

    /* Walk through linked list, maintaining head pointer so we
     * can free list later
     */
    for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
        if (ifa->ifa_addr == NULL) {
            printf("%s \taddress: NULL\n", ifa->ifa_name);
            continue;
        }

        family = ifa->ifa_addr->sa_family;

        /* Display interface name and family (including symbolic
         * form of the latter for the common families)
         */
        printf("%s \tfamily: %d%s\n",
               ifa->ifa_name, family,
               (family == AF_PACKET) ? " (AF_PACKET)" :
               (family == AF_INET) ?   " (AF_INET)" :
               (family == AF_INET6) ?  " (AF_INET6)" : "");

        /* For an AF_INET* interface address, display the address */

        if (family == AF_INET || family == AF_INET6) {
            s = getnameinfo(ifa->ifa_addr,
                            (family == AF_INET) ? sizeof(struct sockaddr_in) :
                            sizeof(struct sockaddr_in6),
                            host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
            if (s != 0) {
                printf("getnameinfo() failed: %s\n", gai_strerror(s));
                exit(EXIT_FAILURE);
            }

            printf("\taddress: <%s>\n", host);
        }
    }

    freeifaddrs(ifaddr);
    exit(EXIT_SUCCESS);
}
-------------- next part --------------
# getifaddrs
 
lo      family: 17 (AF_PACKET)
can0    address: NULL
eth0    family: 17 (AF_PACKET)
wlan0   family: 17 (AF_PACKET)
sit0    family: 17 (AF_PACKET)
ppp0    address: NULL
tun2    address: NULL
lo      family: 2 (AF_INET)
        address: <127.0.0.1>
eth0    family: 2 (AF_INET)
        address: <192.168.178.110>
ppp0    family: 2 (AF_INET)
        address: <10.142.173.66>
tun2    family: 2 (AF_INET)
        address: <10.0.0.1>
lo      family: 10 (AF_INET6)
        address: <::1>
eth0    family: 10 (AF_INET6)
        address: <fe80::201:c0ff:fe19:6c24%eth0>
-------------- next part --------------
# ifconfig -a
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:30 

eth0      Link encap:Ethernet  HWaddr 00:01:C0:19:6C:24  
          inet addr:192.168.178.110  Bcast:192.168.178.255  Mask:255.255.255.0
          inet6 addr: fe80::201:c0ff:fe19:6c24%1996412624/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:361871 errors:9529 dropped:60 overruns:9529 frame:9529
          TX packets:169960 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:511238273 (487.5 MiB)  TX bytes:11817634 (11.2 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1996412624/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:512 (512.0 B)  TX bytes:512 (512.0 B)

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:10.142.173.66  P-t-P:10.142.173.66  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:58 (58.0 B)  TX bytes:98 (98.0 B)

sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tun2      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          POINTOPOINT NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 04:F0:21:13:FD:7C  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:2489 (2.4 KiB)

-------------- next part --------------
************
*** ppp0 ***
************

# ip -d link show dev ppp0
10: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 3
    link/ppp  promiscuity 0 addrgenmode eui64 

# ip -d addr show dev ppp0
10: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 3
    link/ppp  promiscuity 0 
    inet 10.142.173.66/32 scope global ppp0
       valid_lft forever preferred_lft forever

************
*** tun2 ***
************

# ip -d link show dev tun2
11: tun2: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 100
    link/none  promiscuity 0 
    tun addrgenmode eui64 
# ip -d addr show dev tun2
11: tun2: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 100
    link/none  promiscuity 0 
    tun 
    inet 10.0.0.1/24 scope global tun2
       valid_lft forever preferred_lft forever



More information about the Development mailing list