From: Ondrej Zajicek Date: Fri, 9 May 2025 16:26:15 +0000 (+0200) Subject: Conf: Fix cases where lexer tokens are used instead of parser rules X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ec37471d1402ea4986584abb59889f009646856;p=thirdparty%2Fbird.git Conf: Fix cases where lexer tokens are used instead of parser rules --- diff --git a/conf/confbase.Y b/conf/confbase.Y index 0912a5f7e..c7649c3e7 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -341,7 +341,7 @@ net_vpn6_: VPN_RD net_ip6_ net_fill_vpn6($$, net6_prefix(&$2), net6_pxlen(&$2), $1); } -net_roa4_: net_ip4_ MAX NUM AS NUM +net_roa4_: net_ip4_ MAX expr AS expr { $$ = cfg_alloc(sizeof(net_addr_roa4)); net_fill_roa4($$, net4_prefix(&$1), net4_pxlen(&$1), $3, $5); @@ -349,7 +349,7 @@ net_roa4_: net_ip4_ MAX NUM AS NUM cf_error("Invalid max prefix length %u", $3); }; -net_roa6_: net_ip6_ MAX NUM AS NUM +net_roa6_: net_ip6_ MAX expr AS expr { $$ = cfg_alloc(sizeof(net_addr_roa6)); net_fill_roa6($$, net6_prefix(&$1), net6_pxlen(&$1), $3, $5); @@ -357,13 +357,13 @@ net_roa6_: net_ip6_ MAX NUM AS NUM cf_error("Invalid max prefix length %u", $3); }; -net_mpls_: MPLS NUM +net_mpls_: MPLS expr { $$ = cfg_alloc(sizeof(net_addr_mpls)); net_fill_mpls($$, $2); } -net_aspa_: ASPA NUM +net_aspa_: ASPA expr { $$ = cfg_alloc(sizeof(net_addr_aspa)); net_fill_aspa($$, $2); @@ -422,7 +422,7 @@ net_any: } ; -label_stack_start: NUM +label_stack_start: expr { $$ = cfg_allocz(sizeof(mpls_label_stack)); $$->len = 1; @@ -431,7 +431,7 @@ label_stack_start: NUM label_stack: label_stack_start - | label_stack '/' NUM { + | label_stack '/' expr { if ($1->len >= MPLS_MAX_LABEL_STACK) cf_error("Too many labels in stack"); $1->stack[$1->len++] = $3; diff --git a/conf/flowspec.Y b/conf/flowspec.Y index 0709a45b1..de496ecbf 100644 --- a/conf/flowspec.Y +++ b/conf/flowspec.Y @@ -156,7 +156,7 @@ flow6_item: flow_builder_set_type(this_flow, $1); flow_builder6_add_pfx(this_flow, (net_addr_ip6 *) &($2), 0); } - | flow_srcdst net_ip6 OFFSET NUM { + | flow_srcdst net_ip6 OFFSET expr { if ($4 > $2.pxlen) cf_error("Prefix offset is higher than prefix length"); flow_builder_set_type(this_flow, $1); diff --git a/filter/config.Y b/filter/config.Y index 4340d5e0e..3a9af0586 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -437,7 +437,7 @@ bt_test_suite: conf: bt_test_same ; bt_test_same: - BT_TEST_SAME '(' symbol_known ',' symbol_known ',' NUM ')' { + BT_TEST_SAME '(' symbol_known ',' symbol_known ',' expr ')' { cf_assert_symbol($3, SYM_FUNCTION); cf_assert_symbol($5, SYM_FUNCTION); struct f_bt_test_suite *t = cfg_allocz(sizeof(struct f_bt_test_suite)); diff --git a/nest/config.Y b/nest/config.Y index 78b8f8712..d6699aa97 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -390,8 +390,8 @@ timeformat_which: ; timeformat_spec: - TEXT { $$ = (struct timeformat){$1, NULL, 0}; } - | TEXT expr TEXT { $$ = (struct timeformat){$1, $3, (s64) $2 S_}; } + text { $$ = (struct timeformat){$1, NULL, 0}; } + | text expr text { $$ = (struct timeformat){$1, $3, (s64) $2 S_}; } | ISO SHORT { $$ = TM_ISO_SHORT_S; } | ISO SHORT MS { $$ = TM_ISO_SHORT_MS; } | ISO SHORT US { $$ = TM_ISO_SHORT_US; } @@ -888,7 +888,7 @@ echo_mask: echo_size: /* empty */ { $$ = 4096; } - | NUM { + | expr { if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size"); $$ = $1; } diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y index f38a1c4eb..93df8f966 100644 --- a/proto/bgp/config.Y +++ b/proto/bgp/config.Y @@ -166,7 +166,7 @@ bgp_proto: net_copy(n, &($4)); BGP_CFG->remote_range = n; } - | bgp_proto INTERFACE TEXT ';' { BGP_CFG->iface = if_get_by_name($3); } + | bgp_proto INTERFACE text ';' { BGP_CFG->iface = if_get_by_name($3); } | bgp_proto RR CLUSTER ID idval ';' { BGP_CFG->rr_cluster_id = $5; } | bgp_proto RR CLIENT bool ';' { BGP_CFG->rr_client = $4; } | bgp_proto RS CLIENT bool ';' { BGP_CFG->rs_client = $4; } diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index 7d35304a6..83d20f9c4 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -561,7 +561,7 @@ lsadb_args: | lsadb_args GLOBAL { $$ = $1; $$->scope = LSA_SCOPE_AS; } | lsadb_args AREA idval { $$ = $1; $$->scope = LSA_SCOPE_AREA; $$->area = $3; } | lsadb_args LINK { $$ = $1; $$->scope = 1; /* hack, 0 is no filter */ } - | lsadb_args TYPE NUM { $$ = $1; $$->type = $3; } + | lsadb_args TYPE expr { $$ = $1; $$->type = $3; } | lsadb_args LSID idval { $$ = $1; $$->lsid = $3; } | lsadb_args SELF { $$ = $1; $$->router = SH_ROUTER_SELF; } | lsadb_args ROUTER idval { $$ = $1; $$->router = $3; } diff --git a/proto/perf/config.Y b/proto/perf/config.Y index 7cab83338..b6263d5f3 100644 --- a/proto/perf/config.Y +++ b/proto/perf/config.Y @@ -44,12 +44,12 @@ perf_proto: perf_proto_item: proto_channel { this_proto->net_type = $1->net_type; } - | EXP FROM NUM { PERF_CFG->from = $3; } - | EXP TO NUM { PERF_CFG->to = $3; } - | REPEAT NUM { PERF_CFG->repeat = $2; } + | EXP FROM expr { PERF_CFG->from = $3; } + | EXP TO expr { PERF_CFG->to = $3; } + | REPEAT expr { PERF_CFG->repeat = $2; } | THRESHOLD MIN expr_us { PERF_CFG->threshold_min = $3; } | THRESHOLD MAX expr_us { PERF_CFG->threshold_max = $3; } - | ATTRIBUTES NUM { PERF_CFG->attrs_per_rte = $2; } + | ATTRIBUTES expr { PERF_CFG->attrs_per_rte = $2; } | KEEP bool { PERF_CFG->keep = $2; } | MODE IMPORT { PERF_CFG->mode = PERF_MODE_IMPORT; } | MODE EXPORT { PERF_CFG->mode = PERF_MODE_EXPORT; } diff --git a/proto/radv/config.Y b/proto/radv/config.Y index 3a898b8d4..045675b11 100644 --- a/proto/radv/config.Y +++ b/proto/radv/config.Y @@ -293,7 +293,7 @@ radv_rdnss: ; -radv_dnssl_node: TEXT +radv_dnssl_node: text { struct radv_dnssl_config *cf = cfg_allocz(sizeof(struct radv_dnssl_config)); add_tail(&radv_dns_list, NODE cf); diff --git a/proto/static/config.Y b/proto/static/config.Y index 817ee3b77..12a167a0f 100644 --- a/proto/static/config.Y +++ b/proto/static/config.Y @@ -89,7 +89,7 @@ stat_nexthop: this_snh->via = IPA_NONE; this_snh->iface = if_get_by_name($2); } - | stat_nexthop DEV TEXT { + | stat_nexthop DEV text { this_snh->iface = if_get_by_name($3); } | stat_nexthop MPLS label_stack { @@ -164,7 +164,7 @@ stat_route: } ; -stat_aspa_provider: NUM { +stat_aspa_provider: expr { if (this_srt->aspa->length == this_srt_aspa_max * sizeof(u32)) { adata *new = cfg_alloc(sizeof (adata) + (this_srt_aspa_max * 2) * sizeof (u32)); diff --git a/sysdep/unix/config.Y b/sysdep/unix/config.Y index f4e70d198..1119baee8 100644 --- a/sysdep/unix/config.Y +++ b/sysdep/unix/config.Y @@ -83,7 +83,7 @@ log_udp_host: text_or_ipa log_udp_port: /* empty */ { this_log->port = 514; } - | PORT NUM { check_u16($2); this_log->port = $2; } + | PORT expr { check_u16($2); this_log->port = $2; } ; log_mask: @@ -193,7 +193,7 @@ CF_CLI(GRACEFUL RESTART,,, [[Shut the daemon down for graceful restart]]) cfg_name: /* empty */ { $$ = NULL; } - | TEXT + | text ; cfg_timeout: