]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Static: Allow to define both nexthop and interface
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 16 Feb 2024 17:44:40 +0000 (18:44 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 16 Feb 2024 17:44:40 +0000 (18:44 +0100)
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.

doc/bird.sgml
proto/static/config.Y

index 3861a5956d6cc589a84c0589aa5c490e952c8049..76ca7f75a6dded87b0ed346860e9896fc24bbfc2 100644 (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
 }
index 215681e8b0895e3082021ae55c3b49692b804dd9..e746b63cd3e9d3186fcabcc4e0fd594e7e10d93f 100644 (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;
   }