]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Conf: Allowing conf scope to be explicitly read only
authorMaria Matejka <mq@ucw.cz>
Tue, 13 Jun 2023 09:09:41 +0000 (11:09 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 12 Sep 2023 13:36:53 +0000 (15:36 +0200)
conf/cf-lex.l
conf/conf.h

index 952372150593fa236da815898ab9d990b0b6e593..8dc0ac89ac3e88624efc97ca82a48685e21e2318 100644 (file)
@@ -559,6 +559,9 @@ static inline void cf_swap_soft_scope(struct config *conf);
 static struct symbol *
 cf_new_symbol(struct sym_scope *scope, pool *p, struct linpool *lp, const byte *c)
 {
+  if (scope->readonly)
+    cf_error("Unknown symbol %s", c);
+
   struct symbol *s;
 
   uint l = strlen(c);
@@ -712,6 +715,8 @@ cf_lex_init(int is_cli, struct config *c)
       sym->class = SYM_KEYWORD;
       sym->keyword = k;
     }
+
+    global_root_scope->readonly = 1;
   }
 
   ifs_head = ifs = push_ifs(NULL);
index ec8c97e84deaaec61b7830ba10d1b3118e67ed77..8558fcbaedef1b987ac4180dfc49f847ceeb44ef 100644 (file)
@@ -137,9 +137,10 @@ struct sym_scope {
   HASH(struct symbol) hash;            /* Local symbol hash */
 
   uint slots;                          /* Variable slots */
-  byte active;                         /* Currently entered */
-  byte block;                          /* No independent stack frame */
   byte soft_scopes;                    /* Number of soft scopes above */
+  byte active:1;                       /* Currently entered */
+  byte block:1;                                /* No independent stack frame */
+  byte readonly:1;                     /* Do not add new symbols */
 };
 
 extern struct sym_scope *global_root_scope;