[radvd-devel-l] more flexible prefix/route/rdnss definitions

Pekka Savola pekkas at netcore.fi
Sat Nov 7 13:45:52 EST 2009


FYI:

Michael also provided a patch to gram.y that allows the definitions to 
be in any order; I've merged it in CVS.  If you're interested in 
testing this, see the functional patch attached (In addition 
documentation was updated in several places).

On Fri, 19 Jun 2009, Pekka Savola wrote:
> I just commited in CVS a couple of patches from Michael Stapelberg.
> One of them may be interesting; it allows configuring which unicast
> addresses radvd will send advertisements to, and where to accept
> solitications from.
>
> At the same time I recalled an already earlier realized issue:
> prefix/clients/route/RDNSS definitions must be given in exactly this
> order, otherwise the grammar barfs.  This is not very nice to the poor
> user.
>
> Would anyone be interested in looking at gram.y if making this more
> flexible would be straightforward?
>
>

-- 
Pekka Savola                 "You each name yourselves king, yet the
Netcore Oy                    kingdom bleeds."
Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings
-------------- next part --------------
Index: gram.y
===================================================================
RCS file: /work/cvsroot/radvd/gram.y,v
retrieving revision 1.22
diff -u -r1.22 gram.y
--- gram.y	7 Sep 2009 07:56:02 -0000	1.22
+++ gram.y	7 Nov 2009 03:04:46 -0000
@@ -43,6 +43,18 @@
 #endif
 
 #define ABORT	do { cleanup(); YYABORT; } while (0);
+#define ADD_TO_LL(type, list, value) \
+	do { \
+		if (iface->list == NULL) \
+			iface->list = value; \
+		else { \
+			type *current = iface->list; \
+			while (current->next != NULL) \
+				current = current->next; \
+			current->next = value; \
+		} \
+	} while (0)
+
 
 %}
 
@@ -103,10 +115,10 @@
 %token		T_BAD_TOKEN
 
 %type	<str>	name
-%type	<pinfo> optional_prefixlist prefixdef prefixlist
-%type	<ainfo> optional_clientslist clientslist v6addrlist
-%type	<rinfo>	optional_routelist routedef routelist
-%type	<rdnssinfo> optional_rdnsslist rdnssdef rdnsslist
+%type	<pinfo> prefixdef 
+%type	<ainfo> clientslist v6addrlist
+%type	<rinfo>	routedef 
+%type	<rdnssinfo> rdnssdef 
 %type   <num>	number_or_infinity
 
 %union {
@@ -195,49 +207,16 @@
 		}
 		;
 
-ifaceparams	: optional_ifacevlist optional_prefixlist optional_clientslist optional_routelist optional_rdnsslist
-		{
-			iface->AdvPrefixList = $2;
-			iface->ClientList = $3;
-			iface->AdvRouteList = $4;
-			iface->AdvRDNSSList = $5;
-		}
-		;
-
-optional_ifacevlist: /* empty */
-		   | ifacevlist
-		   ;
-
-optional_prefixlist: /* empty */
-		{
-			$$ = NULL;
-		}
-		| prefixlist
-		;
-
-optional_clientslist: /* empty */
-		{
-			$$ = NULL;
-		}
-		| clientslist
+ifaceparams :
+		/* empty */
+		| ifaceparam ifaceparams
 		;
 
-optional_routelist: /* empty */
-		{
-			$$ = NULL;
-		}
-		| routelist
-		;
-		
-optional_rdnsslist: /* empty */
-		{
-			$$ = NULL;
-		}
-		| rdnsslist
-		;
-
-ifacevlist	: ifacevlist ifaceval
-		| ifaceval
+ifaceparam 	: ifaceval
+		| prefixdef 	{ ADD_TO_LL(struct AdvPrefix, AdvPrefixList, $1); }
+		| clientslist 	{ ADD_TO_LL(struct Clients, ClientList, $1); }
+		| routedef 	{ ADD_TO_LL(struct AdvRoute, AdvRouteList, $1); }
+		| rdnssdef 	{ ADD_TO_LL(struct AdvRDNSS, AdvRDNSSList, $1); }
 		;
 
 ifaceval	: T_MinRtrAdvInterval NUMBER ';'
@@ -370,13 +349,6 @@
 		;
 
 
-prefixlist	: prefixdef optional_prefixlist
-		{
-			$1->next = $2;
-			$$ = $1;
-		}
-		;
-
 prefixdef	: prefixhead '{' optional_prefixplist '}' ';'
 		{
 			unsigned int dst;
@@ -514,13 +486,6 @@
 		}
 		;
 
-routelist	: routedef optional_routelist
-		{
-			$1->next = $2;
-			$$ = $1;
-		}
-		;
-
 routedef	: routehead '{' optional_routeplist '}' ';'
 		{
 			$$ = route;
@@ -572,13 +537,6 @@
 		}
 		;
 		
-rdnsslist	: rdnssdef optional_rdnsslist
-		{
-			$1->next = $2;
-			$$ = $1;
-		}
-		;
-		
 rdnssdef	: rdnsshead '{' optional_rdnssplist '}' ';'
 		{
 			$$ = rdnss;


More information about the radvd-devel-l mailing list