-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
test: change the UDP multicast to a administratively scoped range #4314
Conversation
494e000
to
9ec7160
Compare
After a lot of pain and horrible macOS documentation, I did not found the actual reason, but I created a a minimal repro case for this issue, and it is persistent, even without libuv. #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <net/if.h>
#define MULTICAST_ADDR "239.255.0.1"
#define PORT 9123
int main() {
int sockfd;
struct sockaddr_in addr;
struct ip_mreq mreq;
struct ifreq ifr;
// Create a UDP socket
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket creation failed");
exit(1);
}
// Set up the multicast address
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(PORT);
// Bind the socket
if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind failed");
exit(1);
}
// Set up multicast group membership
memset(&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr.s_addr = inet_addr(MULTICAST_ADDR);
mreq.imr_interface.s_addr = INADDR_ANY;
if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
perror("setsockopt failed");
exit(1);
}
printf("Multicast group joined successfully\n");
// Close the socket
close(sockfd);
return 0;
} That prints ➜ ./build/uv_run_tests_a udp_multicast_join udp_multicast_join
Assertion failed in /Users/juanjose/GitHub/libuv/test/test-udp-multicast-join.c on line 131: `r == 0` (-16 == 0)
[1] 56998 abort ./build/uv_run_tests_a udp_multicast_join udp_multicast_join
libuv on juan/fix-macos-test [⇡!]
➜ ./build/uv_run_tests_a udp_multicast_join udp_multicast_join
setsockopt failed: : Exec format error
Assertion failed in /Users/juanjose/GitHub/libuv/test/test-udp-multicast-join.c on line 163: `r == 0` (-8 == 0)
[1] 57723 abort ./build/uv_run_tests_a udp_multicast_join udp_multicast_join I'm sorry for not getting an answer for this, macOS is simply obscure or I'm not the best at searching or both. |
@juanarbol thanks for investigating. I don't really have suggestions what to do next. Maybe we should just chalk this up as "fact of life" (and: "closed-source proprietary operating systems suck") |
Fixes: libuv#4263 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
9ec7160
to
e37b5ff
Compare
I found the solution, you were completely right since the beginning. After those settings, I get the regular "Allow this..." and the test never fails in |
Fixes: #4263