]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Improve grammar rule for interface patterns
authorOndrej Zajicek <santiago@crfreenet.org>
Sat, 10 May 2025 02:30:17 +0000 (04:30 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Sat, 10 May 2025 13:32:02 +0000 (15:32 +0200)
Interface options should allow constants/expressions for name patterns.

Thanks to Arnaud Gomes-do-Vale for the bugreport.

nest/config.Y

index d6699aa97a5714eac8b8ebc731979e37d0dbcbc9..aa1d7c393e053db226f87247318a02d3df527e25 100644 (file)
@@ -412,8 +412,21 @@ iface_patt_node_init:
  ;
 
 iface_patt_node_body:
-   TEXT { this_ipn->pattern = $1; /* this_ipn->prefix stays zero */ }
- | opttext net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2; }
+   TEXT { this_ipn->pattern = $1; }
+ | net_ip_ { this_ipn->prefix = $1; }
+ | IP4 { net_fill_ip4(&(this_ipn->prefix), $1, IP4_MAX_PREFIX_LENGTH); }
+ | IP6 { net_fill_ip6(&(this_ipn->prefix), $1, IP6_MAX_PREFIX_LENGTH); }
+ | conf_expr {
+     if ($1.type == T_STRING)
+       this_ipn->pattern = $1.val.s;
+     else if ($1.type == T_IP)
+       net_fill_ip_host(&(this_ipn->prefix), $1.val.ip);
+     else if (($1.type == T_NET) && net_is_ip($1.val.net))
+       this_ipn->prefix = * $1.val.net;
+     else
+       cf_error("String or IP address/prefix expected");
+ }
+ | text net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2; }
  ;
 
 iface_negate: