-
-
Notifications
You must be signed in to change notification settings - Fork 606
Closed
Description
The implementation of if_nametoindex()/if_indextoname() copied from musl under libc/network/if_nametoindex.c and libc/network/if_indextoname.c has number of problems:
- Both use AF_UNIX domain which is unsupported on OSv (see
fd = socket(AF_UNIX, SOCK_DGRAM, 0)); instead we neeed to use AF_INET like if_nameindex uses - see c4df104) - Even after fixing the above,
if_nametoindexreturns strangely high number like 1082589186 for eth0 and 1082589185 for lo0; most likely it is caused by not zero-ing the index field (for example zeroingifr.ifr_ifindexinif_nametoindex.cbefore calling ioctl() makes the code return correct 2 and 1 index; the correct fix should be somewhere in bsd/linuz compatibility layer code (bsd/sys/compat/linux/linux_ioctl.ccorbsd/sys/kern/sys_socket.ccorbsd/sys/net/if.cc). - The
if_indextonameneeds support in ioctl layer (see missing handling of SIOCGIFNAME inbsd/sys/compat/linux/linux_ioctl.cc).