Module: kamailio
Branch: master
Commit: 7036c0ea947d6450e6a23c2e5b2428c834352de0
URL:
https://github.com/kamailio/kamailio/commit/7036c0ea947d6450e6a23c2e5b2428c…
Author: Sergey Safarov <s.safarov(a)gmail.com>
Committer: Sergey Safarov <s.safarov(a)gmail.com>
Date: 2017-04-29T15:33:03-04:00
src/core: Added IP_FREEBIND flag durring socket initialization
---
Modified: src/core/tcp_main.c
Modified: src/core/udp_server.c
Modified: src/modules/sctp/sctp_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7036c0ea947d6450e6a23c2e5b2428c…
Patch:
https://github.com/kamailio/kamailio/commit/7036c0ea947d6450e6a23c2e5b2428c…
---
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index 14dcaea..b9af4e8 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -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))){
diff --git a/src/core/udp_server.c b/src/core/udp_server.c
index cff4ef0..96ba8eb 100644
--- a/src/core/udp_server.c
+++ b/src/core/udp_server.c
@@ -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)){
diff --git a/src/modules/sctp/sctp_server.c b/src/modules/sctp/sctp_server.c
index e2301f0..686139c 100644
--- a/src/modules/sctp/sctp_server.c
+++ b/src/modules/sctp/sctp_server.c
@@ -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);