]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RPKI: Fix conflict in config grammar
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 25 Aug 2023 02:32:01 +0000 (04:32 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 25 Aug 2023 02:32:01 +0000 (04:32 +0200)
conf/confbase.Y
proto/rpki/config.Y

index f8d244157edaedfdd1bd9a9d0f793870b1de0e35..a6b4b1eec5df4c19919a035a3963c0506581a7b0 100644 (file)
@@ -121,7 +121,7 @@ CF_DECLS
 %type <s> symbol
 %type <kw> kw_sym
 
-%type <v> bytestring_text
+%type <v> bytestring_text text_or_ipa
 %type <x> bytestring_expr
 
 %nonassoc PREFIX_DUMMY
@@ -399,6 +399,24 @@ opttext:
  | /* empty */ { $$ = NULL; }
  ;
 
+text_or_ipa:
+   TEXT { $$.type = T_STRING; $$.val.s = $1; }
+ | IP4 { $$.type = T_IP; $$.val.ip = ipa_from_ip4($1); }
+ | IP6 { $$.type = T_IP; $$.val.ip = ipa_from_ip6($1); }
+ | CF_SYM_KNOWN {
+     if (($1->class == (SYM_CONSTANT | T_STRING)) ||
+        ($1->class == (SYM_CONSTANT | T_IP)))
+       $$ = *($1->val);
+     else
+       cf_error("String or IP constant expected");
+   }
+ | '(' term ')' {
+     $$ = cf_eval($2, T_VOID);
+     if (($$.type != T_BYTESTRING) && ($$.type != T_STRING))
+       cf_error("Bytestring or string value expected");
+   }
+ ;
+
 bytestring:
    BYTETEXT
  | bytestring_expr { $$ = cf_eval($1, T_BYTESTRING).val.bs; }
index d6d326b814a8f3de77a1529361503977a549f68d..c28cab7a661c92fb111e3cd44661c261ad434406 100644 (file)
@@ -89,20 +89,22 @@ rpki_keep_interval:
 
 rpki_proto_item_port: PORT expr { check_u16($2); RPKI_CFG->port = $2; };
 
-rpki_cache_addr:
-   text {
-     rpki_check_unused_hostname();
-     RPKI_CFG->hostname = $1;
-   }
- | ipa {
-     rpki_check_unused_hostname();
-     RPKI_CFG->ip = $1;
-     /* Ensure hostname is filled */
-     char *hostname = cfg_allocz(INET6_ADDRSTRLEN + 1);
-     bsnprintf(hostname, INET6_ADDRSTRLEN+1, "%I", RPKI_CFG->ip);
-     RPKI_CFG->hostname = hostname;
-   }
- ;
+rpki_cache_addr: text_or_ipa
+{
+  rpki_check_unused_hostname();
+  if ($1.type == T_STRING)
+    RPKI_CFG->hostname = $1.val.s;
+  else if ($1.type == T_IP)
+  {
+    RPKI_CFG->ip = $1.val.ip;
+
+    /* Ensure hostname is filled */
+    char *hostname = cfg_allocz(INET6_ADDRSTRLEN + 1);
+    bsnprintf(hostname, INET6_ADDRSTRLEN+1, "%I", RPKI_CFG->ip);
+    RPKI_CFG->hostname = hostname;
+  }
+  else bug("Bad text_or_ipa");
+};
 
 rpki_transport:
    TCP rpki_transport_tcp_init