diff options
author | Erlang/OTP <otp@erlang.org> | 2022-05-02 12:28:04 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2022-05-02 12:28:04 +0200 |
commit | fad08c34d478b1f5e554e121de1146f02ac91652 (patch) | |
tree | b3ea5b4cc2770c9c6477f8ba4b884ea142fa1190 | |
parent | 78847665b879f723d1c7f20fc173a2340981b727 (diff) | |
parent | 1fe90ef8005ce1256b68f01fa0c2b7b5a58f27c4 (diff) | |
download | erlang-fad08c34d478b1f5e554e121de1146f02ac91652.tar.gz |
Merge branch 'big-r81/epmd-nonfatal-loopback/OTP-17970' into maint-23
* big-r81/epmd-nonfatal-loopback/OTP-17970:
epmd: don't fail if non-critical interfaces fail to bind
-rw-r--r-- | erts/epmd/src/epmd_srv.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c index ad264585c6..362173a3f4 100644 --- a/erts/epmd/src/epmd_srv.c +++ b/erts/epmd/src/epmd_srv.c @@ -239,6 +239,7 @@ void run(EpmdVars *g) char socknamebuf[INET_ADDRSTRLEN]; #endif int num_sockets = 0; + int nonfatal_sockets = 0; int i; int opt; unsigned short sport = g->port; @@ -296,6 +297,14 @@ void run(EpmdVars *g) num_sockets++; #endif + /* IPv4 and/or IPv6 loopback may not be present, for example if + * the protocol stack is explicitly disabled in the kernel. If + * any sockets to this point fail, log the error but do not exit + * with failure. If any socket after this (explicitly + * configured via addresses) fails, then consider the error + * fatal. */ + nonfatal_sockets = num_sockets; + if ((tmp = strdup(g->addresses)) == NULL) { dbg_perror(g,"cannot allocate memory"); @@ -411,7 +420,6 @@ void run(EpmdVars *g) epmd_cleanup_exit(g,1); } } - g->listenfd[bound++] = listensock[i]; #if HAVE_DECL_IPV6_V6ONLY opt = 1; @@ -469,7 +477,14 @@ void run(EpmdVars *g) dbg_perror(g,"failed to bind on ipaddr %s", epmd_ntop(&iserv_addr[num_sockets], socknamebuf, sizeof(socknamebuf))); - epmd_cleanup_exit(g,1); + if (i >= nonfatal_sockets) + epmd_cleanup_exit(g,1); + else + { + close(listensock[i]); + continue; + } + } } @@ -479,6 +494,7 @@ void run(EpmdVars *g) socknamebuf, sizeof(socknamebuf))); epmd_cleanup_exit(g,1); } + g->listenfd[bound++] = listensock[i]; select_fd_set(g, listensock[i]); } if (bound == 0) { |