0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Static: Allow to define both nexthop and interface

Allow to define both nexthop and interface using iproute2-like syntax,
e.g.: route 10.0.0.0/16 via 10.1.0.1 dev "eth0";

Now we can avoid to use link-local scope hack (e.g. 10.1.0.1%eth0)
for cases where both nexthop and interface have to be defined.

Thanks to Marcin Saklak for the suggestion.
This commit is contained in:
Ondrej Zajicek 2024-02-16 18:44:40 +01:00
parent 5c04f0e235
commit c3335b5044
2 changed files with 13 additions and 2 deletions

View File

@ -5940,6 +5940,12 @@ options (<cf/bfd/ and <cf/weight 1/), the second nexthop has just <cf/weight 2/.
that BFD protocol also has to be configured, see <ref id="bfd" name="BFD">
section for details. Default value is no.
<tag><label id="static-route-dev">dev <m/text/</tag>
The outgoing interface associated with the nexthop. Useful for
link-local nexthop addresses or when multiple interfaces use the same
network prefix. By default, the outgoing interface is resolved from the
nexthop address.
<tag><label id="static-route-mpls">mpls <m/num/[/<m/num/[/<m/num/[...]]]</tag>
MPLS labels that should be pushed to packets forwarded by the route.
The option could be used for both IP routes (on MPLS ingress routers)
@ -6120,7 +6126,8 @@ protocol static {
via 198.51.100.20 bfd # BFD-controlled next hop
via 192.0.2.1;
route 203.0.113.0/24 blackhole; # Sink route
route 10.2.0.0/24 via "arc0"; # Secondary network
route 10.2.0.0/24 via "arc0"; # Direct route
route 10.2.2.0/24 via 192.0.2.1 dev "eth0" onlink; # Route with both nexthop and iface
route 192.168.10.0/24 via 198.51.100.100 {
ospf_metric1 = 20; # Set extended attribute
};
@ -6139,7 +6146,8 @@ protocol static {
route 2001:db8:10::/48 via 2001:db8:1::1; # Route with global nexthop
route 2001:db8:20::/48 via fe80::10%eth0; # Route with link-local nexthop
route 2001:db8:30::/48 via fe80::20%'eth1.60'; # Iface with non-alphanumeric characters
route 2001:db8:40::/48 via "eth2"; # Direct route to eth2
route 2001:db8:40::/48 via fe80::30 dev "eth1"; # Another link-local nexthop
route 2001:db8:50::/48 via "eth2"; # Direct route to eth2
route 2001:db8::/32 unreachable; # Unreachable route
route ::/0 via 2001:db8:1::1 bfd; # BFD-controlled default route
}

View File

@ -87,6 +87,9 @@ stat_nexthop:
this_snh->via = IPA_NONE;
this_snh->iface = if_get_by_name($2);
}
| stat_nexthop DEV TEXT {
this_snh->iface = if_get_by_name($3);
}
| stat_nexthop MPLS label_stack {
this_snh->mls = $3;
}