gvisor icon indicating copy to clipboard operation
gvisor copied to clipboard

bind to multicast address fails unless group membership is present

Open tamird opened this issue 5 years ago • 4 comments

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, &param, 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.

tamird avatar Sep 02 '20 19:09 tamird

cc @ghanan94

tamird avatar Sep 02 '20 20:09 tamird

Over to @ghanan94 who might know more about this.

tamird avatar Jun 02 '21 15:06 tamird

A friendly reminder that this issue had no activity for 120 days.

github-actions[bot] avatar Sep 14 '23 00:09 github-actions[bot]

A friendly reminder that this issue had no activity for 120 days.

github-actions[bot] avatar Feb 09 '24 00:02 github-actions[bot]

This issue has been closed due to lack of activity.

github-actions[bot] avatar May 09 '24 00:05 github-actions[bot]