Skip to content

route reflection

Thomas Mangin edited this page Nov 9, 2026 · 8 revisions

Pre-Alpha. This page describes behavior that may change.

Ze operates as both a route server (RFC 7947) and an iBGP route reflector (RFC 4456). Route serving is the bgp-rs plugin driven by attach process bindings; it forwards every received route to every other peer with zero-copy wire optimization when peers share an encoding context. iBGP route reflection is a session-level option (session/route-reflector-client plus session/cluster-id) that turns an iBGP peer into a reflector client and applies the RFC 4456 rules (ORIGINATOR_ID, CLUSTER_LIST, client vs non-client forwarding).

This page covers both. Pick the mode that matches the deployment: a route server at an IXP or transit exchange, or a route reflector inside an autonomous system.

iBGP route reflection (RFC 4456)

An iBGP peer is turned into a reflector client by setting session/route-reflector-client true; on it. Ze will then apply the RFC 4456 forwarding rules to routes learned from that peer: routes from a client are forwarded to all other peers (clients and non-clients), routes from a non-client are forwarded to clients only, and the ORIGINATOR_ID plus CLUSTER_LIST attributes are handled automatically.

bgp {
    router-id 10.0.0.254;
    session {
        asn { local 65000; }
        cluster-id 10.0.0.254;          # optional; defaults to router-id
    }

    peer client-a {
        connection { remote { ip 10.0.0.1; } }
        session {
            asn { remote 65000; }        # iBGP: same AS
            route-reflector-client true;
            family { ipv4/unicast { prefix { maximum 1000000; } } }
        }
    }

    peer client-b {
        connection { remote { ip 10.0.0.2; } }
        session {
            asn { remote 65000; }
            route-reflector-client true;
            family { ipv4/unicast { prefix { maximum 1000000; } } }
        }
    }
}

What Ze does on reflected routes

  • ORIGINATOR_ID. Set to the source peer's Router ID if the attribute is absent on ingress. If it is already present (the route has been reflected before), the existing value is preserved.
  • CLUSTER_LIST. Prepended with the local cluster ID (from session/cluster-id, falling back to bgp/router-id). If CLUSTER_LIST is absent on ingress it is created. Existing values are preserved.
  • Link-local next hops. A link-local-only IPv6 next hop is reflected only to a client that shares a connected subnet with the advertiser, or whose next-hop mode rewrites it to Ze's own address. Every other client gets a withdrawal and a warning line. See Link-local next hop.
  • Loop detection. On ingress, if ORIGINATOR_ID matches the local Router ID, or the local cluster ID is in CLUSTER_LIST, the route is treated as a loop and dropped. This is the RFC 4456 Section 8 check and runs as part of the built-in loop-detection filter (see route filters).
  • CLUSTER_LIST cluster-id. If you set session/cluster-id on the peer, the same value is used for egress prepending AND ingress loop detection. Ze keeps the two in sync automatically, so you only need to configure it once.
  • Unresolvable source refused. A forward whose source peer cannot be resolved is refused rather than sent. Every reflection rule above is derived from the source: with a zero-valued source, reflection suppression never fires, ORIGINATOR_ID and CLUSTER_LIST are never injected, and the identifier would be 0.0.0.0, which is never a valid BGP Identifier. Presence in the peer table is not sufficient, because a torn-down-but-present peer has had its router ID cleared. Both forward producers gate on this, including the cached fast path the route server uses.

Client vs non-client

Source peer Destination peer Forwarded?
Client Any iBGP peer (client or non-client) Yes
Non-client Client Yes
Non-client Non-client No (RFC 4456: non-clients rely on the full iBGP mesh to exchange among themselves)
eBGP Any iBGP peer Yes

A peer with route-reflector-client false (the default) is a non-client. Mixing clients and non-clients on the same reflector is the normal setup for a partial-mesh deployment.

Multiple reflectors in a cluster

Set the same cluster-id on every reflector in the cluster. Ze's CLUSTER_LIST prepend uses that value, and the CLUSTER_LIST loop check on ingress uses the same value, so routes bounce between cluster members only when the cluster ID really is different.

The shorter CLUSTER_LIST wins the best path

RFC 4456 Section 9 adds one step to the RFC 4271 tie-break rules: "the following rule SHOULD be inserted between Steps f) and g): a BGP Speaker SHOULD prefer a route with the shorter CLUSTER_LIST length. The CLUSTER_LIST length is zero if a route does not carry the CLUSTER_LIST attribute."

Ze prefers the route with the shorter CLUSTER_LIST. It is step 8 of the selection, between the BGP Identifier comparison and the lowest peer address. A route that carries no CLUSTER_LIST attribute counts as length zero. The count saturates at 16383.

The step is BestStepClusterList in the code, and the comparison reason an operator reads is spelled cluster-list-length 1 vs 2. There is no configuration option. The step is unconditional.

Route server (RFC 7947)

The route server model uses the bgp-rs plugin, bound per peer via process. It forwards every received route to every other peer with no best-path selection, which is what IXP members expect: the server is a transparent bus and the members run their own policy downstream.

plugin {
    internal rs         { use bgp-rs; }
    internal adj-rib-in { use bgp-adj-rib-in; }
}

bgp {
    router-id 10.0.0.254;
    session { asn { local 65000; } }

    peer client-a {
        connection { remote { ip 10.0.0.1; } }
        session {
            asn { remote 65001; }
            family { ipv4/unicast { prefix { maximum 1000000; } } }
        }
        attach process rs {
            receive [ update-received state open-received refresh ];
            send    [ update ];
        }
        attach process adj-rib-in {
            receive [ update-received state ];
        }
    }

    peer client-b {
        connection { remote { ip 10.0.0.2; } }
        session {
            asn { remote 65002; }
            family { ipv4/unicast { prefix { maximum 1000000; } } }
        }
        attach process rs {
            receive [ update-received state open-received refresh ];
            send    [ update ];
        }
        attach process adj-rib-in {
            receive [ update-received state ];
        }
    }
}

Every peer gets both attachments. bgp-rs does the forwarding. bgp-adj-rib-in stores received routes so they can be replayed when a peer reconnects.

The received direction is not a preference. A route server that also receives the UPDATEs Ze sends deadlocks: forwarding one raises the sent event that the forward is waiting on. Write update-received, never update.

The block is authoritative since 2026-08-15, so a peer with no attach process rs is fed nothing and cannot be announced to. See Attached programs.

A route server without per-peer entries

An IXP route server can take its members from a dynamic peer group instead of a peer block for each one. The group opens its own listening socket, so a configuration that names no static peer still accepts members, and a member inherits the group's attach process blocks, its families, its filter chains and its per-peer plugin configuration.

bgp {
    group ix {
        connection {
            remote { ip dynamic; connect false; range 198.51.100.0/24; max-peers 500; }
            local  { ip 198.51.100.1; accept true; }
        }
        session {
            asn { local 64500; }
            router-id 198.51.100.1;
            family { ipv4/unicast { prefix { maximum 200000; } } }
        }
        role { import rs; }

        attach process rs {
            receive [ update-received state open-received refresh ];
            send    [ update ];
        }
        attach process adj-rib-in {
            receive [ update-received state ];
        }
    }
}

A static peer whose address falls inside the range keeps its own session and its own settings.

Forwarding and destination election

Receive validation and each destination's export policy apply before a route can reach a client. ADD-PATH destinations retain distinct paths, so every downstream makes its own best-path decision. At a destination without ADD-PATH only one path per prefix can be held, and with bgp-rib loaded that path is the one the bgp-rib election picks: the first route of a prefix is written as it arrives, and when another source announces a prefix the destination already holds, the election decides rather than the newest arrival.

The destination session's final writer remembers, for each route and outgoing ADD-PATH identifier, the source peer and received path that last advertised it. A received withdrawal removes only that owner's route; a withdrawal from another source cannot erase a replacement or a locally originated route. When the owner withdraws, a destination without ADD-PATH receives the best remaining route from another source, or the withdrawal when none remains: when B announces a prefix, then A announces it, then A withdraws it, the client keeps B's route. Without bgp-rib the withdrawal is sent as before and a warning names the missing plugin. A policy-generated withdrawal is sent only to a client that was advertised the route (RFC 4271 Section 3.1).

A source that leaves is reconciled through the same election, for the route server and the reflector alike: a client holding the departed source's route gets the best remaining one, or the withdrawal; a client holding another source's route is sent nothing. Toward an ADD-PATH destination the departure withdraws only the departed source's identifiers, under the identifier Ze sent (RFC 7911 Section 2). A labeled or VPN route that carried several labels is withdrawn with the single Compatibility field 0x800000 (RFC 8277 Section 2.4). If the RIB cannot establish truthful sent ownership, the affected destination session is reset rather than left with routes that should have been withdrawn.

When bgp-gr retains a departed source's family, both the route server and the reflector leave that family's routes in place through the restart (RFC 4724 Section 4.2), until bgp-rib purges them at Restart Time expiry, End-of-RIB or release-routes. See Graceful restart.

The combination of the route server model and ADD-PATH is what lets every downstream make its own best-path decision. Without ADD-PATH you can only forward one path per prefix to each client; with ADD-PATH every path is available. See ADD-PATH.

Zero-copy forwarding

When two peers negotiate identical capabilities (same ADD-PATH mode, same ASN format, same extended-message support), they share the same encoding context, identified by a ContextID. Routes between peers with matching contexts are forwarded as raw wire bytes: no parse, no rebuild, no allocation. The reactor looks up the cached message, confirms the contexts match, and ships the bytes straight back out.

This is the fast path and the reason a route server with many identically-configured clients runs well on Ze. When contexts differ (for example, one peer without ADD-PATH forwarding to one with ADD-PATH), a progressive build walks the cached attributes and re-encodes for the destination.

For a session configured as a route-server client, received optional attributes are retained for transparent redistribution, unknown transitive and unknown non-transitive ones included, and the route server adds no Partial bit on client redistribution. Ordinary sessions still mark unknown transitive attributes Partial and discard unknown non-transitive ones; forwarding from a client to an ordinary peer applies those rules to a separate outgoing copy, never to the bytes shared with other clients.

Forwarding workers and congestion

Each destination peer has its own long-lived forwarding worker goroutine with a buffered channel. When a destination peer is slower than the update rate, the channel absorbs short bursts (default capacity 4096 items). If the channel fills, items go into a per-worker overflow buffer, and the worker fires a congestion event visible in logs and Prometheus.

The overflow uses a two-tier pool. Per-peer pools (64 slots) absorb steady-state traffic. A shared MixedBufMux pool, auto-sized from peer prefix maximums or overridable via ze.fwd.pool.size, bounds overflow memory across every peer. Routes are never dropped: missing a route update is worse than using extra memory. When a peer catches up and the channel drains below 25 %, congestion clears.

The Prometheus metrics that show this behaviour:

Metric Meaning
ze_bgp_pool_used_ratio Global overflow pool utilisation.
ze_bgp_overflow_items{peer} Items in a per-destination overflow buffer.
ze_bgp_overflow_ratio{source} Per-source overflow ratio.

If ze_bgp_pool_used_ratio is above 0.8 in steady state, you are close to congestion teardown and should investigate which peer is lagging.

Convergent replay

When a peer reconnects, the route server replays every stored route from the other peers. The replay is three phases:

  1. Full snapshot replay from the Adj-RIB-In.
  2. Delta loop that catches routes received during the replay.
  3. End-of-RIB sent when the replay has caught up.

A batch of bug fixes in 2026 closed three latent bugs in this path (wrong-direction dispatch for sent events, nil WireUpdate on reflected UPDATEs, and wrong format when the cached route came from the text codec). The event delivery on replay is now event-driven rather than a fixed sleep, and graceful restart, LLGR, and refresh-on-reconnect tests that had flaky timeouts all pass reliably.

The plugin bindings in detail

bgp-rs plugin. Needs receive [ update-received state open-received refresh ] (the UPDATEs the peer sends, its session state, the capabilities in its OPEN, and route refresh) and send [ update ] (so it can forward routes back out). Every peer that participates in the route server must have these bindings.

bgp-adj-rib-in plugin. Stores received routes for replay on peer reconnect. Needs receive [ update-received state ]. If you do not bind it, reconnecting peers will not get a replay and convergence will be slower.

rs-fast-path grants

behavior { rs-fast-path enable; } forwards in place of bgp-rs, so it obeys the permissions bgp-rs would. It relays an UPDATE only from a source peer that grants bgp-rs receive [ update-received ] (or update, or *), and only to a destination peer that grants bgp-rs send [ update ]. A destination without the send grant is handed back to bgp-rs, whose forward is refused and logged as send refused. When a peer with rs-fast-path lacks either grant, Ze logs one warning as its session comes up naming the missing grant. Fix it with attach process <rs-name> { receive [ update-received ]; send [ update ]; }.

bgp-adj-rib-in needs only receive [ update-received state ] here: when a peer comes up, the route server or reflector reads the stored routes and sends them itself under its own send [ update ] grant. An up whose reason is attached (a reload that attached bgp-adj-rib-in to a session already up) replays nothing.

Removing a client's last import policy

When a commit removes the last accepting import policy of an established EBGP peer, RFC 8212 Section 3 makes that peer's routes ineligible. Ze keeps the session up and invalidates the routes in place under a prepare, apply, abort and finalize transaction: the copies the reflector sent to its clients are withdrawn by bgp-rib on apply and re-announced on abort. A phase whose work does not finish before the transaction's deadline fails, naming the peer, and the transaction rolls back.

Cache commands

Routes in transit are exposed through the cache surface.

Command Description
show cache List cached messages.
request cache retain <id> Prevent cache eviction.
request cache release <id> Release a cached message.
request cache expire <id> Remove a cached message immediately.
request cache forward <id> <peer> Forward a cached message to a peer.

Use these when you want to inspect or reroute a specific cached message. They are more of a debugging surface than a day-2 operator tool, but they are the mechanism that lets a plugin take control of forwarding decisions for a specific UPDATE.

request cache forward is gated by the destination peer's send list, like every other rail that reaches a peer's socket. An operator command is not gated: AAA checks the operator before dispatch.

Without bgp-rs

When bgp-rs is not loaded, routes are not forwarded between peers. The bgp-rib plugin (if loaded) stores routes and runs best-path selection, but it does not re-advertise them. Ze becomes a passive route collector in that mode. Load bgp-rs when you want forwarding.

Route reflection vs route server

Aspect Route reflector (RFC 4456) Route server (RFC 7947)
Intended topology iBGP inside an AS eBGP between members at an IXP
Best-path selection Yes, then forward best path per prefix (or all paths with ADD-PATH) No, forward every path
Modifies NEXT_HOP By default yes on eBGP → iBGP borders (routable inside AS) No, forward unchanged (RFC 7947)
Adds ORIGINATOR_ID / CLUSTER_LIST Yes No
Config knob session/route-reflector-client, session/cluster-id attach process bindings for bgp-rs and bgp-adj-rib-in
Plugin Built-in reactor logic bgp-rs plugin

Pick based on intent: if you want to distribute routes inside an AS without a full iBGP mesh, it is a route reflector. If you want a transparent route exchange where members build their own RIBs from every available path, it is a route server.

See also

Adapted from main/docs/guide/route-reflection.md.

Home

About

First Steps

Configuration

Operation

Interfaces

Plugins

Plugin Development

Chaos Testing

Blueprints

Development

Reference

Clone this wiki locally