Browse code

core: added parameter to enable/disable automatic binding of ipv6 interfaces TODO: documentation

Marius Zbihlei authored on 11/10/2011 08:35:56
Showing 5 changed files
... ...
@@ -370,6 +370,8 @@ DNS_CACHE_MAX_TTL	dns_cache_max_ttl
370 370
 DNS_CACHE_MEM		dns_cache_mem
371 371
 DNS_CACHE_GC_INT	dns_cache_gc_interval
372 372
 DNS_CACHE_DEL_NONEXP	dns_cache_del_nonexp|dns_cache_delete_nonexpired
373
+/* ipv6 auto bind */
374
+AUTO_BIND_IPV6		auto_bind_ipv6
373 375
 /* blacklist */
374 376
 DST_BLST_INIT	dst_blacklist_init
375 377
 USE_DST_BLST		use_dst_blacklist
... ...
@@ -751,6 +753,8 @@ IMPORTFILE      "import_file"
751 751
 								return DNS_CACHE_GC_INT; }
752 752
 <INITIAL>{DNS_CACHE_DEL_NONEXP}	{ count(); yylval.strval=yytext;
753 753
 								return DNS_CACHE_DEL_NONEXP; }
754
+<INITIAL>{AUTO_BIND_IPV6}	{ count(); yylval.strval=yytext;
755
+								return AUTO_BIND_IPV6; }
754 756
 <INITIAL>{DST_BLST_INIT}	{ count(); yylval.strval=yytext;
755 757
 								return DST_BLST_INIT; }
756 758
 <INITIAL>{USE_DST_BLST}	{ count(); yylval.strval=yytext;
... ...
@@ -164,6 +164,11 @@
164 164
 		if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
165 165
 	}while(0)
166 166
 
167
+#ifdef USE_IPV6
168
+	#define IF_AUTO_BIND_IPV6(x) x
169
+#else
170
+	#define IF_AUTO_BIND_IPV6(x) warn("IPV6 support not compiled");
171
+#endif
167 172
 
168 173
 #ifdef USE_DNS_CACHE
169 174
 	#define IF_DNS_CACHE(x) x
... ...
@@ -419,6 +424,10 @@ extern char *finame;
419 419
 %token DNS_CACHE_MEM
420 420
 %token DNS_CACHE_GC_INT
421 421
 %token DNS_CACHE_DEL_NONEXP
422
+
423
+/* ipv6 auto bind */
424
+%token AUTO_BIND_IPV6
425
+
422 426
 /*blacklist*/
423 427
 %token DST_BLST_INIT
424 428
 %token USE_DST_BLST
... ...
@@ -877,6 +886,8 @@ assign_stm:
877 877
 	| DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
878 878
 	| DNS_CACHE_DEL_NONEXP EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
879 879
 	| DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
880
+	| AUTO_BIND_IPV6 EQUAL NUMBER {IF_AUTO_BIND_IPV6(default_core_cfg.auto_bind_ipv6 = $3);}
881
+	| AUTO_BIND_IPV6 error { yyerror("boolean value expected"); }
880 882
 	| DST_BLST_INIT EQUAL NUMBER   { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
881 883
 	| DST_BLST_INIT error { yyerror("boolean value expected"); }
882 884
 	| USE_DST_BLST EQUAL NUMBER {
... ...
@@ -105,6 +105,9 @@ struct cfg_group_core default_core_cfg = {
105 105
 	0, /*!< dns_cache_del_nonexp -- delete only expired entries by default */
106 106
 	0, /*!< dns_cache_rec_pref -- 0 by default, do not check the existing entries. */
107 107
 #endif
108
+#ifdef USE_IPV6
109
+	0, /*!< auto_bind_ipv6 -- off by default */
110
+#endif
108 111
 #ifdef PKG_MALLOC
109 112
 	0, /*!< mem_dump_pkg */
110 113
 #endif
... ...
@@ -272,6 +275,11 @@ cfg_def_t core_cfg_def[] = {
272 272
 		" 2 - prefer new records"
273 273
 		" 3 - prefer records with longer lifetime"},
274 274
 #endif
275
+#ifdef USE_IPV6
276
+	{"auto_bind_ipv6", 	CFG_VAR_INT,	0, 1, 0, 0, 0,
277
+		"enable/disable auto binding of proxy to IPV6 interfaces."
278
+		"default is disabled 0"},
279
+#endif
275 280
 #ifdef PKG_MALLOC
276 281
 	{"mem_dump_pkg",	CFG_VAR_INT,	0, 0, 0, mem_dump_pkg_cb,
277 282
 		"dump process memory status, parameter: pid_number"},
... ...
@@ -93,6 +93,11 @@ struct cfg_group_core {
93 93
 	int dns_cache_del_nonexp;
94 94
 	int dns_cache_rec_pref;
95 95
 #endif
96
+
97
+#ifdef USE_IPV6
98
+	int auto_bind_ipv6;
99
+#endif
100
+
96 101
 #ifdef PKG_MALLOC
97 102
 	int mem_dump_pkg;
98 103
 #endif
... ...
@@ -1712,9 +1712,9 @@ int fix_all_socket_lists()
1712 1712
 		if ( ( (add_interfaces(0, AF_INET, 0,  PROTO_UDP, &ai_lst)==0)
1713 1713
 #ifdef USE_IPV6
1714 1714
 #ifdef __OS_linux
1715
-		&& (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_UDP, &ai_lst) == 0)
1715
+		&&  (!(cfg_get(core, core_cfg, auto_bind_ipv6)) || add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_UDP, &ai_lst) == 0)
1716 1716
 #else
1717
-		&& (add_interfaces(0, AF_INET6, 0,  PROTO_UDP, &ai_lst)==0) /* add_interface does not work for IPv6 on Linux */
1717
+		&& ( !(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 */
1718 1718
 #endif /* __OS_linux */
1719 1719
 #endif /* USE_IPV6 */
1720 1720
 			 ) && (addr_info_to_si_lst(ai_lst, 0, PROTO_UDP, 0, &udp_listen)==0)){
... ...
@@ -1726,12 +1726,12 @@ int fix_all_socket_lists()
1726 1726
 				if ( ((add_interfaces(0, AF_INET, 0,  PROTO_TCP, &ai_lst)!=0)
1727 1727
 #ifdef USE_IPV6
1728 1728
 #ifdef __OS_linux
1729
-    				|| (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TCP, &ai_lst) != 0)
1729
+    				|| (cfg_get(core, core_cfg, auto_bind_ipv6) && add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TCP, &ai_lst) != 0)
1730 1730
 #else
1731
-				|| (add_interfaces(0, AF_INET6, 0,  PROTO_TCP, &ai_lst)!=0)
1731
+				|| (cfg_get(core, core_cfg, auto_bind_ipv6) && add_interfaces(0, AF_INET6, 0,  PROTO_TCP, &ai_lst) !=0 )
1732 1732
 #endif /* __OS_linux */
1733 1733
 #endif /* USE_IPV6 */
1734
-				)|| (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0,
1734
+				) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0,
1735 1735
 										 				&tcp_listen)!=0))
1736 1736
 					goto error;
1737 1737
 				free_addr_info_lst(&ai_lst);
... ...
@@ -1742,9 +1742,9 @@ int fix_all_socket_lists()
1742 1742
 										&ai_lst)!=0)
1743 1743
 #ifdef USE_IPV6
1744 1744
 #ifdef __OS_linux
1745
-    				|| (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TLS, &ai_lst) != 0)
1745
+    				|| (cfg_get(core, core_cfg, auto_bind_ipv6) && add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_TLS, &ai_lst) != 0)
1746 1746
 #else
1747
-				|| (add_interfaces(0, AF_INET6, 0,  PROTO_TLS, &ai_lst)!=0)
1747
+				|| (cfg_get(core, core_cfg, auto_bind_ipv6) && add_interfaces(0, AF_INET6, 0,  PROTO_TLS, &ai_lst)!=0)
1748 1748
 #endif /* __OS_linux */
1749 1749
 #endif /* USE_IPV6 */
1750 1750
 					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TLS, 0,
... ...
@@ -1761,9 +1761,9 @@ int fix_all_socket_lists()
1761 1761
 				if (((add_interfaces(0, AF_INET, 0,  PROTO_SCTP, &ai_lst)!=0)
1762 1762
 #ifdef USE_IPV6
1763 1763
 #ifdef __OS_linux
1764
-    				|| (add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_SCTP, &ai_lst) != 0)
1764
+    				|| (cfg_get(core, core_cfg, auto_bind_ipv6) && add_interfaces_via_netlink(0, AF_INET6, 0, PROTO_SCTP, &ai_lst) != 0)
1765 1765
 #else
1766
-				|| (add_interfaces(0, AF_INET6, 0,  PROTO_SCTP, &ai_lst)!=0)
1766
+				|| (cfg_get(core, core_cfg, auto_bind_ipv6) && add_interfaces(0, AF_INET6, 0,  PROTO_SCTP, &ai_lst) != 0)
1767 1767
 #endif /* __OS_linux */
1768 1768
 #endif /* USE_IPV6 */
1769 1769
 					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_SCTP, 0,