[sr-dev] git:master: core: added parameter to enable/ disable automatic binding of ipv6 interfaces
Daniel-Constantin Mierla
miconda at gmail.com
Thu Oct 13 21:54:53 CEST 2011
Hello,
does this parameter has any impact when changed at runtime? If not, then
maybe is better to be stored just in a variable, not as part of the
cfg_group_core structure that can be reloaded at runtime -- it makes
that structure bigger without a reason and I assume it may have some
impact while looking to see what fields have been updated during runtime.
Cheers,
Daniel
On 10/13/11 9:53 AM, Marius Zbihlei wrote:
> Module: sip-router
> Branch: master
> Commit: bd3d3546af5e52263ed803000f8b490b96108504
> URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bd3d3546af5e52263ed803000f8b490b96108504
>
> Author: Marius Zbihlei<marius.zbihlei at 1and1.ro>
> Committer: Marius Zbihlei<marius.zbihlei at 1and1.ro>
> Date: Tue Oct 11 11:35:56 2011 +0300
>
> core: added parameter to enable/disable automatic binding of ipv6 interfaces
> TODO: documentation
>
> ---
>
> cfg.lex | 4 ++++
> cfg.y | 11 +++++++++++
> cfg_core.c | 8 ++++++++
> cfg_core.h | 5 +++++
> socket_info.c | 18 +++++++++---------
> 5 files changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/cfg.lex b/cfg.lex
> index ff35a8a..4a19fe1 100644
> --- a/cfg.lex
> +++ b/cfg.lex
> @@ -370,6 +370,8 @@ DNS_CACHE_MAX_TTL dns_cache_max_ttl
> DNS_CACHE_MEM dns_cache_mem
> DNS_CACHE_GC_INT dns_cache_gc_interval
> DNS_CACHE_DEL_NONEXP dns_cache_del_nonexp|dns_cache_delete_nonexpired
> +/* ipv6 auto bind */
> +AUTO_BIND_IPV6 auto_bind_ipv6
> /* blacklist */
> DST_BLST_INIT dst_blacklist_init
> USE_DST_BLST use_dst_blacklist
> @@ -751,6 +753,8 @@ IMPORTFILE "import_file"
> return DNS_CACHE_GC_INT; }
> <INITIAL>{DNS_CACHE_DEL_NONEXP} { count(); yylval.strval=yytext;
> return DNS_CACHE_DEL_NONEXP; }
> +<INITIAL>{AUTO_BIND_IPV6} { count(); yylval.strval=yytext;
> + return AUTO_BIND_IPV6; }
> <INITIAL>{DST_BLST_INIT} { count(); yylval.strval=yytext;
> return DST_BLST_INIT; }
> <INITIAL>{USE_DST_BLST} { count(); yylval.strval=yytext;
> diff --git a/cfg.y b/cfg.y
> index 4290e41..ab9b126 100644
> --- a/cfg.y
> +++ b/cfg.y
> @@ -164,6 +164,11 @@
> if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
> }while(0)
>
> +#ifdef USE_IPV6
> + #define IF_AUTO_BIND_IPV6(x) x
> +#else
> + #define IF_AUTO_BIND_IPV6(x) warn("IPV6 support not compiled");
> +#endif
>
> #ifdef USE_DNS_CACHE
> #define IF_DNS_CACHE(x) x
> @@ -419,6 +424,10 @@ extern char *finame;
> %token DNS_CACHE_MEM
> %token DNS_CACHE_GC_INT
> %token DNS_CACHE_DEL_NONEXP
> +
> +/* ipv6 auto bind */
> +%token AUTO_BIND_IPV6
> +
> /*blacklist*/
> %token DST_BLST_INIT
> %token USE_DST_BLST
> @@ -877,6 +886,8 @@ assign_stm:
> | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
> | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
> | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
> + | AUTO_BIND_IPV6 EQUAL NUMBER {IF_AUTO_BIND_IPV6(default_core_cfg.auto_bind_ipv6 = $3);}
> + | AUTO_BIND_IPV6 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/cfg_core.c b/cfg_core.c
> index 27a55b3..bd5a00d 100644
> --- a/cfg_core.c
> +++ b/cfg_core.c
> @@ -105,6 +105,9 @@ struct cfg_group_core default_core_cfg = {
> 0, /*!< dns_cache_del_nonexp -- delete only expired entries by default */
> 0, /*!< dns_cache_rec_pref -- 0 by default, do not check the existing entries. */
> #endif
> +#ifdef USE_IPV6
> + 0, /*!< auto_bind_ipv6 -- off by default */
> +#endif
> #ifdef PKG_MALLOC
> 0, /*!< mem_dump_pkg */
> #endif
> @@ -272,6 +275,11 @@ cfg_def_t core_cfg_def[] = {
> " 2 - prefer new records"
> " 3 - prefer records with longer lifetime"},
> #endif
> +#ifdef USE_IPV6
> + {"auto_bind_ipv6", CFG_VAR_INT, 0, 1, 0, 0, 0,
> + "enable/disable auto binding of proxy to IPV6 interfaces."
> + "default is disabled 0"},
> +#endif
> #ifdef PKG_MALLOC
> {"mem_dump_pkg", CFG_VAR_INT, 0, 0, 0, mem_dump_pkg_cb,
> "dump process memory status, parameter: pid_number"},
> diff --git a/cfg_core.h b/cfg_core.h
> index 25f69ae..ada5b89 100644
> --- a/cfg_core.h
> +++ b/cfg_core.h
> @@ -93,6 +93,11 @@ struct cfg_group_core {
> int dns_cache_del_nonexp;
> int dns_cache_rec_pref;
> #endif
> +
> +#ifdef USE_IPV6
> + int auto_bind_ipv6;
> +#endif
> +
> #ifdef PKG_MALLOC
> int mem_dump_pkg;
> #endif
> diff --git a/socket_info.c b/socket_info.c
> index 73a5cf3..4e7d27e 100644
> --- a/socket_info.c
> +++ b/socket_info.c
> @@ -1712,9 +1712,9 @@ int fix_all_socket_lists()
> if ( ( (add_interfaces(0, AF_INET, 0, PROTO_UDP,&ai_lst)==0)
> #ifdef USE_IPV6
> #ifdef __OS_linux
> - && (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_UDP,&ai_lst) == 0)
> + && (!(cfg_get(core, core_cfg, auto_bind_ipv6)) || add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_UDP,&ai_lst) == 0)
> #else
> - && (add_interfaces(0, AF_INET6, 0, PROTO_UDP,&ai_lst)==0) /* add_interface does not work for IPv6 on Linux */
> + && ( !(cfg_get(core, core_cfg, auto_bind_ipv6)) || add_interfaces(0, AF_INET6, 0, PROTO_UDP,&ai_lst) !=0 ) /* add_interface does not work for IPv6 on Linux */
> #endif /* __OS_linux */
> #endif /* USE_IPV6 */
> )&& (addr_info_to_si_lst(ai_lst, 0, PROTO_UDP, 0,&udp_listen)==0)){
> @@ -1726,12 +1726,12 @@ int fix_all_socket_lists()
> if ( ((add_interfaces(0, AF_INET, 0, PROTO_TCP,&ai_lst)!=0)
> #ifdef USE_IPV6
> #ifdef __OS_linux
> - || (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TCP,&ai_lst) != 0)
> + || (cfg_get(core, core_cfg, auto_bind_ipv6)&& add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TCP,&ai_lst) != 0)
> #else
> - || (add_interfaces(0, AF_INET6, 0, PROTO_TCP,&ai_lst)!=0)
> + || (cfg_get(core, core_cfg, auto_bind_ipv6)&& add_interfaces(0, AF_INET6, 0, PROTO_TCP,&ai_lst) !=0 )
> #endif /* __OS_linux */
> #endif /* USE_IPV6 */
> - )|| (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0,
> + ) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0,
> &tcp_listen)!=0))
> goto error;
> free_addr_info_lst(&ai_lst);
> @@ -1742,9 +1742,9 @@ int fix_all_socket_lists()
> &ai_lst)!=0)
> #ifdef USE_IPV6
> #ifdef __OS_linux
> - || (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TLS,&ai_lst) != 0)
> + || (cfg_get(core, core_cfg, auto_bind_ipv6)&& add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TLS,&ai_lst) != 0)
> #else
> - || (add_interfaces(0, AF_INET6, 0, PROTO_TLS,&ai_lst)!=0)
> + || (cfg_get(core, core_cfg, auto_bind_ipv6)&& add_interfaces(0, AF_INET6, 0, PROTO_TLS,&ai_lst)!=0)
> #endif /* __OS_linux */
> #endif /* USE_IPV6 */
> ) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TLS, 0,
> @@ -1761,9 +1761,9 @@ int fix_all_socket_lists()
> if (((add_interfaces(0, AF_INET, 0, PROTO_SCTP,&ai_lst)!=0)
> #ifdef USE_IPV6
> #ifdef __OS_linux
> - || (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_SCTP,&ai_lst) != 0)
> + || (cfg_get(core, core_cfg, auto_bind_ipv6)&& add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_SCTP,&ai_lst) != 0)
> #else
> - || (add_interfaces(0, AF_INET6, 0, PROTO_SCTP,&ai_lst)!=0)
> + || (cfg_get(core, core_cfg, auto_bind_ipv6)&& add_interfaces(0, AF_INET6, 0, PROTO_SCTP,&ai_lst) != 0)
> #endif /* __OS_linux */
> #endif /* USE_IPV6 */
> ) || (addr_info_to_si_lst(ai_lst, 0, PROTO_SCTP, 0,
>
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda
More information about the sr-dev
mailing list