Re: [patch/openbgpd] make man example works

2017-05-26 Thread Peter Hessler
looks good to me, OK


On 2017 May 21 (Sun) at 19:36:36 +0200 (+0200), Denis Fondras wrote:
:Hi,
:
:bgpd.conf manual has an example with :
:
:good="{ 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 }"
:bad="{ 224.0.0.0/4 prefixlen >= 4, 240.0.0.0/4 prefixlen >= 4 }"
:ugly="{ 127.0.0.1/8, 169.254.0.0/16 }"
:deny from any prefix { $good $bad $ugly } 
:
:This syntax is not valid with current parse.y.
:
:Here is a patch to make it valid.
:
:Index: parse.y
:===
:RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
:retrieving revision 1.298
:diff -u -p -r1.298 parse.y
:--- parse.y22 Feb 2017 13:55:14 -  1.298
:+++ parse.y21 May 2017 17:29:11 -
:@@ -217,6 +217,7 @@ typedef struct {
: %type   filter_set_opt
: %type  filter_set filter_set_l
: %typefilter_prefix filter_prefix_l filter_prefix_h
:+%typefilter_prefix_m
: %type   unaryop equalityop binaryop filter_as_type
: %type  encspec
: %%
:@@ -1615,8 +1616,22 @@ filter_prefix_h : IPV4 prefixlenop  
 {
:   }
:   }
:   | PREFIX filter_prefix  { $$ = $2; }
:-  | PREFIX '{' filter_prefix_l '}'{ $$ = $3; }
:+  | PREFIX '{' filter_prefix_m '}'{ $$ = $3; }
:   ;
:+
:+filter_prefix_m   : filter_prefix_l
:+  | '{' filter_prefix_l '}'   { $$ = $2; }
:+  | '{' filter_prefix_l '}' filter_prefix_m
:+  {
:+  struct filter_prefix_l  *p;
:+
:+  /* merge, both can be lists */
:+  for (p = $2; p != NULL && p->next != NULL; p = p->next)
:+  ;   /* nothing */
:+  if (p != NULL)
:+  p->next = $4;
:+  $$ = $2;
:+  } 
: 
: filter_prefix_l   : filter_prefix { $$ = $1; }
:   | filter_prefix_l comma filter_prefix   {
:

-- 
Keep your Eye on the Ball,
Your Shoulder to the Wheel,
Your Nose to the Grindstone,
Your Feet on the Ground,
Your Head on your Shoulders.
Now ... try to get something DONE!



[patch/openbgpd] make man example works

2017-05-21 Thread Denis Fondras
Hi,

bgpd.conf manual has an example with :

good="{ 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 }"
bad="{ 224.0.0.0/4 prefixlen >= 4, 240.0.0.0/4 prefixlen >= 4 }"
ugly="{ 127.0.0.1/8, 169.254.0.0/16 }"
deny from any prefix { $good $bad $ugly } 

This syntax is not valid with current parse.y.

Here is a patch to make it valid.

Index: parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.298
diff -u -p -r1.298 parse.y
--- parse.y 22 Feb 2017 13:55:14 -  1.298
+++ parse.y 21 May 2017 17:29:11 -
@@ -217,6 +217,7 @@ typedef struct {
 %typefilter_set_opt
 %type   filter_set filter_set_l
 %type filter_prefix filter_prefix_l filter_prefix_h
+%type filter_prefix_m
 %typeunaryop equalityop binaryop filter_as_type
 %type   encspec
 %%
@@ -1615,8 +1616,22 @@ filter_prefix_h  : IPV4 prefixlenop  
 {
}
}
| PREFIX filter_prefix  { $$ = $2; }
-   | PREFIX '{' filter_prefix_l '}'{ $$ = $3; }
+   | PREFIX '{' filter_prefix_m '}'{ $$ = $3; }
;
+
+filter_prefix_m: filter_prefix_l
+   | '{' filter_prefix_l '}'   { $$ = $2; }
+   | '{' filter_prefix_l '}' filter_prefix_m
+   {
+   struct filter_prefix_l  *p;
+
+   /* merge, both can be lists */
+   for (p = $2; p != NULL && p->next != NULL; p = p->next)
+   ;   /* nothing */
+   if (p != NULL)
+   p->next = $4;
+   $$ = $2;
+   } 
 
 filter_prefix_l: filter_prefix { $$ = $1; }
| filter_prefix_l comma filter_prefix   {