Maintained by: NLnet Labs

view functionality and ptr's

Björn Ketelaars
Fri Mar 17 07:31:30 CET 2017


I'm currently running multiple Unbound instances on a machine to serve
different subnets. Each subnet requires some distinctive local-data-ptr magic.

It seems like a good idea to replace the above by a single unbound instance
using the more recent view functionality. Nearly everything works, except
support for local-data-ptr in a view clause. I'm guessing this is
intentionally? As I'm unable to think of a reason why enabling local-data-ptr
in a view is a bad idea I'm running Unbound with the enclosed diff. It seems
to work...

Check question: Am I missing something?

-- 
Björn Ketelaars
GPG key: 0x4F0E5F21


diff --git doc/unbound.conf.5.in doc/unbound.conf.5.in
index d7423225170..9dc71809219 100644
--- doc/unbound.conf.5.in
+++ doc/unbound.conf.5.in
@@ -1358,6 +1358,10 @@ global local\-zone elements.
 View specific local\-data elements. Has the same behaviour as the global
 local\-data elements.
 .TP
+.B local\-data\-ptr: \fI"IPaddr name"
+View specific local\-data\-ptr elements. Has the same behaviour as the global
+local\-data\-ptr elements.
+.TP
 .B view\-first: \fI<yes or no>
 If enabled, it attempts to use the global local\-zone and local\-data if there
 is no match in the view specific options.
diff --git util/configparser.y util/configparser.y
index e6e3fb4744f..f430bc39b5e 100644
--- util/configparser.y
+++ util/configparser.y
@@ -265,7 +265,8 @@ viewstart: VAR_VIEW
 	;
 contents_view: contents_view content_view 
 	| ;
-content_view: view_name | view_local_zone | view_local_data | view_first
+content_view: view_name | view_local_zone | view_local_data |
+	view_local_data_ptr | view_first
 	;
 server_num_threads: VAR_NUM_THREADS STRING_ARG 
 	{ 
@@ -1778,6 +1779,21 @@ view_local_data: VAR_LOCAL_DATA STRING_ARG
 		}
 	}
 	;
+view_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
+	{
+		char* ptr;
+		OUTYY(("P(view_local_data_ptr:%s)\n", $2));
+		ptr = cfg_ptr_reverse($2);
+		free($2);
+		if(ptr) {
+			if(!cfg_strlist_insert(&cfg_parser->cfg->views->
+				local_data, ptr))
+				fatal_exit("out of memory adding local-data");
+		} else {
+			yyerror("local-data-ptr could not be reversed");
+		}
+	}
+	;
 view_first: VAR_VIEW_FIRST STRING_ARG
 	{
 		OUTYY(("P(view-first:%s)\n", $2));