IOS-XR Segment Routing: SR-MPLS with OSPF Prefix-SID - 夜莺博客

IOS-XR Segment Routing: SR-MPLS with OSPF Prefix-SID

Segment routing removes LDP from the path by having the IGP itself carry the label information: each router assigns a prefix-SID to the prefixes it originates, and every other router computes the incoming label from a globally consistent block called the SRGB. On Cisco IOS-XR the configuration is remarkably small, but the pieces must line up — the same SRGB on every router, SIDs inside that block, and segment routing enabled both globally and per interface. This guide covers the SR-MPLS build with OSPF, and the verification chain from SRGB to LFIB that tells you exactly where it breaks when labels do not appear.

SRGB and Prefix-SIDs Explained

The Segment Routing Global Block is a reserved label range, typically 16000-23999, from which prefix-SIDs are allocated. A prefix-SID is expressed as an index, and the actual label is the SRGB base plus that index. Because the index is carried by the IGP and the base is local, every router must have the same SRGB or the same index on two routers will produce different labels — and traffic will be dropped or misforwarded.

The standard allocations are:

  • Prefix-SID index 0-15999 as absolute values mapped above the base, or a numeric index that resolves to SRGB base + index.
  • Explicit-null is used for PHP (penultimate hop popping) behaviour, so the destination router advertises label 0 for its own prefix.

Step 1 - Enable Segment Routing Globally

RP/0/RSP0/CPU0:PE1# configure
RP/0/RSP0/CPU0:PE1(config)# segment-routing mpls
RP/0/RSP0/CPU0:PE1(config-sr-mpls)# set-attributes
RP/0/RSP0/CPU0:PE1(config-sr-mpls-attr)# address-family ipv4
RP/0/RSP0/CPU0:PE1(config-sr-mpls-attr-af)# srgb 16000 23999
RP/0/RSP0/CPU0:PE1(config-sr-mpls-attr-af)# commit

Apply the identical SRGB on every router in the SR domain. If you inherit an existing SRGB, verify it before rolling out SIDs rather than assuming the default.

Step 2 - Enable SR on OSPF Interfaces

Enabling segment routing under the IGP and under each interface is what actually puts labels on the wire:

RP/0/RSP0/CPU0:PE1(config)# router ospf 1
RP/0/RSP0/CPU0:PE1(config-ospf)# segment-routing mpls
RP/0/RSP0/CPU0:PE1(config-ospf)# area 0
RP/0/RSP0/CPU0:PE1(config-ospf-ar)# interface GigabitEthernet0/0/0/1
RP/0/RSP0/CPU0:PE1(config-ospf-ar-if)# segment-routing mpls
RP/0/RSP0/CPU0:PE1(config-ospf-ar-if)# commit

Both levels are required: the global IGP statement turns SR on for the process, and the interface statement enables it per link. Applying it to a subset of interfaces is a legitimate design choice — SR is only used on links where it is enabled.

Step 3 - Assign Prefix-SIDs

Assign a prefix-SID to every loopback that must be reachable as an SR node. Indexes must be unique in the domain and fit inside the SRGB:

RP/0/RSP0/CPU0:PE1(config)# router ospf 1
RP/0/RSP0/CPU0:PE1(config-ospf)# area 0
RP/0/RSP0/CPU0:PE1(config-ospf-ar)# interface Loopback0
RP/0/RSP0/CPU0:PE1(config-ospf-ar-if)# prefix-sid index 1
RP/0/RSP0/CPU0:PE1(config-ospf-ar-if)# commit

For interoperability with devices that cannot carry the index, the absolute variant is available and sets the label directly:

RP/0/RSP0/CPU0:PE1(config-ospf-ar-if)# prefix-sid absolute 16001

Index versus absolute prefix-SIDs

Do not mix index and absolute values across the domain for the same prefix. Absolute labels from a router with a different SRGB base will point at the wrong node — the failure looks like traffic reaching an unintended router, which is far harder to debug than a simple drop.

Step 4 - Adjacency SIDs and TI-LFA

Adjacency SIDs are allocated automatically for each SR-enabled interface and are the building blocks of TI-LFA protection. You normally do not configure them by hand, but you should verify they exist, because a missing adjacency SID means fast reroute cannot protect the link:

RP/0/RSP0/CPU0:PE1# show ospf interface GigabitEthernet0/0/0/1 detail
RP/0/RSP0/CPU0:PE1# show isis or ospf segment-routing

Verification Chain

Verify in strict order, because each step depends on the previous one:

RP/0/RSP0/CPU0:PE1# show segment-routing mpls srgb
RP/0/RSP0/CPU0:PE1# show ospf segment-routing prefix-sid-map
RP/0/RSP0/CPU0:PE1# show ospf route 10.0.0.2/32
RP/0/RSP0/CPU0:PE1# show ospf database opaque-area
RP/0/RSP0/CPU0:PE1# show mpls forwarding
RP/0/RSP0/CPU0:PE1# show mpls forwarding labels 16002
RP/0/RSP0/CPU0:PE1# show mpls lfib cef 10.0.0.2/32

Start at the SRGB and confirm it matches every other router. Then confirm the SID mapping is advertised and received — show ospf route 10.0.0.2/32 detail shows the prefix-SID attached to the route. If the route has no SID, the originator has not configured one. If the SID is present on the route but no labelled entry appears in show mpls forwarding, segment routing is not enabled on the outgoing interface.

Inspecting the label stack and backup path

For a specific destination, show mpls lfib cef shows the exact label stack that will be imposed, including any backup TI-LFA path. That single output answers both "is SR working" and "is protection installed".

Operational Notes

  • Keep one SRGB across the entire SR domain and document it — mismatched bases cause silent misforwarding.
  • Assign index-based prefix-SIDs to loopbacks and keep a written index map; duplicates are the second most common error.
  • Enabling SR requires both the IGP-level and interface-level statements.
  • SR-MPLS does not remove the need for an IGP — the IGP still computes the shortest path that the SID list encodes.
  • Verify adjacency SIDs before relying on TI-LFA, otherwise you have a protection plan that cannot be installed.

Related reading: our SR-MPLS versus SRv6 explained guide, the TI-LFA segment routing fast reroute configuration article, and the IOS-XR RPL route policy and prefix-set guide.

原文链接:https://www.cisco.com/c/en/us/td/docs/routers/asr9000/software/26xx/segment-routing/configuration/guide/b-segment-routing-cg-asr9000-26xx/configure-sr-for-ospf-protocol.html