Skip to content
Snippets Groups Projects
Commit e90bc908 authored by Ondřej Surý's avatar Ondřej Surý Committed by Jan Včelák
Browse files

Set IP_FREEBIND on socket before bind to allow start before the network is fully up

parent c6874dc3
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif
#include <netinet/in.h>
#include <sys/stat.h>
#include <assert.h>
......@@ -82,6 +83,11 @@ int net_bound_socket(int type, const struct sockaddr_storage *ss)
&flag, sizeof(flag));
}
/* Allow bind to non-local address (Linux) */
#ifdef IP_FREEBIND
(void) setsockopt(socket, IPPROTO_IP, IP_FREEBIND, &flag, sizeof(flag));
#endif
/* Bind to specified address. */
const struct sockaddr *sa = (const struct sockaddr *)ss;
int ret = bind(socket, sa, sockaddr_len(sa));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment