Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: test udp_multicast_join fails on macOS 13 and above #4263

Open
mizvekov opened this issue Dec 20, 2023 · 10 comments
Open

macOS: test udp_multicast_join fails on macOS 13 and above #4263

mizvekov opened this issue Dec 20, 2023 · 10 comments

Comments

@mizvekov
Copy link
Contributor

Fails with:

not ok 403 - udp_multicast_join
# exit code 6
# Output from process `udp_multicast_join`:
# Assertion failed in test/test-udp-multicast-join.c on line 163: `r == 0` (-8 == 0)

Failure happens on udp_set_membership / setsockopt call.

For reference, see: https://github.com/libuv/libuv/actions/runs/7277757514/job/19830481286#step:5:508

@bnoordhuis
Copy link
Member

It's probably a firewall issue (common issue with the multicast tests) but that -8 error code is kind of odd, that's ENOEXEC.

@juanarbol
Copy link
Contributor

I could work on this.

@bnoordhuis
Copy link
Member

You're welcome to. Do you know what the root cause is?

@juanarbol
Copy link
Contributor

No yet... I'm investigating

@juanarbol
Copy link
Contributor

I think I found the problem, but I'm not sure why is happening:

diff --git a/src/unix/udp.c b/src/unix/udp.c
index c2814512..29742136 100644
--- a/src/unix/udp.c
+++ b/src/unix/udp.c
@@ -811,7 +811,7 @@ static int uv__udp_set_membership4(uv_udp_t* handle,
     mreq.imr_interface.s_addr = htonl(INADDR_ANY);
   }
 
-  mreq.imr_multiaddr.s_addr = multicast_addr->sin_addr.s_addr;
+  mreq.imr_multiaddr.s_addr = inet_addr("239.255.255.250");
 
   switch (membership) {
   case UV_JOIN_GROUP:

That diff will make the setsockopt works, but sure the test runner will hang.

Maybe the problem is in uv_ip4_addr(multicast_addr...)

if (uv_ip4_addr(multicast_addr, 0, &addr4) == 0) {
, is the only function touching the multicast_addr struct.

Any hints? Or ideas?

@bnoordhuis
Copy link
Member

The test tries to join the multicast group with address 239.255.0.1.

My best guess is that address is completely blocked off, whereas 239.255.255.250 is available(ish) but not able to send or receive datagrams.

See if starts working when you disable the macos firewall completely.

@juanarbol
Copy link
Contributor

I have my firewall disabled, It has been disabled this whole time

@bnoordhuis
Copy link
Member

Ah, okay. I don't have a good hypothesis then. Do local subnet addresses (224.0.0.x) work?

@juanarbol
Copy link
Contributor

Ok, this is really weird; I'm using the next Node.js UDP server

const dgram = require('dgram');

const MULTICAST_ADDR = '224.0.0.4';
const PORT = 1234;

const socket = dgram.createSocket({ type: 'udp4', reuseAddr: true });

socket.on('error', (err) => {
  console.error(`Socket error: ${err}`);
  socket.close();
});

socket.on('listening', () => {
  console.log(`Socket listening on ${socket.address().address}:${socket.address().port}`);
});

socket.on('message', (msg, rinfo) => {
  console.log(`Received message from ${rinfo.address}:${rinfo.port}: ${msg}`);
});

socket.bind(PORT, () => {
  socket.addMembership(MULTICAST_ADDR);
  console.log(`Joined multicast group ${MULTICAST_ADDR}`);
});

If I run that, and change the test to use that address, the test passes, normally. Now, If I kill that server and try to run that server again, I get the same -8 error code that I get in libuv. Anyway, the test won't pass unless a run a UDP server.

juanarbol added a commit to juanarbol/libuv that referenced this issue Apr 25, 2024
Fixes: libuv#4263
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
juanarbol added a commit to juanarbol/libuv that referenced this issue May 9, 2024
Fixes: libuv#4263
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
@juanarbol
Copy link
Contributor

It is a firewall issue.

#4314 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants