Summary: | IPV6 Non-Local Bind Operation timeout. | ||
---|---|---|---|
Product: | Base System | Reporter: | todenerey |
Component: | kern | Assignee: | freebsd-net (Nobody) <net> |
Status: | New --- | ||
Severity: | Affects Only Me | CC: | zlei |
Priority: | --- | ||
Version: | Unspecified | ||
Hardware: | Any | ||
OS: | Any |
Description
todenerey
2022-07-29 00:23:24 UTC
(In reply to todenerey from comment #0) Can you please share a minimal program to demonstrate? (In reply to Zhenlei Huang from comment #1) #include <stdio.h> #include <arpa/inet.h> #include <unistd.h> #include <netinet/in.h> #include <sys/socket.h> const char *bind_ip = " "; // My /64 block ip. const char *HOST = "2a01:4f8:c0c:bd0a::1"; const int PORT = 80; int main() { int sockfd; struct sockaddr_in6 sin; struct sockaddr_in6 sa; sockfd = socket(AF_INET6, SOCK_STREAM, 0); if(sockfd == -1) { perror("Socket error: "); return 1; } int on = 1; setsockopt(sockfd, IPPROTO_IPV6, IPV6_BINDANY, &on, sizeof(on)); sin.sin6_family = AF_INET6; sin.sin6_port = htons(0); if(inet_pton(AF_INET6, bind_ip, &sin.sin6_addr) != 1) { fprintf(stderr, "Invalid bind source address.\n"); return 1; } sa.sin6_family = AF_INET6; sa.sin6_port = htons(PORT); if(inet_pton(AF_INET6, HOST, &sa.sin6_addr) != 1) { fprintf(stderr, "Invalid host address.\n"); return 1; } if(bind(sockfd, (struct sockaddr *) &sin, sizeof(sin)) == -1) { perror("Bind error: "); return 1; } if(connect(sockfd, (struct sockaddr *)&sa, sizeof(sa)) != 0) { perror("Connect error: "); return 1; } printf("Connection successful!\n"); close(sockfd); return 0; } |