Browse Source

gossipd: Do not report bind failures for IPv4

ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
3d2ef44064
  1. 7
      gossipd/gossip.c

7
gossipd/gossip.c

@ -1194,7 +1194,7 @@ out:
return daemon_conn_read_next(conn, &daemon->master);
}
static int make_listen_fd(int domain, void *addr, socklen_t len)
static int make_listen_fd(int domain, void *addr, socklen_t len, bool reportfail)
{
int fd = socket(domain, SOCK_STREAM, 0);
if (fd < 0) {
@ -1212,6 +1212,7 @@ static int make_listen_fd(int domain, void *addr, socklen_t len)
strerror(errno));
if (bind(fd, addr, len) != 0) {
if (reportfail)
status_trace("Failed to bind on %u socket: %s",
domain, strerror(errno));
goto fail;
@ -1431,7 +1432,7 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
addr6.sin6_port = htons(portnum);
/* IPv6, since on Linux that (usually) binds to IPv4 too. */
fd1 = make_listen_fd(AF_INET6, &addr6, sizeof(addr6));
fd1 = make_listen_fd(AF_INET6, &addr6, sizeof(addr6), true);
if (fd1 >= 0) {
struct sockaddr_in6 in6;
@ -1451,7 +1452,7 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
}
/* Just in case, aim for the same port... */
fd2 = make_listen_fd(AF_INET, &addr, sizeof(addr));
fd2 = make_listen_fd(AF_INET, &addr, sizeof(addr), false);
if (fd2 >= 0) {
len = sizeof(addr);
if (getsockname(fd2, (void *)&addr, &len) != 0) {

Loading…
Cancel
Save