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 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
#include
#include
#include
#include
#include
#include
#include
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);
}
# getifaddrs
lo family: 17 (AF_PACKET)
can0address: NULL
eth0family: 17 (AF_PACKET)
wlan0 family: 17 (AF_PACKET)
sit0family: 17 (AF_PACKET)
ppp0address: NULL
tun2address: NULL
lo family: 2 (AF_INET)
address: <127.0.0.1>
eth0family: 2 (AF_INET)
address: <192.168.178.110>
ppp0family: 2 (AF_INET)
address: <10.142.173.66>
tun2family: 2 (AF_INET)
address: <10.0.0.1>
lo family: 10 (AF_INET6)
address: <::1>
eth0family: 10 (AF_INET6)
address:
# 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)
loLink 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