summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-11-10 14:55:41 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-11-10 14:55:41 +0100
commit13c71785b58fe542ca95eeed11dabf99f1be71fa (patch)
treec5e9469af5de6dbba2a2b79b598678bff576e31a
parent68b33305cc7d258b5556a30f6cb96e1882bda0d7 (diff)
downloadfastd-13c71785b58fe542ca95eeed11dabf99f1be71fa.tar
fastd-13c71785b58fe542ca95eeed11dabf99f1be71fa.zip
Don't allow global config statements in peer groups
-rw-r--r--src/config.c2
-rw-r--r--src/config.y19
2 files changed, 16 insertions, 5 deletions
diff --git a/src/config.c b/src/config.c
index 409a83b..09a0adc 100644
--- a/src/config.c
+++ b/src/config.c
@@ -435,7 +435,7 @@ bool fastd_read_config(fastd_context *ctx, fastd_config *conf, const char *filen
if (peer_config)
token = START_PEER_CONFIG;
else
- token = START_CONFIG;
+ token = conf->peer_group->parent ? START_PEER_GROUP_CONFIG : START_CONFIG;
int parse_ret = fastd_config_push_parse(ps, token, &token_val, &loc, ctx, conf, filename, depth+1);
diff --git a/src/config.y b/src/config.y
index 5e3e837..d576b91 100644
--- a/src/config.y
+++ b/src/config.y
@@ -51,6 +51,7 @@
}
%token START_CONFIG
+%token START_PEER_GROUP_CONFIG
%token START_PEER_CONFIG
%token <num> TOK_INTEGER
@@ -131,6 +132,7 @@
%%
start: START_CONFIG config
+ | START_PEER_GROUP_CONFIG peer_group_config
| START_PEER_CONFIG peer_conf
;
@@ -138,7 +140,13 @@ config: config statement
|
;
-statement: TOK_LOG log ';'
+peer_group_config:
+ peer_group_config peer_group_statement
+ |
+ ;
+
+statement: peer_group_statement
+ | TOK_LOG log ';'
| TOK_INTERFACE interface ';'
| TOK_BIND bind ';'
| TOK_MTU mtu ';'
@@ -151,10 +159,13 @@ statement: TOK_LOG log ';'
| TOK_ON TOK_DOWN on_down ';'
| TOK_ON TOK_ESTABLISH on_establish ';'
| TOK_ON TOK_DISESTABLISH on_disestablish ';'
- | TOK_PEER peer '{' peer_conf '}'
- | TOK_PEER TOK_GROUP peer_group '{' config '}' peer_group_after
- | TOK_PEER TOK_LIMIT peer_limit ';'
| TOK_FORWARD forward ';'
+ ;
+
+peer_group_statement:
+ TOK_PEER peer '{' peer_conf '}'
+ | TOK_PEER TOK_GROUP peer_group '{' peer_group_config '}' peer_group_after
+ | TOK_PEER TOK_LIMIT peer_limit ';'
| TOK_INCLUDE include ';'
;