IOS XR BGP maximum-prefix and discard-extra-paths - 夜莺博客

IOS XR BGP maximum-prefix and discard-extra-paths

A single leaky BGP session can push hundreds of thousands of prefixes into a router and consume the memory that the rest of the control plane needs. IOS XR solves this with maximum-prefix, which caps how many prefixes a neighbor may send per address family and tears the session down when the limit is crossed. This article covers the default limits, the warning threshold, automatic restart behaviour, and the newer discard-extra-paths option that drops excess prefixes without flapping the session - the difference between a contained incident and a second outage caused by the mitigation itself.

What happens when the limit is exceeded

When the received prefix count goes above the configured maximum, the router sends a CEASE notification to the neighbor and terminates the session. The session stays down until an operator clears it with clear bgp - unless the restart keyword was configured, in which case BGP brings the neighbor back automatically after the specified interval. A warning is logged once the count crosses the threshold (75% by default). Lowering the limit below what the neighbor has already advertised terminates the session immediately, so change these values during a window.

Default peer and prefix limits

IOS XR applies platform defaults per address family (IPv4 unicast 1,048,576 prefixes, IPv6 unicast 524,288, VPNv4 and EVPN 2,097,152, labelled-unicast 131,072, and so on), and a default of 4000 neighbours that can be raised to 15000 with bgp maximum neighbor. From IOS XR 7.3.1 the platform no longer imposes per-AF default maximum-prefix values unless you configure them, which makes explicit configuration - not vendor defaults - the documented best practice.

Configuration

RP/0/RP0/CPU0:router# configure
RP/0/RP0/CPU0:router(config)# router bgp 65000
RP/0/RP0/CPU0:router(config-bgp)# neighbor 10.0.0.1
RP/0/RP0/CPU0:router(config-bgp-nbr)# address-family ipv4 unicast
RP/0/RP0/CPU0:router(config-bgp-nbr-af)# maximum-prefix 1000 80 restart 30 discard-extra-paths
RP/0/RP0/CPU0:router(config-bgp-nbr-af)# commit

The three parameters read as: hard limit of 1000 prefixes, warn at 80%, and if the limit is still exceeded after 30 minutes, and discard-extra-paths drops the overflow instead of flapping the session.

Why discard-extra-paths changes the failure mode

Without it, a leaky peer is punished by a session reset - which hides the problem from your own routing table but breaks every legitimate prefix from that peer at the same time. With it, BGP keeps the session up, drops only the prefixes above the ceiling, and holds memory flat. The line to watch in verification output is explicit:

Router# show bgp neighbor 10.0.0.1
BGP neighbor is 10.0.0.1
  Maximum prefixes allowed 1000 (discard-extra-paths)
  Threshold for warning message 80%

Router# show bgp ipv4 unicast summary
Router# show route bgp | count

If the discard-extra-paths configuration is later removed, IOS XR sends a route-refresh to the neighbor when it supports the capability and otherwise flaps the session - another reason to schedule that change.

Deployment guidance

  • Set limits from observed baseline plus headroom (typically 20-30%), not from the platform maximum.
  • Apply them on every EBGP edge session, including customer and IX peers; the peer that leaks is rarely the one you distrust.
  • Pair maximum-prefix with RPKI origin validation and prefix filters - limits contain the blast radius, filters prevent it.
  • Alert on the warning threshold crossing: a sustained 80% is a leading indicator, not a rounding error.
  • Document the restart interval; an automatic session recovery that surprises the NOC is worse than a manual clear.

Related: BGP add-path advertisement configuration, RPKI route origin validation, and BGP session stuck in Idle or Active.

原文链接:https://www.cisco.com/c/en/us/td/docs/iosxr/cisco8000/bgp/bgp-config-cisco8000/r-wrapper-bgp-prefix-management-and-session-parameters/bgp-maximum-prefix-and-discard-extra-paths.html