summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd/parse.y
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-05-31 03:24:07 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-05-31 03:24:07 +0000
commit096d22c2a59ca8fd190428607badf44481bcb88e (patch)
tree37d9e8b77bbe608b52e203e5937e6677f8341847 /usr.sbin/ospfd/parse.y
parent4efb916c2227091b9bdd87d8d5abc6720e52da33 (diff)
More redistribute fun. Add a possibility to deny redistribution of specified
routes via "no redistribute rtlabel admin". Redistribute rules are parsed in order and the first match is used. Only exception is "redistribute default" Which is independent of the other rules and can't be negated.
Diffstat (limited to 'usr.sbin/ospfd/parse.y')
-rw-r--r--usr.sbin/ospfd/parse.y56
1 files changed, 32 insertions, 24 deletions
diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y
index 8297690d3de..c45a30eb9e2 100644
--- a/usr.sbin/ospfd/parse.y
+++ b/usr.sbin/ospfd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.32 2006/05/31 02:18:23 pat Exp $ */
+/* $OpenBSD: parse.y,v 1.33 2006/05/31 03:24:06 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -112,9 +112,10 @@ typedef struct {
%token METRIC PASSIVE
%token HELLOINTERVAL TRANSMITDELAY
%token RETRANSMITINTERVAL ROUTERDEADTIME ROUTERPRIORITY
+%token YES NO
%token ERROR
%token <v.string> STRING
-%type <v.number> number yesno
+%type <v.number> number yesno no
%type <v.string> string
%%
@@ -153,19 +154,13 @@ string : string STRING {
| STRING
;
-yesno : STRING {
- if (!strcmp($1, "yes"))
- $$ = 1;
- else if (!strcmp($1, "no"))
- $$ = 0;
- else {
- free($1);
- YYERROR;
- }
- free($1);
- }
+yesno : YES { $$ = 1; }
+ | NO { $$ = 0; }
;
+no : /* empty */ { $$ = 0; }
+ | NO { $$ = 1; }
+
varset : STRING '=' string {
if (conf->opts & OSPFD_OPT_VERBOSE)
printf("%s = \"%s\"\n", $1, $3);
@@ -190,40 +185,51 @@ conf_main : ROUTERID STRING {
else
conf->flags &= ~OSPFD_FLAG_NO_FIB_UPDATE;
}
- | REDISTRIBUTE STRING {
+ | no REDISTRIBUTE STRING {
struct redistribute *r;
- if (!strcmp($2, "default"))
+ if (!strcmp($3, "default")) {
conf->redistribute |= REDISTRIBUTE_DEFAULT;
- else {
+ if ($1) {
+ yyerror("cannot use 'no' with "
+ "redistribute default");
+ free($3);
+ YYERROR;
+ }
+ } else {
if ((r = calloc(1, sizeof(*r))) == NULL)
fatal(NULL);
- if (!strcmp($2, "static"))
+ if (!strcmp($3, "static"))
r->type = REDIST_STATIC;
- else if (!strcmp($2, "connected"))
+ else if (!strcmp($3, "connected"))
r->type = REDIST_CONNECTED;
else {
yyerror("unknown redistribute type");
- free($2);
+ free($3);
free(r);
YYERROR;
}
+ if ($1)
+ r->type |= REDIST_NO;
+
SIMPLEQ_INSERT_TAIL(&conf->redist_list, r,
entry);
}
conf->redistribute |= REDISTRIBUTE_ON;
- free($2);
+ free($3);
}
- | REDISTRIBUTE RTLABEL STRING {
+ | no REDISTRIBUTE RTLABEL STRING {
struct redistribute *r;
if ((r = calloc(1, sizeof(*r))) == NULL)
fatal(NULL);
r->type = REDIST_LABEL;
- r->label = rtlabel_name2id($3);
- free($3);
+ r->label = rtlabel_name2id($4);
+ if ($1)
+ r->type |= REDIST_NO;
+ free($4);
SIMPLEQ_INSERT_TAIL(&conf->redist_list, r, entry);
conf->redistribute |= REDISTRIBUTE_ON;
@@ -496,6 +502,7 @@ lookup(char *s)
{"hello-interval", HELLOINTERVAL},
{"interface", INTERFACE},
{"metric", METRIC},
+ {"no", NO},
{"passive", PASSIVE},
{"redistribute", REDISTRIBUTE},
{"retransmit-interval", RETRANSMITINTERVAL},
@@ -506,7 +513,8 @@ lookup(char *s)
{"rtlabel", RTLABEL},
{"spf-delay", SPFDELAY},
{"spf-holdtime", SPFHOLDTIME},
- {"transmit-delay", TRANSMITDELAY}
+ {"transmit-delay", TRANSMITDELAY},
+ {"yes", YES}
};
const struct keywords *p;