Module: kamailio Branch: master Commit: 600490c546502786eaef1f2bfbeb18a5bb2a2ee1 URL: https://github.com/kamailio/kamailio/commit/600490c546502786eaef1f2bfbeb18a5...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-04-25T21:01:12+02:00
core: new global parameter bind_ipv6_link_local
- if set to 1, try to bind also IPv6 link local addresses by discovering the scope of the interface - apply it for udp socket for now, to be added for the other cases
---
Modified: src/core/cfg.lex Modified: src/core/cfg.y Modified: src/core/globals.h Modified: src/core/udp_server.c Modified: src/main.c
---
Diff: https://github.com/kamailio/kamailio/commit/600490c546502786eaef1f2bfbeb18a5... Patch: https://github.com/kamailio/kamailio/commit/600490c546502786eaef1f2bfbeb18a5...
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex index 706c1b05ce..dd1b935d8f 100644 --- a/src/core/cfg.lex +++ b/src/core/cfg.lex @@ -329,6 +329,7 @@ DNS_CACHE_DEL_NONEXP dns_cache_del_nonexp|dns_cache_delete_nonexpired DNS_CACHE_REC_PREF dns_cache_rec_pref /* ipv6 auto bind */ AUTO_BIND_IPV6 auto_bind_ipv6 +BIND_IPV6_LINK_LOCAL bind_ipv6_link_local /* blacklist */ DST_BLST_INIT dst_blacklist_init USE_DST_BLST use_dst_blacklist @@ -763,6 +764,8 @@ IMPORTFILE "import_file" return DNS_CACHE_REC_PREF; } <INITIAL>{AUTO_BIND_IPV6} { count(); yylval.strval=yytext; return AUTO_BIND_IPV6; } +<INITIAL>{BIND_IPV6_LINK_LOCAL} { count(); yylval.strval=yytext; + return BIND_IPV6_LINK_LOCAL; } <INITIAL>{DST_BLST_INIT} { count(); yylval.strval=yytext; return DST_BLST_INIT; } <INITIAL>{USE_DST_BLST} { count(); yylval.strval=yytext; diff --git a/src/core/cfg.y b/src/core/cfg.y index 2610364481..4c7dcd1307 100644 --- a/src/core/cfg.y +++ b/src/core/cfg.y @@ -357,6 +357,7 @@ extern char *default_routename;
/* ipv6 auto bind */ %token AUTO_BIND_IPV6 +%token BIND_IPV6_LINK_LOCAL
/*blacklist*/ %token DST_BLST_INIT @@ -867,6 +868,8 @@ assign_stm: | DNS_CACHE_REC_PREF error { yyerror("boolean value expected"); } | AUTO_BIND_IPV6 EQUAL NUMBER {IF_AUTO_BIND_IPV6(auto_bind_ipv6 = $3);} | AUTO_BIND_IPV6 error { yyerror("boolean value expected"); } + | BIND_IPV6_LINK_LOCAL EQUAL NUMBER {sr_bind_ipv6_link_local = $3;} + | BIND_IPV6_LINK_LOCAL error { yyerror("boolean value expected"); } | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); } | DST_BLST_INIT error { yyerror("boolean value expected"); } | USE_DST_BLST EQUAL NUMBER { diff --git a/src/core/globals.h b/src/core/globals.h index 0e9e950c62..3790058075 100644 --- a/src/core/globals.h +++ b/src/core/globals.h @@ -140,6 +140,7 @@ extern char* mcast; #endif /* USE_MCAST */
extern int auto_bind_ipv6; +extern int sr_bind_ipv6_link_local;
extern int tos; extern int pmtu_discovery; diff --git a/src/core/udp_server.c b/src/core/udp_server.c index 7017b85c7b..2b874ab2ed 100644 --- a/src/core/udp_server.c +++ b/src/core/udp_server.c @@ -49,6 +49,7 @@ #include "receive.h" #include "mem/mem.h" #include "ip_addr.h" +#include "socket_info.h" #include "cfg/cfg_struct.h" #include "events.h" #include "stun.h" @@ -319,6 +320,11 @@ int udp_init(struct socket_info* sock_info) LM_WARN("setsockopt v6 tos: %s\n", strerror(errno)); /* continue since this is not critical */ } + if(sr_bind_ipv6_link_local!=0) { + LM_INFO("setting scope of %s\n", sock_info->address_str.s); + addr->sin6.sin6_scope_id = + ipv6_get_netif_scope(sock_info->address_str.s); + } }
#if defined (__OS_linux) && defined(UDP_ERRORS) @@ -397,8 +403,9 @@ int udp_init(struct socket_info* sock_info) (unsigned)sockaddru_len(*addr), sock_info->address_str.s, strerror(errno)); - if (addr->s.sa_family==AF_INET6) - LM_ERR("might be caused by using a link local address, try site local or global\n"); + if (addr->s.sa_family==AF_INET6) { + LM_ERR("might be caused by using a link local address, is 'bind_ipv6_link_local' set?\n"); + } goto error; }
diff --git a/src/main.c b/src/main.c index d052ee4e97..6d6d390306 100644 --- a/src/main.c +++ b/src/main.c @@ -426,6 +426,7 @@ int tos = IPTOS_LOWDELAY; int pmtu_discovery = 0;
int auto_bind_ipv6 = 0; +int sr_bind_ipv6_link_local = 0;
struct socket_info* udp_listen=0; #ifdef USE_TCP