From: Ondrej Zajicek Date: Fri, 9 May 2025 16:51:54 +0000 (+0200) Subject: Static: Improve grammar rule for static route next hops X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3012e56a9c566815ea5e63c3d1a00048ce5cec57;p=thirdparty%2Fbird.git Static: Improve grammar rule for static route next hops Static routes should allow constants/expressions for interface names in next hops. --- diff --git a/proto/static/config.Y b/proto/static/config.Y index 12a167a0f..f840947b2 100644 --- a/proto/static/config.Y +++ b/proto/static/config.Y @@ -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);