]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: further split of print & die to FI_PRINT, FI_FLUSH and FI_DIE
authorMaria Matejka <mq@ucw.cz>
Mon, 15 Jul 2019 13:43:47 +0000 (15:43 +0200)
committerMaria Matejka <mq@ucw.cz>
Mon, 15 Jul 2019 13:46:36 +0000 (15:46 +0200)
filter/config.Y
filter/f-inst.c

index 9a240763ab5633ebe25ee916b82f5276094c30ff..83319194c91b8ed910911af6ac87cf6f94e44a57 100644 (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));
index 997bc6acf7860a84946b6b6bf2c38b5074a7acd6..0867ac4a1784dce12e423a95474f376537da03af 100644 (file)
        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");
     }