]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Static: Improve grammar rule for static route next hops
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 9 May 2025 16:51:54 +0000 (18:51 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Sat, 10 May 2025 13:32:02 +0000 (15:32 +0200)
Static routes should allow constants/expressions for interface names in
next hops.

proto/static/config.Y

index 12a167a0f1606679c47c549e812902b276e977de..f840947b2a237fb9edb23b2c4d12e59620a58b2a 100644 (file)
@@ -79,15 +79,17 @@ static_proto:
  ;
 
 stat_nexthop:
-    VIA ipa ipa_scope {
+    VIA text_or_ipa {
       this_snh = static_nexthop_new();
-      this_snh->via = $2;
-      this_snh->iface = $3;
-    }
-  | VIA TEXT {
-      this_snh = static_nexthop_new();
-      this_snh->via = IPA_NONE;
-      this_snh->iface = if_get_by_name($2);
+      if ($2.type == T_IP)
+        this_snh->via = $2.val.ip;
+      else if ($2.type == T_STRING)
+        this_snh->iface = if_get_by_name($2.val.s);
+    } ipa_scope {
+      if ($2.type == T_IP)
+        this_snh->iface = $4;
+      else if ($4)
+        cf_error("syntax error, unexpected '%'");
     }
   | stat_nexthop DEV text {
       this_snh->iface = if_get_by_name($3);