0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

Filter: further split of print & die to FI_PRINT, FI_FLUSH and FI_DIE

This commit is contained in:
Maria Matejka 2019-07-15 15:43:47 +02:00
parent 3782454e8d
commit efd7c87b5b
2 changed files with 23 additions and 22 deletions

View File

@ -966,8 +966,6 @@ break_command:
| ACCEPT { $$ = F_ACCEPT; }
| REJECT { $$ = F_REJECT; }
| ERROR { $$ = F_ERROR; }
| PRINT { $$ = F_NOP; }
| PRINTN { $$ = F_NONL; }
;
print_list: /* EMPTY */ { $$ = NULL; }
@ -1018,21 +1016,23 @@ cmd:
$$ = f_new_inst(FI_EA_UNSET, $3);
}
| break_command print_list ';' {
struct f_inst *breaker = NULL;
struct f_inst *printer = NULL;
if ($2)
printer = f_new_inst(FI_PRINT, $2);
if ($1 != F_NONL)
breaker = f_new_inst(FI_DIE, $1);
if (printer && breaker)
printer->next = breaker;
if (printer)
struct f_inst *breaker = f_new_inst(FI_DIE, $1);
if ($2) {
struct f_inst *printer = f_new_inst(FI_PRINT, $2);
struct f_inst *flusher = f_new_inst(FI_FLUSH);
printer->next = flusher;
flusher->next = breaker;
$$ = printer;
else
} else
$$ = breaker;
}
| PRINT print_list ';' {
$$ = f_new_inst(FI_PRINT, $2);
$$->next = f_new_inst(FI_FLUSH);
}
| PRINTN print_list ';' {
$$ = f_new_inst(FI_PRINT, $2);
}
| function_call ';' { $$ = f_new_inst(FI_DROP_RESULT, $1); }
| CASE term '{' switch_body '}' {
$$ = f_new_inst(FI_SWITCH, $2, build_tree($4));

View File

@ -455,23 +455,24 @@
val_format(&(vv(i)), &fs->buf);
}
INST(FI_FLUSH, 0, 0) {
NEVER_CONSTANT;
if (!(fs->flags & FF_SILENT))
/* After log_commit, the buffer is reset */
log_commit(*L_INFO, &fs->buf);
}
INST(FI_DIE, 0, 0) {
NEVER_CONSTANT;
FID_MEMBER(enum filter_return, fret, f1->fret != f2->fret, "%s", filter_return_str(item->fret));
if (fs->buf.start < fs->buf.pos)
log_commit(*L_INFO, &fs->buf);
switch (whati->fret) {
case F_QUITBIRD:
die( "Filter asked me to die" );
case F_ACCEPT:
/* Should take care about turning ACCEPT into MODIFY */
case F_ACCEPT: /* Should take care about turning ACCEPT into MODIFY */
case F_ERROR:
case F_REJECT: /* FIXME (noncritical) Should print complete route along with reason to reject route */
case F_REJECT: /* Maybe print complete route along with reason to reject route? */
return fret; /* We have to return now, no more processing. */
case F_NOP:
break;
default:
bug( "unknown return type: Can't happen");
}