#9770 closed bug (fixed)
if_nameindex() returns multiple elements with same if_index
Reported by: | akira | Owned by: | phoudoin |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Kits/Network Kit | Version: | R1/alpha4.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
I found that if_nameindex() returns multile elements with same if_index.
~/n> uname -srvm Haiku 1 hrevr1alpha4-44702 Nov 14 2012 BePC ~/n> cat tst.c #include <stdlib.h> #include <stdio.h> #include <net/if.h> int main(int argc, char *argv[]) { struct if_nameindex *ifs; int i; ifs = if_nameindex(); if (ifs == NULL) { perror("if_nameindex"); exit(EXIT_FAILURE); } for (i = 0; ifs[i].if_index != 0 || ifs[i].if_name != NULL; i++) { printf("%d %s\n", ifs[i].if_index, ifs[i].if_name); } return EXIT_SUCCESS; } ~/n> gcc tst.c -lnetwork ~/n> ./a.out 288 loop 288 /dev/net/rtl81xx/0
I think 288 is not a valid if_index.
Change History (6)
comment:1 by , 11 years ago
Component: | - General → Network & Internet/Stack |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 11 years ago
Issue is that it's assumed that SIOCGIFCONF returns a list of ifreq of ifr_name + ifr_index flavor: http://cgit.haiku-os.org/haiku/tree/src/kits/network/interfaces.cpp#n110
While in fact it's ifr_name + ifr_addr flavor: http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/network/stack/device_interfaces.cpp#n343
Will do a SIOCGIFINDEX request to retrieve that interface name's index. Stay tuned.
comment:3 by , 11 years ago
Status: | assigned → in-progress |
---|
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | in-progress → closed |
Fixed in hrev45687.
Thanks for report and testcase.
comment:5 by , 11 years ago
Component: | Network & Internet/Stack → Kits/Network Kit |
---|
comment:6 by , 11 years ago
Oh, for the curious ones: 288 is 0x0120, which match "AF_INET" address family and a "32 bytes sockaddr lenght".
I will look into, at it seems indeed a bug.