Tag: bgp

Advertising tenant networks with BGP EVPN type-5 in OpenStack

Tenant reachability with dynamic routing

Neutron‘s ML2/OVN driver keeps tenant networking inside OVN: a tenant network is a Geneve overlay among the nodes that host its ports, with no presence in the data center’s routing. When the underlay is a BGP EVPN fabric, a question shows up quickly: how does the rest of the data center reach tenant networks, the private networks tenants create at will and that are unreachable from outside, without resorting to flat provider networks or per-tenant VLAN plumbing? This post walks through BGP EVPN type-5, the mechanism that answers it.

The classic EVPN route type is type-2, the MAC/IP advertisement (RFC 7432): it carries endpoint MAC and IP bindings, which is how a tenant’s Layer-2 domain is stretched across an IP underlay. A routed tenant network needs something different, because what has to be reachable from outside is an IP prefix, not an individual MAC. That is the job of the EVPN type-5 route (the prefix route, RFC 9135/9136): it carries an IP prefix, a BGP next hop identifying the originating VTEP, a label field (carrying the VXLAN Network Identifier, or VNI, in VXLAN deployments), and an associated Ethernet Router MAC (RMAC) Extended Community used to resolve the next hop. In the current implementation those prefixes are always host routes (a /32 for IPv4 and a /128 for IPv6), because they are exactly the blackhole routes OVN installs in the tenant VRF. Subnet prefixes are not advertised. Wider prefixes are possible through other redistributable types such a static route on the router, which is advertised with its own prefix length.

OpenStack 2026.2  adds a new Neutron service: the EVPN service plugin, whose ovn-evpn extension runs in the ovn-agent. It turns a regular Neutron router into a VRF whose routes are advertised as EVPN type-5 routes by FRR, per tenant, automatically. This post walks the whole chain on a real deployment:

  1. What the API looks like and how Neutron programs the OVN Northbound database
  2. How OVN reacts: a Linux VRF appears on a networker node, maintained by ovn-controller
  3. What the Neutron agent builds (the Single VXLAN Device and per-VRF BGP configuration) and why
  4. A live traffic-flow inspection, showing end-to-end packet flow through a spine-and-leaf fabric

It is written for OpenStack operators, for teams evaluating dynamic routing for their clusters, and for network engineers who run a spine-and-leaf routed data center. The aim is to get you close enough to the centralized type-5 path to enable it on your own cluster and reason about it when a prefix does not turn up: which component owns which piece of a route, what the packets look like on the wire, and where to look next.

RELEASE STATUS

This is the centralized form of the feature: the type-5 routes are originated on the OVN gateway chassis, which is exactly the chain this post walks through. It merged for OpenStack 2026.2 Hibiscus (neutron 29.0.0) and depends on OVN 26.03, the first OVN release that supports EVPN type-5 routes. The design is Neutron to Provision BGP EVPN Type-5 Route Advertisement (neutron-specs, 2026.2).

The roadmap goes further, and both remaining pieces are already designed. Type-2 routes cover bridged traffic with MAC/IP advertisements. Distributed type-5 moves route origination to every compute node, so each node becomes a VTEP and advertises the prefixes of the workloads it hosts, with no detour through a gateway chassis. Both are targeted at 2027.1 Indri.

The BGP EVPN type-5 pipeline:

Neutron programs OVN NB, which replicates to SB. ovn-controller materializes a Linux VRF in the kernel; the ovn-agent watches SB’s Port_Binding table and the kernel’s netlink VRF events (both dashed), then adds the VRF to the node’s FRR configuration, which advertises the kernel routes as EVPN prefix routes.

The pipeline moves through four stages, and the Linux VRF on the networker node is where they meet: Neutron writes the intent to OVN, ovn-controller turns it into kernel routes, the ovn-agent adds the VRF to the node’s FRR configuration, and FRR advertises those routes to the fabric.

The API surface is deliberately tiny. A Neutron router gets one new attribute, and one router-interface flag controls what gets exported:

--evpn-vni (or --auto-evpn-vni to allocate from a pool) is admin-only and immutable, so pick it at create time. advertise-host on the interface says “keep a host route per port address on this subnet”, which OVN realizes as connected-as-host. Either way what leaves the VTEP is always a host route (/32 or /128), matching the blackhole routes OVN maintains in the VRF. And that’s the whole API. Everything below is what those two flags trigger.

The lab fabric

The command output in this post comes from a lab deployment of OpenStack on top of a Kubernetes cluster: the OpenStack control-plane services run as pods on the Kubernetes masters and workers, and the dataplane runs on separate nodes. The stack is ML2/OVN with the EVPN service plugin, OVN 26.03.3, OVS 3.7.2 and FRR 10.7.1, on a hybrid iBGP/eBGP EVPN fabric: three racks, two spines, and an external router that stands in for “the rest of the data center”:

The lab fabric. Networker nodes (red) host the OVN gateway chassis. The gateway role lands on dedicated networker nodes rather than on the nodes that run the OVN control plane: ovn-agent configures the local FRR instance. Each networker has two routed uplinks, one per leaf in its rack, installed as a single ECMP group; the spines and router-0 are dual-homed the same way.

In this deployment, the OVN gateways live on dedicated networker nodes, not on the compute nodes. That is what centralized means for this feature: the VTEP sits on the networker nodes, and each tenant router is owned by one networker at a time (chosen by an OVN HA_Chassis_Group). The distributed form, where every compute node is a VTEP, is in progress and is covered at the end of this post.

router-0 plays the external world. In a real deployment it would be a DC gateway or a VTEP in a second data center; in the lab we provision it with the same kernel+FRR constructs a real one would have, so the demo exercises genuine route exchange.

Note: On the Kubernetes nodes, FRR belongs to frr-k8s and is managed by the cluster. There is no frr-k8s integration in the ovn-agent yet, so dedicated networker nodes carry the gateway role.

The underlay: ECMP at every tier

None of this is pinned to a single physical link. Each networker has two routed uplinks (a /30 point-to-point link to each leaf of its rack), and FRR installs both BGP paths as one equal-cost nexthop group:

[root@r1-networker-0 ~]# ip route show
default nhid 20 proto bgp src 99.99.1.6 metric 20
        nexthop via 100.64.1.5 dev br-bgp-0 weight 1
        nexthop via 100.65.1.5 dev br-bgp-1 weight 1
100.64.1.4/30 dev br-bgp-0 proto kernel scope link src 100.64.1.6 metric 800
100.65.1.4/30 dev br-bgp-1 proto kernel scope link src 100.65.1.6 metric 800
192.168.123.0/24 dev eth1 proto kernel scope link src 192.168.123.210 metric 101

nhid 20 is a nexthop group, not a route with a preferred path: both legs are active, both weight 1, and the group is sourced from 99.99.1.6, the VTEP address. That address lives on the networker’s loopback interface as a /32, and FRR advertises it to the fabric through BGP, redistributing connected routes, so every leaf and spine learns a path to the VTEP itself. FRR sees the two uplinks as equal too, marking both paths best:

[root@r1-networker-0 ~]# vtysh -c "show ip route 0.0.0.0/0"
Routing entry for 0.0.0.0/0
  Known via "bgp", distance 200, metric 0, best
  Last update 02w6d18h ago
  Flags: Recursion iBGP Selected
  Status: Installed
  * 100.64.1.5, via br-bgp-0, rmapsrc 99.99.1.6, weight 1
  * 100.65.1.5, via br-bgp-1, rmapsrc 99.99.1.6, weight 1

Both paths are learned the same way, one iBGP session per leaf, and carry identical attributes, so the only differences are the peer and its next hop:

[root@r1-networker-0 ~]# vtysh -c "show bgp ipv4 unicast 0.0.0.0/0"
BGP routing table entry for 0.0.0.0/0, version 5
Paths: (2 available, best #1, table default)
  Not advertised to any peer
  Local
    100.64.1.5 (metric 800) from 100.64.1.5 (192.168.111.37)
      Origin IGP, metric 0, localpref 0, valid, internal, multipath, best
      Community: graceful-shutdown
      Last update: Wed Oct 21 14:48:46 2026
  Local
    100.65.1.5 (metric 800) from 100.65.1.5 (192.168.111.38)
      Origin IGP, metric 0, localpref 0, valid, internal, multipath
      Community: graceful-shutdown
      Last update: Wed Oct 21 14:48:46 2026

 Both peers run remote-as internal in their FRR configuration, which is what makes the sessions iBGP rather than eBGP. An empty AS path is what prints as Local: the default originates inside AS 65000. FRR marks each path multipath, picks the first only to break the tie on router ID, and hands both to zebra, which is where the nhid 20 comes from.

The spines keep an equal-cost group toward each networker VTEP (nhid 71 group 18/19, one leg per leaf in that rack), and router-0 keeps one toward each networker VTEP (nhid 18 group 19/20, one leg per spine). Every tier has two ways out, and none of it is visible to the overlay: a tenant route names a VTEP, never an uplink.

[root@spine-0 ~]# ip route show 99.99.1.6
99.99.1.6 nhid 71 proto bgp metric 20
        nexthop via inet6 fe80::413a:e664:5204:abdc dev eth4 weight 1
        nexthop via inet6 fe80::550b:b636:1ac4:5ec7 dev eth3 weight 1

[root@router-0 ~]# ip route show 99.99.1.6
99.99.1.6 nhid 18 proto bgp metric 20
        nexthop via inet6 fe80::cffd:d8a2:dfba:a161 dev eth1 weight 1
        nexthop via inet6 fe80::f345:6292:555d:67cb dev eth2 weight 1

PER-FLOW, NOT PER-PACKET

ECMP picks a path per flow, not per packet. The sending node hashes the packet’s addresses, ports, and protocol into the nexthop group, and every packet of that flow takes the chosen leg, so packets stay in order and one flow never spans both uplinks. For tunneled traffic the outer UDP source port is derived from the inner flow, so distinct tenant flows spread across the uplinks even though they all share the same VTEP addresses.

Failover follows the same nexthop group. If a leaf or an uplink goes away, BGP withdraws its path, zebra drops it from the group, and traffic rehashes onto the remaining uplinks. No tenant route, VNI, or type-5 advertisement has to change.

The operational consequence is asymmetry: each direction is hashed independently by the VTEP that sends it, so requests arriving on one leaf and replies leaving on the other are normal. A capture on a single uplink shows half the conversation; capture both.

The walkthrough

The resources: router evpn-router with VNI 100, network net0, subnet subnet0 (192.168.100.0/24), and a small VM vm0. Everything below is real output from the live system.

STEP 0
Create the router

$ openstack router create evpn-router --evpn-vni 100
| evpn_vni | 100                                  |
| id       | 4161f72b-721a-4dca-a95d-1eee3a283d0a |
| name     | evpn-router                          |
| status   | ACTIVE                               |

An explicit VNI keeps the external-endpoint provisioning deterministic; --auto-evpn-vni works too and allocates from a pool. Note that the VNI is also the Linux routing-table ID on the networker, a deliberate spec choice that makes debugging easier: ip route show table 100 is your tenant’s Routing Information Base (RIB).

STEP 1
What Neutron wrote into OVN NB

The EVPN service plugin translates the router into OVN’s dynamic-routing vocabulary:

$ ovn-nbctl list Logical_Router neutron-4161f72b-...
options : {dynamic-routing="true",
           dynamic-routing-redistribute=static,
           dynamic-routing-vrf-id="100",
           dynamic-routing-vrf-name=vr4161f72b-721a, ...}

dynamic-routing-redistribute is a list of route types that Neutron asks OVN to sync into the VRF. On the router it holds one entry, static, which covers static routes configured on the router; this demo has none, so nothing is synced for it. A router port can override that list, and STEP 2 shows a tenant port doing exactly that.

More interestingly, it also creates a dummy logical switch with a special router port on it:

$ ovn-nbctl find Logical_Switch name=evpn-ls-100
name        other_config
evpn-ls-100 {dynamic-routing-bridge-ifname=vl-0-1,
             dynamic-routing-vni="100",
             dynamic-routing-vxlan-ifname=vxlanevpn-0}
$ ovn-nbctl show
switch (evpn-ls-100)
    port evpn-lsp-evpn-ls-100-to-4161f72b-721
        type: router
        router-port: evpn-lrp-4161f72b-721-to-evpn-ls-100
router (neutron-4161f72b-...) (aka evpn-router)
    port evpn-lrp-4161f72b-721-to-evpn-ls-100
        mac: "fa:16:3e:1a:6d:fc"

No VM will ever attach to evpn-ls-100. It exists so that OVN has a place to map the VNI onto, and so the EVPN router port (evpn-lrp-…) exists; its MAC, fa:16:3e:1a:6d:fc, becomes the Rmac carried in every type-5 route. An HA_Chassis_Group spanning the networkers decides which networker owns the router; for evpn-router it landed on r1-networker-0.

STEP 2
What advertise-host puts on the router port

$ openstack network create net0          # geneve, MTU 1442
$ openstack subnet create subnet0 --network net0 --subnet-range 192.168.100.0/24
$ openstack router add subnet --advertise-host evpn-router subnet0
$ ovn-nbctl --columns=name,options list Logical_Router_Port \
    lrp-adb7f55d-3729-48a4-9caf-40deec8070cb
name                : lrp-adb7f55d-3729-48a4-9caf-40deec8070cb
options             : {dynamic-routing-redistribute=connected-as-host}

advertise-host makes Neutron set dynamic-routing-redistribute=connected-as-host on that router port. That way, the subnet contributes one /32 per address in use. Without the flag, Neutron writes nothing on the port and no address from that subnet is advertised. Because the decision is per subnet, an EVPN router can mix advertised and non-advertised subnets; the others still route inside OVN, they just never reach BGP.

The plumbing above serves a regular virtual machine, and the API will show it to you directly:

$ openstack server show vm0 \
      -c name -c status -c addresses -c OS-EXT-SRV-ATTR:host
| name                 | vm0                                  |
| status               | ACTIVE                               |
| addresses            | net0=192.168.100.157                 |
| OS-EXT-SRV-ATTR:host | r0-compute-0.ctlplane.example.com    |

So inside 192.168.100.0/24 the tenant has exactly three addresses: vm0 at 192.168.100.157, the metadata/DHCP port at 192.168.100.2, and the subnet gateway at 192.168.100.1, owned by the evpn-router. All three become host routes in the next step; only the gateway belongs to the router itself.

The tenant side, as OVN sees it. net0 holds three addresses: vm0 at 192.168.100.157 (bound on r0-compute-0, not on the networker), the metadata/DHCP port at 192.168.100.2, and the router port at 192.168.100.1. Of the three, only evpn-router is something the fabric knows as an EVPN endpoint: it reaches the networker’s VTEP (99.99.1.6) over VNI 100, which is also the Linux table ID, and the tenant addresses are advertised behind the Rmac it carries on evpn-ls-100.

STEP 3
How OVN built the Linux VRF

On r1-networker-0, once ovn-controller has claimed the router port, it creates a Linux VRF and populates it with host routes (protocol 84 is OVN’s):

$ ip route show table 100    # r1-networker-0
99.99.99.1 nhid 418 via 99.99.99.1 dev vl-0-1 proto bgp metric 20 onlink
blackhole 192.168.100.1   proto 84 metric 100    # router interface port
blackhole 192.168.100.2   proto 84 metric 1000   # metadata/DHCP port
blackhole 192.168.100.157 proto 84 metric 1000   # vm0 (after it boots)

$ ip nexthop show id 418
id 418 group 419 proto zebra
$ ip nexthop show id 419
id 419 via 99.99.99.1 dev vl-0-1 scope link proto zebra onlink

The first line is a control-plane route to router-0’s VTEP, resolved onlink through the tenant Switched Virtual Interface (SVI). That route points at a nexthop group with one member, 419, which holds the gateway; both objects are proto zebra, so FRR’s route engine created them, while the route itself is proto bgp. Inside the VRF there is only one way to that VTEP, vl-0-1. Tenant traffic never follows it.

The blackholes are FRR’s export source: each prefix sits in table 100 with no usable next hop, so the kernel drops anything it would route out of it, and redistribute kernel, which STEP 4 shows in the VRF’s FRR configuration, takes the prefix from there and hands it to BGP.

The metric is OVN’s local-binding marker: 100 means the port that owns the prefix is local to the chassis advertising it, 1000 means it is not. 192.168.100.1 is the router port itself, a patch port with no chassisredirect, which OVN counts as local on every chassis; .2 is the metadata localport, whose binding carries no chassis, and vm0’s /32 belongs to a port bound on r0-compute-0, so both are remote from this networker. The distinction matters when several chassis advertise the same prefix: the one that owns the port announces at 100, and and within AS 65000 the fabric prefers the lower metric. vm0’s /32 appeared on its own when the VM booted: no API call, no agent restart.

OVN SB shows where both decisions come from: the EVPN router port is bound to this chassis, and its options carry the VRF name and the flag that makes OVN own the VRF:

Port_Binding(type=chassisredirect,
  logical_port=cr-evpn-lrp-4161f72b-721-to-evpn-ls-100,
  options={'dynamic-routing-maintain-vrf': 'true',
           'dynamic-routing-vrf-name': 'vr4161f72b-721a', ...},
  external_ids={'vlan': '1', 'vni': '100'},
  chassis=[r1-networker-0])

dynamic-routing-maintain-vrf is what makes the VRF OVN’s to create: with the flag, ovn-controller creates the VRF device itself, and if the flag is later removed it leaves a VRF it created in place. Without it, OVN still syncs routes into the routing table, but expects the VRF to be provisioned elsewhere. dynamic-routing-vrf-name supplies the name, vr4161f72b-721a, and the external_ids tie the port to VLAN 1 and VNI 100.

And here is the agent’s whole decision procedure, from its own log: a small finite-state machine (FSM) per VRF, waiting on two events, netlink saying the VRF device exists, and the SB saying the router port is bound here:

09:08:22.095 netlink_monitor: VRF created: vr4161f72b-721a
09:08:22.096 fsm: EVPN VRF vr4161f72b-721a: init -> waiting_for_bridge
09:08:22.112 PortBindingLrpEvpnCreateEvent matched (cr- port bound to this chassis)
09:08:22.116 fsm: EVPN VRF vr4161f72b-721a: waiting_for_bridge -> advertising
09:08:22.155 svd: SVD brevpn-0/vxlanevpn-0: added VLAN 1 -> VNI 100, SVI vl-0-1
09:08:22.162 frr_driver: Creating EVPN router: (asn=65000, vrf_name='vr4161f72b-721a', vni=100)
09:08:22.374 fsm: EVPN: advertised ...

The two events can arrive in either order; the FSM has a waiting state for each and converges. The svd: line is where the VNI lands on this chassis: the SVD is the one VXLAN netdev per chassis (vxlanevpn-0, on bridge brevpn-0), into which the agent maps every tenant VNI, VLAN by VLAN. Teardown is the mirror image (advertising → waiting_for_bridge → destroy), removing the VNI from the SVD and the FRR router.

STEP 4
What the agent built: the single VXLAN device and per-VRF BGP

The ovn-evpn extension in the ovn-agent runs on every OVN gateway chassis. Once its FSM fires, it maps the tenant into that shared single VXLAN device:

$ ip -d link show vl-0-1   # r1-networker-0
21: vl-0-1@brevpn-0: ... master vr4161f72b-721a ...
    link/ether fa:16:3e:1a:6d:fc ... # same MAC as the EVPN LRP / Rmac

Two VXLAN devices, two planes. Everything in the left pane is RIB-only: the agent’s SVD (vl-0-1, brevpn-0, vxlanevpn-0 on port 60010) exists so the tenant VRF has an L3 presence in VNI 100 and FRR has somewhere to run the per-VRF EVPN instance. No tenant packet goes near it. Tenant traffic lives entirely in the right pane: it arrives on vxlan_sys_4789, the dummy logical switch maps VNI 100 into evpn-router, and ovn-controller sends it on to the computes over geneve. Because every step of that tenant path is OVS (VXLAN in, logical routing, geneve out), it runs unchanged on OVS-DPDK: the datapath moves to userspace and tenant forwarding is accelerated, with no EVPN-specific data path to implement.

The VRF gets its L3 interface into the VNI via vl-0-1 (VLAN 1), enslaved into the tenant VRF and carrying the Rmac. The VLAN↔VNI mapping is consistent across the cloud because Neutron allocates the pair per router and stores it, with the VNI unique fabric-wide and the VLAN unique per physical network, so every chassis maps VNI 100 to the same VLAN. One SVD carries at most 4094 VLAN↔VNI mappings, because VLAN IDs 0 and 4095 are reserved out of 4096, and the agent creates one SVI per mapping, so a networker can serve 4094 tenant VNIs. Scaling beyond that by indexing additional SVDs (brevpn-$i/vxlanevpn-$i) is designed for but not yet implemented.

Then FRR. The agent creates one BGP instance per tenant VRF, and two lines inside it matter here: redistribute kernel pulls the VRF’s routes in, and advertise ipv4 unicast sends them out.

$ vtysh -c "show running-config"   # r1-networker-0
vrf vr4161f72b-721a
 vni 100
exit-vrf
!
router bgp 65000 vrf vr4161f72b-721a
 address-family ipv4 unicast
  redistribute kernel
 exit-address-family
 address-family l2vpn evpn
  advertise ipv4 unicast        <-- this generates the type-5 routes
 exit-address-family

The address family is called l2vpn evpn even though these are prefix routes: EVPN is carried under the L2VPN address family (AFI 25/SAFI 70, named for its L2 origins), and advertise ipv4 unicast inside it is what produces the type-5s. So redistribute kernel pulls the proto-84 routes out of table 100, and each one leaves as an EVPN prefix route. Here is the result as the networker’s leaf sees it:

$ vtysh -c "show bgp l2vpn evpn"   # leaf-2
Route Distinguisher: 99.99.1.6:2
 *>  [5]:[0]:[32]:[192.168.100.1]
      99.99.1.6   100  32768 ?  ET:8 RT:65000:100 Rmac:fa:16:3e:1a:6d:fc
 *>  [5]:[0]:[32]:[192.168.100.2]
      99.99.1.6  1000  32768 ?  ET:8 RT:65000:100 Rmac:fa:16:3e:1a:6d:fc
 *>  [5]:[0]:[32]:[192.168.100.157]
      99.99.1.6  1000  32768 ?  ET:8 RT:65000:100 Rmac:fa:16:3e:1a:6d:fc

The Route Distinguisher: 99.99.1.6:2 line is the RD for this VRF on that VTEP, in the form <VTEP address>:<locally assigned number>. The number only has to be unique on the VTEP; nothing in this walkthrough depends on its value. Three type-5 routes follow: the gateway, the metadata/DHCP port, and vm0. RT is auto-derived as <AS>:<VNI> = 65000:100. The metrics are the ones OVN wrote, carried through into BGP. Leaf-2 learns them over iBGP from the networker and re-advertises to the spines over eBGP. However, those metrics are local to the fabric: across the eBGP edge to router-0 the metric does not propagate, which is why the same prefixes show metric 20 in router-0’s table in the next step.

One version note: the build behind these captures advertises all three. Upstream code merged for 2027.1 sets dynamic-routing-advertise=false on the gateway and metadata ports, keeping OVN’s default of true for workload host routes; the option requires OVN 26.09. A 2026.2 deployment, which has neither the patch nor 26.09, still advertises all three.

STEP 5
What the remote VTEP sees

On router-0 we provision the same constructs a remote DC gateway would have: a VRF with a VNI binding, a bridge with a VXLAN member, and a per-VRF FRR configuration that imports what the fabric advertises:

$ ip route show table 100  # router-0
local 99.99.99.1 dev br-100 proto kernel scope host src 99.99.99.1
192.168.100.1   nhid 474 via 99.99.1.6 dev br-100 proto bgp metric 20 onlink
192.168.100.2   nhid 474 via 99.99.1.6 dev br-100 proto bgp metric 20 onlink
192.168.100.157 nhid 474 via 99.99.1.6 dev br-100 proto bgp metric 20 onlink

The import is not automatic, because router-0 and the networker sit in different ASes: the routes arrive carrying RT:65000:100, derived from the networker’s AS and VNI, while router-0 is AS 64999, so nothing derives that target locally, and without the explicit import line the routes would stay in the BGP table without ever reaching table 100. What router-0 received:

$ vtysh -c "show bgp l2vpn evpn"   # router-0
Route Distinguisher: 99.99.1.6:2
 *>i [5]:[0]:[32]:[192.168.100.157]
                    99.99.1.6                       0      0 65000 ?
                    RT:65000:100 ET:8 Rmac:fa:16:3e:1a:6d:fc

And the line that lets those routes into the VRF:

$ vtysh -c "show running-config"   # router-0, VRF
router bgp 64999 vrf evpnvrf-100
 address-family l2vpn evpn
  advertise ipv4 unicast
  route-target import 65000:100   <-- imports the tenant routes
 exit-address-family

STEP 6
What the packets show: TTL as the hop counter

# tenant gateway (OVN LR)
$ ip vrf exec evpnvrf-100 ping -c 2 192.168.100.1
64 bytes from 192.168.100.1: icmp_seq=1 ttl=254 time=1.75 ms

# vm0 on r0-compute-0
$ ip vrf exec evpnvrf-100 ping -c 3 192.168.100.157
64 bytes from 192.168.100.157: icmp_seq=1 ttl=63 time=4.08 ms

The journey across the fabric costs zero TTL: every device between router-0 and r1-networker-0, spines and leaves included, forwards the outer encapsulation and never touches the tenant IP header. The single TTL decrement in the whole path comes at the centralized OVN logical router on the networker, which routes the inner packet. That one hop is why tracepath shows nothing useful here. Nothing on the path answers a probe: the outer hops only see the encapsulation, and the probe itself comes back unanswered at every TTL:

$ ip vrf exec evpnvrf-100 tracepath -n -m 6 192.168.100.157  # router-0
 1?: [LOCALHOST]                      pmtu 1442
 1:  no reply
 2:  no reply
 3:  no reply
 4:  no reply
 5:  no reply
 6:  no reply
     Too many hops: pmtu 1442

That leaves ping TTL as the honest hop counter: there is one decrement to look for on the whole path, and both replies above show it.

Tcpdump along the path, with a ping running, tells the sharper story:

$ tcpdump -ni vxlan-100   # router-0: VNI 100, 99.99.99.1 -> 99.99.1.6
IP 99.99.99.1 > 192.168.100.157: ICMP echo request
IP 192.168.100.157 > 99.99.99.1: ICMP echo reply

$ tcpdump -ni vxlan_sys_4789 host 99.99.99.1   # r1-networker-0: SAME packets
IP 99.99.99.1 > 192.168.100.157: ICMP echo request
IP 192.168.100.157 > 99.99.99.1: ICMP echo reply

$ tcpdump -ni br-bgp-0 udp port 4789   # requests in (leaf-2)
IP 99.99.99.1.39749 > 99.99.1.6.vxlan: VXLAN, flags [I] (0x08), vni 100
    IP 99.99.99.1 > 192.168.100.157: ICMP echo request

$ tcpdump -ni br-bgp-1 udp port 4789   # replies out (leaf-3)
IP 99.99.1.6.54324 > 99.99.99.1.vxlan: VXLAN, flags [I] (0x08), vni 100
    IP 192.168.100.157 > 99.99.99.1: ICMP echo reply

$ tcpdump -ni vl-0-1 ; tcpdump -ni vxlanevpn-0  # NOTHING

$ tcpdump -ni any icmp                          # r0-compute-0
genev_sys_6081 P  IP 99.99.99.1 > 192.168.100.157: ICMP echo request

The last two captures are ECMP visible on the wire, and each direction was hashed by a different VTEP: router-0’s VTEP, 99.99.99.1, put the request on the path through leaf-2, and the networker’s VTEP, 99.99.1.6, put the reply on the path through leaf-3. Each host has a single VTEP, addressed on its loopback, but each makes its own per-flow choice, so the two need not match, and a capture on one uplink only shows half the conversation.

The captures on vl-0-1 and vxlanevpn-0 stay empty because the agent’s SVD is control-plane only. It gives the tenant VRF an L3 presence in VNI 100, so FRR can run a per-VRF EVPN instance and install learned routes onlink through the SVI. Tenant traffic arrives on vxlan_sys_4789, an OVS datapath port (packet_type=ptap) created by ovn-controller, and leaves the networker as Geneve. The EVPN-specific pieces live in the control plane; the tenant data path is just regular OVS tunneling and logical routing, which is why an OVS-DPDK deployment accelerates it without them changing.

The routing state itself lives in the Linux VRF, not in OVN NB. OVN writes the proto-84 routes into table 100, FRR redistributes them out as type-5, and FRR installs fabric-learned routes back (proto bgp), where ovn-controller’s maintain-vrf picks them up. ovn-nbctl lr-route-list on the evpn-router stays empty throughout: the external route never becomes an NB static route, and ovn-controller handles it at the chassis level.

Wrapping up

Two flags are all a tenant router needs, and they set the chain in motion: Neutron writes the intent to OVN NB, ovn-controller turns the router into a Linux VRF on the owning networker, the agent builds the SVD and the per-VRF BGP instance, and FRR advertises the VRF’s host routes as EVPN type-5 routes.

The fabric only ever sees an IP prefix and a VTEP: no MAC, no uplink, no per-tenant VLAN. The underlay spends zero TTL, because spines and leaves forward the tunnel without touching the tenant header; the one decrement on the path from router-0 to vm0 is the tenant router itself. ECMP spreads flows across the leaves, and the state to watch is one Linux table numbered after the VNI. Neutron owns the intent, OVN owns the VRF, the agent owns the glue, and FRR owns the wire.

Try it

Type-5 advertisement is available from OpenStack 2026.2 Hibiscus, and you can see it on your own fabric with two commands: openstack router create <name> --evpn-vni <vni>, then openstack router add subnet --advertise-host <router> <subnet>. Start the check on the owning networker with ip route show table <vni>: if the host routes are there, OVN has done its part and anything left to fix is in FRR or the fabric.

Feedback is welcome on the openstack-discuss mailing list, which is where the design questions get answered. For the design behind the behavior, read the centralized type-5 spec; the type-2 and distributed type-5 specs show what comes next, and both are targeted at 2027.1 Indri.

Learning OVN and BGP with Claude AI

Recently, OVN has introduced BGP support and I did not have the time to follow the development so I decided to use the help of AI (Claude Code CLI) to learn about the new feature. The path I chose here is:

  1. Run one of the existing BGP tests  (ovn multinode bgp unnumbered)
  2. Use AI (claude-sonnet-4.5 model) to help me understand what the test does
  3. Identify the parts of the codebase that implement some of the bits in the test
  4. Do a small modification to the test to do something new

1. Run the BGP test from the OVN sources

To run this test, I need first to deploy an ovn-fake-multinode setup with 4 chassis and 4 gateways. I did it just by following the instructions in the README.md file.

$ sudo -E CHASSIS_COUNT=4 GW_COUNT=4 ./ovn_cluster.sh start

After deploying the cluster, you’ll have multiple containers running but only the ovn-central-az1, ovn-gw-1, and ovn-gw-2 are relevant to this test. This cluster will have some OVN resources but the test cleans them up upon start.

I did not want to investigate much how these containers are wired so I asked Claude to read the sources and produce a diagram for me. It also helped me to render it into a PNG file using ImageMagick :p

Essentially, it will create two OVS bridges in my host to connect eth1 on each container for the underlay and eth2 for the dataplane. The eth0 interface is connected to the podman network for management.

Now we run the test and stop it before the clean up. This you can do by adding a check false right before the cleanup, and then executing the test like this:

OVS_PAUSE_TEST=1 make check-multinode TESTSUITEFLAGS="-k 'ovn multinode bgp unnumbered' -v"

Once the test stops, you can see that it’s completed successfully and it was able to ping some IP address, and the containers are running with the configuration and resources created by the test.

multinode.at:2959: waiting until m_as ovn-gw-1 ip netns exec frr-ns ping -W 1 -c 1 172.16.10.2...
PING 172.16.10.2 (172.16.10.2) 56(84) bytes of data.
64 bytes from 172.16.10.2: icmp_seq=1 ttl=62 time=2.32 ms

--- 172.16.10.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.322/2.322/2.322/0.000 ms
multinode.at:2959: wait succeeded immediately
multinode.at:2960: waiting until m_as ovn-gw-2 ip netns exec frr-ns ip route | grep -q 'ext1'...
multinode.at:2960: wait succeeded immediately
multinode.at:2961: waiting until m_as ovn-gw-2 ip netns exec frr-ns ping -W 1 -c 1 172.16.10.2...
PING 172.16.10.2 (172.16.10.2) 56(84) bytes of data.
64 bytes from 172.16.10.2: icmp_seq=1 ttl=62 time=1.77 ms

--- 172.16.10.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.773/1.773/1.773/0.000 ms
multinode.at:2961: wait succeeded immediately
false
./ovn-macros.at:856: "$@"
./ovn-macros.at:856: exit code was 1, expected 0
=====================================================
Set following environment variable to use various ovs utilities
export OVS_RUNDIR=/root/ovn/tests/multinode-testsuite.dir/17
Press ENTER to continue:


$ podman exec ovn-central-az1 ovn-nbctl show | grep -E '^(router|switch)'
switch 05e453e9-f5b2-47b9-9eb6-10ef6ea8a08c (ls-ovn-gw-2-ext0)
switch 8a12c075-6367-46b0-ac5a-88346450fc60 (ls-ovn-gw-1-ext0)
switch 3cc96979-1aab-4cd3-a84b-6f5f36bd4a42 (ls-guest-ovn-gw-1)
switch e24ad9c9-ef80-4686-96eb-88ef47d9bc01 (ls-guest-ovn-gw-2)
switch 9a279d1b-0929-4386-a704-fb9faaf6dfa6 (ls-join)
router e0a37965-c854-4c17-a4bb-4401d61c48a6 (lr-guest)
router 1f81175b-1168-4956-b7a8-64c85c07af4f (lr-ovn-gw-1-ext0)
router ce2161ff-ea11-4fb0-954b-75f0cf26f3d7 (lr-ovn-gw-2-ext0)

2. Use Claude AI to understand what the test does

At this point I read the test and I can see that there’s a fake VM with a Floating IP (172.16.10.2) that’s reachable through the simulated ToR switches. The ToRs learn the route via BGP, but I’m struggling to understand the exact topology and configuration because the test uses several layers of macros that call other macros.

Claude to the rescue!

I used Claude to help me:

  • Trace through the macro definitions to understand what topology gets created
  • Identify which components run where (containers, namespaces, VRFs)
  • Map out the BGP peering relationships and AS numbers
  • Understand how FRR is configured on both the ToRs and OVN gateways
  • Figure out why there are two separate FRR instances running on the same container The key insight Claude helped me understand was that the test simulates both the ToR switches and the OVN gateways within the same container nodes, using:
  • Network namespaces (frr-ns) to isolate the ToR’s network stack
  • Two separate FRR instances – one for the ToR (in frr-ns) and one for the OVN gateway (in default namespace, using VRFs)
  • BGP unnumbered peering using IPv6 link-local addresses between them

As a bonus, I asked Claude to draw a couple of diagrams for me to better understand the topology that this test creates:

 

Since I stopped the test before the cleanup, I told Claude how to access the remote lab and asked to inspect the live environment via SSH commands.

NOTE: Before I got the answer below I had been asking Claude things about the macros that the test uses and it’s been unpacking and reading a lot of the OVN code that I checked out locally. I re-ran this on a fresh session and it failed to figure out things like who creates the VRFs where the blackhole routes are installed, so it required a few more follow-up questions until I was able to find the right answers.

> I would like you to inspect the live deployment and show how the routes get advertised (eg. listing the different OVN tables, FRR configuration, etcetera). You can access the live environment by running 'ssh ovnlab' directly and using 'sudo'.


⏺ Perfect! Let me trace through exactly how the Floating IP (172.16.10.2) gets advertised from OVN through to the external ToR switches via BGP.

  ---  Step 1: NAT Configuration in OVN Northbound

  First, the NAT rule is configured on the guest router:

  $ podman exec ovn-central-az1 ovn-nbctl list NAT
  _uuid               : 4305c6db-b431-400d-b3e8-248d920394fc
  external_ip         : "172.16.10.2"
  logical_ip          : "192.168.10.10"
  type                : dnat_and_snat
  gateway_port        : lrp-guest-join-dgp
  options             : {add_route="true", ...}

  Key points:
  - external_ip: 172.16.10.2 (the Floating IP)
  - logical_ip: 192.168.10.10 (the internal VM IP)
  - gateway_port: Associated with the Distributed Gateway Port (DGP)
  - add_route=true: Tells OVN to create a route for this NAT entry

  Step 2: Dynamic Routing and VRF Configuration

  The gateway routers are configured with dynamic routing and VRF settings:

  $ podman exec ovn-central-az1 ovn-nbctl get logical_router lr-ovn-gw-1-ext0 options
  {chassis=ovn-gw-1, dynamic-routing="true", dynamic-routing-vrf-id="10"}

  $ podman exec ovn-central-az1 ovn-nbctl get logical_router_port lrp-ovn-gw-1-ext0 options
  {dynamic-routing-maintain-vrf="true", dynamic-routing-redistribute=nat,
   routing-protocol-redirect=lsp-ovn-gw-1-ext0-bgp, routing-protocols="BGP,BFD"}

  This configuration tells OVN:
  - Enable dynamic routing on lr-ovn-gw-1-ext0
  - Use VRF ID 10 (will create VRF named ovnvrf10)
  - dynamic-routing-maintain-vrf=true on the router port - This is the key setting that tells ovn-controller to create and maintain the VRF in the kernel
  - Redistribute NAT routes via the router port
  - Redirect BGP protocol traffic to the lsp-ovn-gw-1-ext0-bgp port

  When ovn-controller on the ovn-gw-1 chassis sees the dynamic-routing-maintain-vrf=true option, it automatically creates the VRF in the kernel:

  $ podman exec ovn-gw-1 ip link show type vrf
  11: ovnvrf10: <NOARP,MASTER,UP,LOWER_UP> mtu 65575 qdisc noqueue state UP mode DEFAULT group default qlen 1000
      link/ether 7a:7c:6f:2c:0d:22 brd ff:ff:ff:ff:ff:ff

  The VRF name is constructed as ovnvrf + dynamic-routing-vrf-id (10 in this case).

  Similarly, on ovn-gw-2, the VRF ID 20 creates ovnvrf20.

  Step 3: Advertised Routes in OVN Southbound

  OVN northd processes the NAT configuration and creates advertised route entries:

  $ podman exec ovn-central-az1 ovn-sbctl list Advertised_Route
  _uuid               : 360a360a-4ff4-4e87-888f-80e7c3b55e0a
  ip_prefix           : "172.16.10.2"
  logical_port        : lrp-ovn-gw-1-to-join
  ...

  _uuid               : d3a74c47-2ad9-471e-8b5e-e186ab774f21
  ip_prefix           : "172.16.10.2"
  logical_port        : lrp-ovn-gw-2-to-join
  ...

  Both gateway routers have advertised route entries for 172.16.10.2 because:
  - Each gateway router (lr-ovn-gw-1-ext0, lr-ovn-gw-2-ext0) has dynamic-routing-redistribute=nat configured on its port connecting to the join switch
  - The NAT entry from lr-guest gets redistributed to both gateway routers
  - Each gateway then advertises the FIP to its respective ToR (ovn-ext-1 and ovn-ext-2)
  - This provides connectivity from both external ASNs (ASN 4200000100 and ASN 4200000200) to reach the FIP

  The DGP location only matters for actual traffic forwarding, not for route advertisement. Both ToRs can advertise reachability to 172.16.10.2, and when traffic arrives at either gateway, OVN's overlay handles forwarding it to whichever chassis actually hosts the DGP.

  Step 4: Blackhole Routes in the Kernel

  OVN-controller on each gateway node installs blackhole routes in the VRF:

  $ podman exec ovn-gw-1 ip route show vrf ovnvrf10
  blackhole 172.16.10.2 proto 84 metric 1000

  $ podman exec ovn-gw-2 ip route show vrf ovnvrf20
  blackhole 172.16.10.2 proto 84 metric 1000

  These blackhole routes serve as markers for FRR to detect and advertise via BGP. They don't actually route traffic (that's handled by OVN flows), but FRR's redistribute kernel configuration picks them up.

  Step 5: FRR BGP Advertisement (OVN Gateway Side)

  FRR on the OVN gateway sees the kernel route and advertises it to its BGP neighbor:

  $ podman exec ovn-gw-1 vtysh --vty_socket /run/frr/ -c "show bgp vrf ovnvrf10 ipv4"
  BGP table version is 1, local router ID is 14.14.14.14, vrf id 11
  Default local pref 100, local AS 4210000000

       Network          Next Hop            Metric LocPrf Weight Path
   *>  172.16.10.2/32   0.0.0.0               1000         32768 ?

  The route shows:
  - Next Hop: 0.0.0.0 - locally originated (from kernel redistribution)
  - Weight: 32768 - default weight for local routes
  - Path: ? - incomplete origin (redistributed from kernel)

  Step 6: BGP Peering (Unnumbered)

  The OVN gateway and ToR are peered using BGP unnumbered (IPv6 link-local addresses):

  $ podman exec ovn-gw-1 vtysh --vty_socket /run/frr/ -c "show bgp vrf ovnvrf10 neighbors ext0-bgp"
  BGP neighbor on ext0-bgp: fe80::a8ed:baff:feb6:585e, remote AS 4200000100, local AS 4210000000
  BGP state = Established, up for 1d06h12m
  ...
  Prefix statistics:
    0 accepted, 1 sent prefixes

  Key details:
  - Neighbor: fe80::a8ed:baff:feb6:585e (IPv6 link-local - unnumbered)
  - Remote AS: 4200000100 (the ToR's ASN)
  - Local AS: 4210000000 (OVN gateway's ASN)
  - Sent prefixes: 1 (the 172.16.10.2/32 route)

  Step 7: FRR BGP Learning (ToR Side)

  The ToR's FRR instance receives and accepts the route:

  $ podman exec ovn-gw-1 vtysh --vty_socket /run/frr/frr-ns/ -c "show bgp ipv4"
  BGP table version is 1, local router ID is 41.41.41.41, vrf id 0
  Default local pref 100, local AS 4200000100

       Network          Next Hop            Metric LocPrf Weight Path
   *>  172.16.10.2/32   ext1                  1000             0 4210000000 ?

  The ToR now knows:
  - Network: 172.16.10.2/32
  - Next Hop: ext1 (the interface toward the OVN gateway)
  - Metric: 1000 (inherited from the advertised route)
  - ASN Path: 4210000000 (learned from the OVN gateway's ASN)

  Summary: Complete Advertisement Chain

  1. NAT Config (NB)
     ↓
  2. Dynamic Routing + VRF Config (NB)
     ↓
  3. VRF Creation (Kernel) ← ovn-controller sees dynamic-routing-maintain-vrf=true
     ↓
  4. Advertised Routes (SB) ← northd processing
     ↓
  5. Blackhole Routes (Kernel VRF) ← ovn-controller
     ↓
  6. BGP Table (FRR Gateway) ← redistribute kernel
     ↓
  7. BGP Peering (IPv6 LLA)
     ↓
  8. BGP Table (FRR ToR) ← received from peer

  This shows the complete journey of how a NAT entry in OVN becomes a BGP route advertised to external infrastructure, enabling seamless integration between OVN's virtual networking and physical network routing.

3. Identify the parts of the codebase that implement some of the bits in the test

At this point I believe I understand what the test does and how the BGP implementation works on the surface. In order for me to get a deeper understanding of certain parts of the code I want to understand how and when the VRF is created by ovn-controller. Since Claude has access to the OVN sources and my live environment, it should be able to give me good pointers to it 🙂

> I want to get some details (source code level) about how and when ovn-controller creates the VRF where it installs the blackhole routes.


⏺ Let me trace through the source code to show you exactly how and when ovn-controller creates the VRF and installs the blackhole routes.

⏺ Read(ovn/controller/route-exchange.c)
  ⎿  Read 100 lines

⏺ Search(pattern: "vrf.*create|create.*vrf", path: "ovn/controller", output_mode: "content")
  ⎿  Found 5 lines (ctrl+o to expand)

⏺ Read(ovn/controller/route-exchange.c)
  ⎿  Read 150 lines

⏺ Read(ovn/controller/route-exchange-netlink.c)
  ⎿  Read 80 lines

⏺ Now let me check where the advertise_datapath_entry gets populated with the maintain_vrf flag:

⏺ Search(pattern: "maintain_vrf.*=|->maintain_vrf", path: "ovn/controller", output_mode: "content")
  ⎿  Found 2 lines (ctrl+o to expand)

⏺ Read(ovn/controller/route.c)
  ⎿  Read 50 lines

⏺ Perfect! Now let me check how advertised routes get added:

⏺ Search(pattern: "Advertised_Route|advertised.*route", path: "ovn/controller/route.c", output_mode: "content")
  ⎿  Found 3 lines (ctrl+o to expand)

⏺ Read(ovn/controller/route.c)
  ⎿  Read 80 lines

⏺ Perfect! Now I have the complete picture. Let me create a detailed source code-level explanation:

  ---
  Source Code Deep Dive: VRF Creation and Blackhole Route Installation

  Overview

  The VRF creation and blackhole route installation happens in ovn-controller through a multi-step process coordinated between several source files. Let me trace through the exact code path.

  Step 1: Checking for dynamic-routing-maintain-vrf Option

  File: controller/route.c (lines 206-209)

  ad->maintain_vrf |=
      smap_get_bool(&repb->options,
                    "dynamic-routing-maintain-vrf",
                    false);

  What happens here:
  - ovn-controller iterates through all router port bindings (repb) that have dynamic routing enabled
  - For each port, it checks if the dynamic-routing-maintain-vrf option is set to true
  - If found, it sets the maintain_vrf flag in the advertise_datapath_entry structure
  - This flag tells ovn-controller that it is responsible for creating and managing the VRF

  Step 2: Determining VRF Name

  File: controller/route.c (lines 211-225)

  const char *vrf_name = smap_get(&repb->options,
                                  "dynamic-routing-vrf-name");
  if (vrf_name && strlen(vrf_name) >= IFNAMSIZ) {
      // Warn and ignore if name is too long
      vrf_name = NULL;
  }
  if (vrf_name) {
      memcpy(ad->vrf_name, vrf_name, strlen(vrf_name) + 1);
  } else {
      snprintf(ad->vrf_name, sizeof ad->vrf_name, "ovnvrf%"PRIu32,
               route_get_table_id(ad->db));
  }

  What happens here:
  - First checks if a custom VRF name is specified via dynamic-routing-vrf-name option
  - If no custom name is provided, constructs the default name as ovnvrf + VRF ID
  - For example, with dynamic-routing-vrf-id=10, it creates ovnvrf10

  Step 3: Creating the VRF

  File: controller/route-exchange.c (lines 265-277)

  if (ad->maintain_vrf) {
      if (!sset_contains(&old_maintained_vrfs, ad->vrf_name)) {
          error = re_nl_create_vrf(ad->vrf_name, table_id);
          if (error && error != EEXIST) {
              VLOG_WARN_RL(&rl,
                           "Unable to create VRF %s for datapath "
                           UUID_FMT": %s.", ad->vrf_name,
                           UUID_ARGS(&ad->db->header_.uuid),
                           ovs_strerror(error));
              SET_ROUTE_EXCHANGE_NL_STATUS(error);
              continue;
          }
      }
      sset_add(&_maintained_vrfs, ad->vrf_name);
  }

  What happens here:
  - During the route_exchange_run() function execution (called on every ovn-controller iteration)
  - Checks if the VRF was already created in a previous iteration (by checking old_maintained_vrfs)
  - If not, calls re_nl_create_vrf() to create it via netlink
  - Adds the VRF name to _maintained_vrfs set to track it
  - If VRF already exists (EEXIST error), silently continues (this is normal)

  Step 4: Netlink VRF Creation

  File: controller/route-exchange-netlink.c (lines 42-77)

  int
  re_nl_create_vrf(const char *ifname, uint32_t table_id)
  {
      if (!TABLE_ID_VALID(table_id)) {
          // ... error handling
          return EINVAL;
      }

      // Prepare netlink message
      struct ofpbuf request;
      uint8_t request_stub[NETNL_REQ_BUFFER_SIZE];
      ofpbuf_use_stub(&request, request_stub, sizeof(request_stub));

      // Create RTM_NEWLINK message with VRF attributes
      nl_msg_put_nlmsghdr(&request, 0, RTM_NEWLINK,
                          NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_EXCL);
      ifinfo = ofpbuf_put_zeros(&request, sizeof *ifinfo);
      nl_msg_put_string(&request, IFLA_IFNAME, ifname);  // VRF name

      ifinfo->ifi_change = ifinfo->ifi_flags = IFF_UP;   // Bring it UP
      linkinfo_off = nl_msg_start_nested(&request, IFLA_LINKINFO);
      nl_msg_put_string(&request, IFLA_INFO_KIND, "vrf");  // Type: VRF
      infodata_off = nl_msg_start_nested(&request, IFLA_INFO_DATA);
      nl_msg_put_u32(&request, IFLA_VRF_TABLE, table_id);  // VRF table ID
      nl_msg_end_nested(&request, infodata_off);
      nl_msg_end_nested(&request, linkinfo_off);

      // Send to kernel via netlink
      err = nl_transact(NETLINK_ROUTE, &request, NULL);

      ofpbuf_uninit(&request);
      return err;
  }

  What happens here:
  - Constructs a netlink RTM_NEWLINK message to create a new network interface
  - Sets the interface type to "vrf"
  - Associates it with the routing table ID (from dynamic-routing-vrf-id)
  - Sets the interface to UP state immediately
  - Sends the netlink message to the kernel's routing subsystem
  - The kernel creates the VRF device (e.g., ovnvrf10)

  Step 5: Reading Advertised Routes from Southbound DB

  File: controller/route.c (lines 267-295)

  const struct sbrec_advertised_route *route;
  SBREC_ADVERTISED_ROUTE_TABLE_FOR_EACH (route,
                                         r_ctx_in->advertised_route_table) {
      struct advertise_datapath_entry *ad =
          advertise_datapath_find(r_ctx_out->announce_routes,
                                  route->datapath);
      if (!ad) {
          continue;
      }

      struct in6_addr prefix;
      unsigned int plen;
      if (!ip46_parse_cidr(route->ip_prefix, &prefix, &plen)) {
          // ... error handling
          continue;
      }

      if (!lport_is_local(r_ctx_in->sbrec_port_binding_by_name,
                          r_ctx_in->chassis,
                          route->logical_port->logical_port)) {
          // Skip routes for ports not on this chassis
          continue;
      }

      // Add route to the advertise_datapath_entry
      struct advertise_route_entry *ar = xmalloc(sizeof(*ar));
      ar->addr = prefix;
      ar->plen = plen;
      ar->priority = priority;
      hmap_insert(&ad->routes, &ar->node,
                  advertise_route_hash(&prefix, plen));
  }

  What happens here:
  - Reads all Advertised_Route entries from the Southbound database
  - These are created by northd when it processes NAT rules with redistribution enabled
  - Filters to only routes whose logical port is bound to this chassis
  - Builds a hash map of routes to be installed in the kernel

  Step 6: Installing Blackhole Routes

  File: controller/route-exchange-netlink.c (lines 98-121)

  static int
  modify_route(uint32_t type, uint32_t flags_arg, uint32_t table_id,
               const struct in6_addr *dst, unsigned int plen,
               unsigned int priority)
  {
      uint32_t flags = NLM_F_REQUEST | NLM_F_ACK;
      bool is_ipv4 = IN6_IS_ADDR_V4MAPPED(dst);
      struct rtmsg *rt;

      flags |= flags_arg;

      struct ofpbuf request;
      // ... buffer initialization

      nl_msg_put_nlmsghdr(&request, 0, type, flags);
      rt = ofpbuf_put_zeros(&request, sizeof *rt);
      rt->rtm_family = is_ipv4 ? AF_INET : AF_INET6;
      rt->rtm_table = RT_TABLE_UNSPEC;
      rt->rtm_protocol = RTPROT_OVN;      // Mark as OVN-managed (proto 84)
      rt->rtm_type = RTN_BLACKHOLE;       // ← BLACKHOLE route type
      rt->rtm_scope = RT_SCOPE_UNIVERSE;

  What happens here:
  - For each advertised route, constructs a netlink RTM_NEWROUTE message
  - Sets route type to RTN_BLACKHOLE - this is the key!
  - Sets protocol to RTPROT_OVN (protocol 84) so they can be identified later
  - Sends to kernel, which installs the route in the specified VRF table

  Step 7: FRR Picks Up the Routes

  Once the blackhole routes are installed in the kernel VRF, FRR's redistribute kernel configuration (in the VRF BGP context) automatically detects them and advertises via BGP.

  Key Timing and Lifecycle

  1. When VRF is created: On first ovn-controller iteration after seeing dynamic-routing-maintain-vrf=true
  2. When routes are installed: Every time ovn-controller runs and processes Advertised_Route entries
  3. Route updates: Synchronized continuously - stale routes are removed, new ones added
  4. VRF cleanup: When dynamic-routing-maintain-vrf is removed or chassis loses binding, VRF is deleted

  Why Blackhole Routes?

  The routes are marked as RTN_BLACKHOLE because:
  - They are markers for FRR to advertise, not for actual packet forwarding
  - OVN handles the actual packet forwarding through OpenFlow rules
  - If a packet somehow reaches the kernel and matches one of these routes, it will be dropped (blackholed)
  - This prevents routing loops and ensures all traffic goes through OVN's datapath

Impressive, right?

Let’s now try to do something with the environment!

3. Modify the environment to advertise internal IPs via BGP

One potential modification to this test is to advertise the internal IP address of the guest VM (192.168.10.10) and ping it from the ToR. Instead of changing the code of the test I’ll modify the live environment to advertise the route to the VM and use Claude to handhold me.

First, verify that the VM is not reachable.

# podman exec ovn-gw-2 ip netns exec frr-ns ping -c 1 192.168.10.10
ping: connect: Network is unreachable

Now, since the ToRs are on different ASNs and are not connected,  we will only be able to access the VM from the ToR where the DGP  is bound. In our environment, the active gateway is on the gw-2 node. On a typical datacenter with a spine-and-leaf topology, the ToRs will be in the same AS and will be connected through the spine so we could reach the VM from anywhere in the network.

> I would like the lr-guest to advertise the route to 192.168.10.10, how can i enable that option?

⏺ To make lr-guest advertise its connected routes, you need to configure dynamic routing on lr-guest itself and on its router ports. Here's how:

  Step 1: Enable dynamic routing on lr-guest

  podman exec ovn-central-az1 ovn-nbctl set logical_router lr-guest \
      options:dynamic-routing=true \
      options:dynamic-routing-vrf-id=100

  Step 2: Configure the router ports to redistribute connected routes

  You need to set dynamic-routing-redistribute on the ports where you want to advertise routes from:

  # Advertise from the port connected to ls-guest-ovn-gw-1
  podman exec ovn-central-az1 ovn-nbctl set logical_router_port lrp-guest-ls-guest-ovn-gw-1 \
      options:dynamic-routing-redistribute=connected

  # Advertise from the port connected to ls-guest-ovn-gw-2
  podman exec ovn-central-az1 ovn-nbctl set logical_router_port lrp-guest-ls-guest-ovn-gw-2 \
      options:dynamic-routing-redistribute=connected

  However, there's a critical limitation here:

  - lr-guest is only instantiated on the chassis where the DGP is active (ovn-gw-2)
  - The VRF (ovnvrf100) will only be created on ovn-gw-2
  - Routes from lr-guest won't propagate to the gateway routers (lr-ovn-gw-1-ext0, lr-ovn-gw-2-ext0) automatically

  To actually make this work end-to-end, you would still need the static routes approach on the gateway routers, because OVN doesn't automatically propagate routes between different logical routers.

  The dynamic-routing-redistribute=connected on lr-guest would be useful if you had FRR running directly in the lr-guest VRF (ovnvrf100), but in this test topology, the BGP peering is happening in the gateway router VRFs (ovnvrf10, ovnvrf20), not in lr-guest's VRF.

  So the answer is: you can enable it, but it won't achieve what you want without also adding the static routes on the gateway routers.

This looks sane but still it does not seem that we’re telling OVN to create the VRF 100 and also FRR won’t be reading any routes from that VRF. Claude has missed that part, let’s talk about it 🙂

> if i understood you correctly earlier, we still need to add the maintain-vrf option to the LRP so that the vrf100 gets created

⏺ You're absolutely right! We need to add the maintain-vrf option to trigger vrf100 creation. Let me provide the complete configuration:

  # 1. Set maintain-vrf=true on the DGP to create vrf100
  # This is the critical step that triggers VRF creation in ovn-controller
  podman exec -it ovn-central-az1 \
    ovn-nbctl set logical_router_port lrp-guest-join-dgp \
    options:dynamic-routing-maintain-vrf=true

  # 2. Add static routes on gateway routers pointing to the DGP
  podman exec ovn-central-az1 ovn-nbctl lr-route-add lr-ovn-gw-2-ext0 \
      192.168.10.0/24 fe80::216:6ff:fe12:f00d lrp-ovn-gw-2-to-join


> FRR on ovn-gw-2 does not know anything about the vrf100. Can you help me adding the config to import this VRF?

⏺ You are right. Here's the configuration to add the import:

  podman exec -i ovn-gw-2 vtysh <<'EOF'
  configure
    router bgp 4210000000 vrf ovnvrf100
      bgp router-id 100.100.100.100
      no bgp ebgp-requires-policy
      address-family ipv4 unicast
        redistribute kernel
      exit-address-family
    exit
    router bgp 4210000000 vrf ovnvrf20
      address-family ipv4 unicast
        import vrf ovnvrf100
      exit-address-family
    exit
    write memory
  EOF

  This will:
  1. Create the BGP instance in ovnvrf100 that redistributes kernel routes (the blackhole route for 192.168.10.0/24)
  2. Add import vrf ovnvrf100 to the existing ovnvrf20 BGP configuration, so routes from vrf100 get leaked into vrf20 and advertised to the ToR


> Can you explain in detail what we have just done to reach 192.168.10.10 from the ToR?


⏺ Let me explain in detail how this works by tracing through the entire flow:

  1. OVN Configuration Creates the Foundation

  You've configured lr-guest with:
  - options:dynamic-routing=true
  - options:dynamic-routing-vrf-id=100
  - lrp-guest-join-dgp has options:dynamic-routing-maintain-vrf=true

  2. VRF Creation in Kernel

  On ovn-gw-2 (where the DGP is bound), ovn-controller sees the dynamic-routing-maintain-vrf=true option and calls re_nl_create_vrf() to create ovnvrf100 in the kernel with routing table ID 100.

  You can verify this:
  ssh ovnlab sudo podman exec ovn-gw-2 ip link show ovnvrf100
  ssh ovnlab sudo podman exec ovn-gw-2 ip route show vrf ovnvrf100

  3. Blackhole Route Installation

  When lr-guest has routes to advertise (like the connected network 192.168.10.0/24), ovn-controller queries the Advertised_Route table in the Southbound DB and installs blackhole routes in vrf100:

  ssh ovnlab sudo podman exec ovn-gw-2 ip route show vrf ovnvrf100 table 100
  # You should see something like:
  # blackhole 192.168.10.0/24 proto 84

  The route is marked as:
  - RTN_BLACKHOLE - doesn't actually route traffic, just a marker
  - RTPROT_OVN (protocol 84) - identifies it as an OVN-managed route

  This happens in route-exchange-netlink.c:98-121.

  4. FRR Sees the Kernel Route in vrf100

  When you configure:
  router bgp 4210000000 vrf ovnvrf100
    address-family ipv4 unicast
      redistribute kernel

  FRR monitors the kernel routing table for vrf100 (table 100) and sees the blackhole route for 192.168.10.0/24. Because of redistribute kernel, FRR adds this route to BGP's Routing Information Base (RIB) for vrf100.

  You can verify:
  ssh ovnlab "sudo podman exec ovn-gw-2 vtysh -c 'show ip bgp vrf ovnvrf100'"

  5. VRF Route Leaking (The Magic Part)

  When you configure in ovnvrf20:
  router bgp 4210000000 vrf ovnvrf20
    address-family ipv4 unicast
      import vrf ovnvrf100

  This tells FRR to import routes from vrf100's BGP RIB into vrf20's BGP RIB. This is called "VRF route leaking" or "route target import."

  Internally, FRR copies the 192.168.10.0/24 route from vrf100's BGP table into vrf20's BGP table.

  You can verify:
  ssh ovnlab "sudo podman exec ovn-gw-2 vtysh -c 'show ip bgp vrf ovnvrf20'"
  # Should now show 192.168.10.0/24 in addition to the NAT routes

  6. BGP Advertisement to ToR

  Once the route is in ovnvrf20's BGP RIB, the existing BGP session advertises it:
  router bgp 4210000000 vrf ovnvrf20
    neighbor ext0-bgp interface remote-as external
    address-family ipv4 unicast
      redistribute kernel
      neighbor ext0-bgp prefix-list no-default out

  The route gets advertised to the ToR peer via the ext0-bgp unnumbered BGP session.


  Key Points

  1. vrf100 has no external BGP peers - it's purely for internal route collection from lr-guest
  2. vrf20 has the actual ToR peering - it's where routes get advertised externally
  3. VRF import bridges the two - routes from vrf100 appear in vrf20's BGP table
  4. Blackhole routes are just markers - they don't route actual traffic, they just signal to FRR "advertise this prefix"
  5. This only works on ovn-gw-2 - because that's where the DGP (lrp-guest-join-dgp) is currently bound

And, of course, we can now ping the VM IP address from the ToR connected to ovn-gw-2:

$ podman exec -it ovn-central-az1 ovn-sbctl list advertised_route | grep 192.168.10 -C3
_uuid               : 1c417fc1-6af6-4945-9aaf-5443237a120a
datapath            : c1a7942f-bf59-4835-8c56-4df45a5c5855
external_ids        : {}
ip_prefix           : "192.168.10.0/24"
logical_port        : 782b2357-2c37-4e6f-bec6-ff204fcb4733
tracked_port        : []

$ podman exec ovn-gw-2 ip netns exec frr-ns ip route
172.16.10.2 nhid 6 via inet6 fe80::20fb:d6ff:fe66:992c dev ext1 proto bgp metric 20
192.168.10.0/24 nhid 6 via inet6 fe80::20fb:d6ff:fe66:992c dev ext1 proto bgp metric 20
192.168.20.0/24 nhid 6 via inet6 fe80::20fb:d6ff:fe66:992c dev ext1 proto bgp metric 20

$ podman exec ovn-gw-2 ip netns exec frr-ns ping -c 2 192.168.10.10
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=1 ttl=62 time=1.48 ms
64 bytes from 192.168.10.10: icmp_seq=2 ttl=62 time=0.575 ms

--- 192.168.10.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.575/1.027/1.479/0.452 ms


Conclusions

This combination of code analysis + live system inspection + domain knowledge made understanding the feature much faster than traditional code reading alone. Even for someone familiar with OVN, having AI as a “knowledgeable assistant” that can quickly locate and explain specific implementation details is awesome! It’s been very handy for:

  • Rapid ramp-up on the new BGP integration feature as a user
  • Tracing execution paths across multiple source files without manually grepping through thousands of lines
  • Understanding the “how” and “why” of implementation details like the VRF creation
  • Connecting the dots between configuration options and actual kernel-level operations

Claude is definitely getting a permanent route in my learning topology. Next hop: more complex features! 😉