Module: kamailio
Branch: master
Commit: 86770d203bde6859284ec8862be66d78efd2715a
URL:
https://github.com/kamailio/kamailio/commit/86770d203bde6859284ec8862be66d7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-09-13T08:50:35+02:00
core: check for incompatible modes for bind_ipv6_link_local
- a few more debug messages
---
Modified: src/core/cfg.y
Modified: src/core/socket_info.c
Modified: src/core/tcp_main.c
Modified: src/core/udp_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/86770d203bde6859284ec8862be66d7…
Patch:
https://github.com/kamailio/kamailio/commit/86770d203bde6859284ec8862be66d7…
---
diff --git a/src/core/cfg.y b/src/core/cfg.y
index a6ad69b3148..ae1c9ec4b0b 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -999,7 +999,12 @@ assign_stm:
ksr_ipv6_hex_style.len = strlen(ksr_ipv6_hex_style.s);
}
| IPV6_HEX_STYLE error { yyerror("string value expected"); }
- | BIND_IPV6_LINK_LOCAL EQUAL NUMBER {sr_bind_ipv6_link_local = $3;}
+ | BIND_IPV6_LINK_LOCAL EQUAL NUMBER {
+ sr_bind_ipv6_link_local = $3;
+ if(sr_bind_ipv6_link_local &&
(KSR_IPV6_LINK_LOCAL_BIND|KSR_IPV6_LINK_LOCAL_SKIP)) {
+ yyerror("incompatible modes set");
+ }
+ }
| BIND_IPV6_LINK_LOCAL error { yyerror("number expected"); }
| DST_BLST_INIT EQUAL NUMBER { IF_DST_BLOCKLIST(dst_blocklist_init=$3); }
| DST_BLST_INIT error { yyerror("boolean value expected"); }
diff --git a/src/core/socket_info.c b/src/core/socket_info.c
index 4cf1693560a..446878d6b23 100644
--- a/src/core/socket_info.c
+++ b/src/core/socket_info.c
@@ -1609,11 +1609,15 @@ static int build_iface_list(void)
if(is_link_local) {
if(sr_bind_ipv6_link_local & KSR_IPV6_LINK_LOCAL_SKIP) {
/* skip - config option */
+ LM_DBG("skip binding on '%s' (bind mode: %d)\n",
+ entry->addr, sr_bind_ipv6_link_local);
pkg_free(entry);
continue;
}
if(!(sr_bind_ipv6_link_local & KSR_IPV6_LINK_LOCAL_BIND)) {
/* skip - link local addresses are not bindable without scope */
+ LM_DBG("not set to on '%s' (bind mode: %d)\n", entry->addr,
+ sr_bind_ipv6_link_local);
pkg_free(entry);
continue;
}
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index f5ca2d9ad55..9daaf1ce641 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -3148,7 +3148,8 @@ int tcp_init(struct socket_info *sock_info)
if((addr->s.sa_family == AF_INET6)
&& (sr_bind_ipv6_link_local & KSR_IPV6_LINK_LOCAL_SKIP)
&& IN6_IS_ADDR_LINKLOCAL(&addr->sin6.sin6_addr)) {
- LM_DBG("skip binding on %s\n", sock_info->address_str.s);
+ LM_DBG("skip binding on %s (bind mode: %d)\n", sock_info->address_str.s,
+ sr_bind_ipv6_link_local);
return 0;
}
/* sock_info->proto=PROTO_TCP; */
@@ -3219,7 +3220,8 @@ int tcp_init(struct socket_info *sock_info)
/* continue since this is not critical */
}
if(sr_bind_ipv6_link_local & KSR_IPV6_LINK_LOCAL_BIND) {
- LM_INFO("setting scope of %s\n", sock_info->address_str.s);
+ LM_INFO("setting scope of %s (bind mode: %d)\n",
+ sock_info->address_str.s, sr_bind_ipv6_link_local);
addr->sin6.sin6_scope_id =
ipv6_get_netif_scope(sock_info->address_str.s);
}
diff --git a/src/core/udp_server.c b/src/core/udp_server.c
index ef7d2894d0d..476ff0fd9e9 100644
--- a/src/core/udp_server.c
+++ b/src/core/udp_server.c
@@ -418,7 +418,8 @@ int udp_init(struct socket_info *sock_info)
if((addr->s.sa_family == AF_INET6)
&& (sr_bind_ipv6_link_local & KSR_IPV6_LINK_LOCAL_SKIP)
&& IN6_IS_ADDR_LINKLOCAL(&addr->sin6.sin6_addr)) {
- LM_DBG("skip binding on %s\n", sock_info->address_str.s);
+ LM_DBG("skip binding on %s (mode: %d)\n", sock_info->address_str.s,
+ sr_bind_ipv6_link_local);
return 0;
}
@@ -465,7 +466,8 @@ int udp_init(struct socket_info *sock_info)
/* continue since this is not critical */
}
if(sr_bind_ipv6_link_local & KSR_IPV6_LINK_LOCAL_BIND) {
- LM_INFO("setting scope of %s\n", sock_info->address_str.s);
+ LM_INFO("setting scope of %s (bind mode: %d)\n",
+ sock_info->address_str.s, sr_bind_ipv6_link_local);
addr->sin6.sin6_scope_id =
ipv6_get_netif_scope(sock_info->address_str.s);
}