You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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_nametoindex returns 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 zeroing ifr.ifr_ifindex in if_nametoindex.c before 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.cc or bsd/sys/kern/sys_socket.cc or bsd/sys/net/if.cc).
The if_indextoname needs support in ioctl layer (see missing handling of SIOCGIFNAME in bsd/sys/compat/linux/linux_ioctl.cc).
The text was updated successfully, but these errors were encountered:
The implementation of
if_nametoindex()/if_indextoname()
copied from musl underlibc/network/if_nametoindex.c
andlibc/network/if_indextoname.c
has number of problems:fd = socket(AF_UNIX, SOCK_DGRAM, 0)
); instead we neeed to use AF_INET like if_nameindex uses - see c4df104)if_nametoindex
returns 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_ifindex
inif_nametoindex.c
before 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.cc
orbsd/sys/kern/sys_socket.cc
orbsd/sys/net/if.cc
).if_indextoname
needs support in ioctl layer (see missing handling of SIOCGIFNAME inbsd/sys/compat/linux/linux_ioctl.cc
).The text was updated successfully, but these errors were encountered: