On Linux, one may query even a network interface that doesn't have the "BROADCAST" flag with SIOCGIFBRDADDR - for example, the loopback interface does not have this flag and yet in Linux, one may query it for the broadcast address and it doesn't fail (the interfaces address is returned).
Trying to query the broadcast address of an interface without one is not very useful, but unfortunately musl's getifaddrs() implementation does this (it assumes any non point-to-point interface has a broadcast address, which is wrong for the loopback interface) and Linux is graceful about it, and so should we, to be compatible with Linux. With this patch (and the previous patch to another ioctl), the getifaddrs() now works. Fixes #783. Signed-off-by: Nadav Har'El <n...@scylladb.com> --- bsd/sys/netinet/in.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bsd/sys/netinet/in.cc b/bsd/sys/netinet/in.cc index 563a8b3..1520b30 100644 --- a/bsd/sys/netinet/in.cc +++ b/bsd/sys/netinet/in.cc @@ -431,11 +431,13 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, goto out; case SIOCGIFBRDADDR: +#if 0 if ((ifp->if_flags & IFF_BROADCAST) == 0) { error = EINVAL; goto out; } - *((struct bsd_sockaddr_in *)&ifr->ifr_dstaddr) = ia->ia_broadaddr; +#endif + *((struct bsd_sockaddr_in *)&ifr->ifr_broadaddr) = ia->ia_broadaddr; goto out; case SIOCGIFDSTADDR: -- 2.5.5 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.