Skip to content
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

src/core: Added IP_FREEBIND flag durring socket initialization #1104

Merged
merged 1 commit into from May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/tcp_main.c
Expand Up @@ -2782,6 +2782,13 @@ int tcp_init(struct socket_info* sock_info)
/* continue since this is not critical */
}
}

/* Allow bind to non local address. Required when daemon started before network initialized */
if (setsockopt(sock_info->socket, IPPROTO_IP, IP_FREEBIND,
(void*)&optval, sizeof(optval)) ==-1) {
LM_WARN("setsockopt freebind: %s\n", strerror(errno));
/* continue since this is not critical */
}
#ifdef HAVE_TCP_DEFER_ACCEPT
/* linux only */
if ((optval=cfg_get(tcp, tcp_cfg, defer_accept))){
Expand Down
8 changes: 8 additions & 0 deletions src/core/udp_server.c
Expand Up @@ -339,6 +339,14 @@ int udp_init(struct socket_info* sock_info)
}
#endif

/* Allow bind to non local address. Required when daemon started before network initialized */
optval = 1;
if (setsockopt(sock_info->socket, IPPROTO_IP, IP_FREEBIND,
(void*)&optval, sizeof(optval)) ==-1) {
LM_WARN("setsockopt freebind: %s\n", strerror(errno));
/* continue since this is not critical */
}

#ifdef USE_MCAST
if ((sock_info->flags & SI_IS_MCAST)
&& (setup_mcast_rcvr(sock_info->socket, addr, sock_info->mcast.s)<0)){
Expand Down
8 changes: 8 additions & 0 deletions src/modules/sctp/sctp_server.c
Expand Up @@ -469,6 +469,14 @@ static int sctp_init_sock_opt_common(int s, int af)
}
}

/* Allow bind to non local address. Required when daemon started before network initialized */
optval = 1;
if (setsockopt(s, IPPROTO_IP, IP_FREEBIND,
(void*)&optval, sizeof(optval)) ==-1) {
LM_WARN("sctp_init_sock_opt_common: setsockopt freebind %s\n", strerror(errno));
/* continue since this is not critical */
}

/* set receive buffer: SO_RCVBUF*/
if (cfg_get(sctp, sctp_cfg, so_rcvbuf)){
optval=cfg_get(sctp, sctp_cfg, so_rcvbuf);
Expand Down