gvisor
gvisor copied to clipboard
bind to multicast address fails unless group membership is present
Failing snippet:
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
};
#if defined(__Fuchsia__) // stand-in for gvisor
fbl::unique_fd s;
#endif
if (multicast) {
int n = inet_pton(addr.sin_family, "224.0.2.1", &addr.sin_addr);
ASSERT_GE(n, 0) << strerror(errno);
ASSERT_EQ(n, 1);
#if defined(__Fuchsia__)
ASSERT_TRUE(s = fbl::unique_fd(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))) << strerror(errno);
ip_mreqn param = {
.imr_multiaddr = addr.sin_addr,
.imr_address.s_addr = htonl(INADDR_ANY),
.imr_ifindex = 1,
};
ASSERT_EQ(setsockopt(s.get(), SOL_IP, IP_ADD_MEMBERSHIP, ¶m, sizeof(param)), 0)
<< strerror(errno);
#endif
}
fbl::unique_fd s1;
ASSERT_TRUE(s1 = fbl::unique_fd(socket(AF_INET, type, 0))) << strerror(errno);
ASSERT_EQ(setsockopt(s1.get(), SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)), 0) << strerror(errno);
ASSERT_EQ(bind(s1.get(), reinterpret_cast<const struct sockaddr*>(&addr), sizeof(addr)), 0)
<< strerror(errno); // this fails on gvisor without the `#if defined` above
@hbhasker for triage.
cc @ghanan94
Over to @ghanan94 who might know more about this.
A friendly reminder that this issue had no activity for 120 days.
A friendly reminder that this issue had no activity for 120 days.
This issue has been closed due to lack of activity.