Segment Routing – IS-IS Flexible Algorithm (Flex-Algo)

IS-IS Flexible Algorithm (Flex-Algo)

In the MPLS-SR lab and the follow-up on Fast Reroute and TI-LFA, every prefix-SID followed the same path: the IGP shortest path. That’s fine until the business asks for something like this:

  • “Voice and trading traffic must take the lowest-latency path, not the cheapest one.”
  • “Customer X may never cross the leased line we rent from a third party.”

The classic answers are RSVP-TE tunnels or SR-TE policies with explicit paths, or a PCE that computes them. Both work, but both add state, operations, and a dependency. Flexible Algorithm solves a large part of this inside the IGP itself. Each router computes extra SPF trees with different constraints, and each tree gets its own prefix-SID. The ingress router chooses a plane just by choosing a label. There are no tunnels, no head-end state, and no controller.

In this post I build a small IS-IS Flex-Algo lab in CML with three planes over the same physical topology.


What is Flex-Algo?

Normal SPF (Algorithm 0) asks one question: what’s the lowest IGP metric path?

Flex-Algo (RFC 9350) lets you define a new algorithm (number 128–255) with three components:

ComponentOptionsExample
Metric typeIGP metric, min. unidirectional link delay, TE metricmetric-type delay
Calculation typeSPF(always SPF today)
Constraintsinclude-any / include-all / exclude-any affinities, SRLG excludeaffinity exclude-any RED

This combination is the Flex-Algo Definition (FAD). Every router that participates in algorithm 128 runs an extra SPF on the topology, after pruning links that violate the constraints, using the selected metric. It then installs a forwarding entry for every algorithm-128 prefix-SID.

The result is that 16006 (algo 0) and 16106 (algo 128) both lead to PE6’s loopback, but they follow different paths, hop by hop, with no state on the head-end.

Algorithm 1 is Strict SPF, not Flex-Algo. It’s the “don’t let any local policy override my SPF path” algorithm.


How it is encoded in IS-IS

This is the part that helps when you troubleshoot with show isis database verbose:

WhatWhere in IS-IS
“I participate in algos 0, 1, 128, 129”SR-Algorithm sub-TLV (19) inside the Router Capability TLV (242)
The definition itself (FAD)FAD sub-TLV (26) inside TLV 242, sent only by routers configured with advertise-definition
Per-algorithm prefix-SIDPrefix-SID sub-TLV (3) with the Algorithm field set to 128/129
Link delayMin. unidirectional link delay (RFC 8570), carried in ASLA sub-TLVs (RFC 8919) with the Flex-Algo application bit
Link affinityExtended Admin Group in ASLA

FAD election: you don’t need to configure the definition everywhere. Routers pick the advertised FAD with the highest priority, then the highest system-ID as a tie-breaker. In this lab, P1 (priority 200) and P2 (priority 150) both advertise the definition, and P2 is the backup if P1 goes away. All other routers only participate.


Lab setup

Logical View: six routers in one IS-IS Level-2 domain (CORE). The link costs are chosen on purpose so that each algorithm picks a different path from PE5 to PE6:

Topology

  • P1–P4 is cheap (metric 5) but slow (10 ms), and it’s a rented third-party line, so it gets affinity RED.
  • P1–P2 is cheap (metric 10) but long-haul (15 ms).
  • P3–P4 is expensive (metric 30) but fast (2 ms).
DevicePlatformLoopback0Algo 0 SIDAlgo 128 SIDAlgo 129 SIDRole
P1IOS-XRv 90001.1.1.1/32160011610116201P, FAD owner (prio 200)
P2IOS-XRv 90002.2.2.2/32160021610216202P, FAD backup (prio 150)
P3IOS-XRv 90003.3.3.3/32160031610316203P
P4IOS-XRv 90004.4.4.4/32160041610416204P
PE5IOS-XRv 90005.5.5.5/32160051610516205PE (ingress)
PE6IOS-XRv 90006.6.6.6/32160061610616206PE (egress)

Link addressing follows my usual scheme: 10.<lowest ID>.<highest ID>.<router ID>/24.

Three planes

PlaneDefinitionExpected path PE5 → PE6Cost
Algo 0IGP metricPE5 → P1 → P4 → PE6metric 25
Algo 128metric-type delayPE5 → P3 → P4 → PE64 ms
Algo 129IGP metric, exclude-any REDPE5 → P1 → P2 → PE6metric 30


Router configurations

IOS-XR – P1 (Flex-Algo definition owner)

# ============= Affinity + Flex-Algo definitions
router isis CORE
 is-type level-2-only
 net 49.0001.0000.0000.0001.00
 affinity-map RED bit-position 1
 !
 flex-algo 128
  metric-type delay
  advertise-definition
  priority 200
 !
 flex-algo 129
  affinity exclude-any RED
  advertise-definition
  priority 200
 !
 address-family ipv4 unicast
  metric-style wide
  segment-routing mpls
 !
# ============= One prefix-SID per algorithm
 interface Loopback0
  passive
  address-family ipv4 unicast
   prefix-sid index 1
   prefix-sid algorithm 128 index 101
   prefix-sid algorithm 129 index 201
  !
 !
# ============= Colour the third-party link RED
 interface GigabitEthernet0/0/0/3
  point-to-point
  affinity flex-algo RED
  address-family ipv4 unicast
   metric 5
   fast-reroute per-prefix
   fast-reroute per-prefix ti-lfa
  !
 !
 interface GigabitEthernet0/0/0/1
  point-to-point
  address-family ipv4 unicast
   metric 10
   fast-reroute per-prefix
   fast-reroute per-prefix ti-lfa
  !
 !
 (Gi0/0/0/0 and Gi0/0/0/2 omitted for brevity – identical, metric 10)
!
# ============= Link delay (static values -> deterministic lab)
performance-measurement
 interface GigabitEthernet0/0/0/1
  delay-measurement
   advertise-delay 15000
  !
 !
 interface GigabitEthernet0/0/0/3
  delay-measurement
   advertise-delay 10000
  !
 !
 (other interfaces: advertise-delay 1000)
!
segment-routing
 global-block 16000 23999

IOS-XR – PE5 (participant)

PE5 doesn’t advertise a definition. It only needs to participate in the algorithms and advertise its own per-algo SIDs:

router isis CORE
 is-type level-2-only
 net 49.0001.0000.0000.0005.00
 affinity-map RED bit-position 1
 !
 flex-algo 128
 !
 flex-algo 129
 !
 address-family ipv4 unicast
  metric-style wide
  segment-routing mpls
 !
 interface Loopback0
  passive
  address-family ipv4 unicast
   prefix-sid index 5
   prefix-sid algorithm 128 index 105
   prefix-sid algorithm 129 index 205
  !
 !
 interface GigabitEthernet0/0/0/0
  point-to-point
  address-family ipv4 unicast
   metric 10
   fast-reroute per-prefix
   fast-reroute per-prefix ti-lfa
  !
 !
 interface GigabitEthernet0/0/0/1
  point-to-point
  address-family ipv4 unicast
   metric 10
   fast-reroute per-prefix
   fast-reroute per-prefix ti-lfa
  !
 !
!
performance-measurement
 interface GigabitEthernet0/0/0/0
  delay-measurement
   advertise-delay 1000
 !
 interface GigabitEthernet0/0/0/1
  delay-measurement
   advertise-delay 1000

Why static delay? In production you’d let Performance Measurement probe the links dynamically (TWAMP-light based) and advertise the measured minimum delay. In a virtual lab the measured values mostly show hypervisor scheduling noise, so advertise-delay <usec> gives repeatable results. The flex-algo logic doesn’t care where the number came from.


Verification

1. Which FAD won?

On PE5, a participant without its own definition:

RP/0/RP0/CPU0:PE5#show isis flex-algo 128

IS-IS CORE Flex-Algo Database

Flex-Algo 128:

Level-2:
  Definition Priority: 200
  Definition Source: P1.00
  Definition Equal to Local: No
  Definition Metric Type: Delay
  Definition Flex-Algo Prefix Metric: No
  Exclude Any Bit(s):
  Include Any Bit(s):
  Include All Bit(s):
  Disabled: No
  Microloop Avoidance Timer Running: No
  Data Plane Segment Routing: Yes
  Data Plane IP: No

Local Priority: 128
FRR Disabled: No
Microloop Avoidance Disabled: No
RP/0/RP0/CPU0:PE5#show isis flex-algo 129

IS-IS CORE Flex-Algo Database

Flex-Algo 129:

Level-2:
  Definition Priority: 200
  Definition Source: P1.00
  Definition Equal to Local: No
  Definition Metric Type: IGP
  Definition Flex-Algo Prefix Metric: No
  Exclude Any Bit(s): 1
  Include Any Bit(s):
  Include All Bit(s):
  Disabled: No
  Microloop Avoidance Timer Running: No
  Data Plane Segment Routing: Yes
  Data Plane IP: No

Local Priority: 128
FRR Disabled: No
Microloop Avoidance Disabled: No

PE5 has no definition of its own (Definition Equal to Local: No), but it learned P1’s definition (priority 200) and participates (Disabled: No). For algo 129, the RED affinity shows up as bit 1.

FAD failover test: remove advertise-definition from P1. P2 (priority 150) takes over:

RP/0/RP0/CPU0:P1(config)#router isis CORE flex-algo 128 no advertise-definition
RP/0/RP0/CPU0:P1(config)#commit

RP/0/RP0/CPU0:PE5#show isis flex-algo 128 | include "Priority|Source"
  Definition Priority: 150
  Definition Source: P2.00
Local Priority: 128

2. What is in the LSP?

RP/0/RP0/CPU0:PE5#show isis database verbose P1.00-00

IS-IS CORE (Level-2) Link State Database
LSPID                 LSP Seq Num  LSP Checksum  LSP Holdtime/Rcvd  ATT/P/OL
P1.00-00              0x0000002b   0x7c41        1104 /1200         0/0/0
  Area Address:   49.0001
  NLPID:          0xcc
  IP Address:     1.1.1.1
  Hostname:       P1
  Router Cap:     1.1.1.1 D:0 S:0
    Segment Routing: I:1 V:0, SRGB Base: 16000 Range: 8000
    SR Local Block: Base: 15000 Range: 1000
    SR Algorithm:
      Algorithm: 0
      Algorithm: 1
      Algorithm: 128
      Algorithm: 129
    Node Maximum SID Depth:
      Label Imposition: 10
    Flex-Algo Definition:
      Algorithm: 128 Metric-Type: 1 Alg-type: 0 Priority: 200
    Flex-Algo Definition:
      Algorithm: 129 Metric-Type: 0 Alg-type: 0 Priority: 200
      Flex-Algo Exclude-Any Ext Admin Group:
        0x00000002
  ...
  Metric: 5          IS-Extended P4.00
    Interface IP Address: 10.1.4.1
    Neighbor IP Address: 10.1.4.4
    Application Specific Link Attributes:
      L flag: 0, SA-Length: 1, UDA-Length: 0
        Standard Applications: FLEX-ALGO
        Ext Admin Group:
          0x00000002
        Link Min/Max Delay: 10000/10000 us
    ADJ-SID: F:0 B:0 V:1 L:1 S:0 P:0 weight:0 Adjacency-sid:24005
  Metric: 10         IS-Extended P2.00
    Interface IP Address: 10.1.2.1
    Neighbor IP Address: 10.1.2.2
    Application Specific Link Attributes:
      L flag: 0, SA-Length: 1, UDA-Length: 0
        Standard Applications: FLEX-ALGO
        Link Min/Max Delay: 15000/15000 us
    ADJ-SID: F:0 B:0 V:1 L:1 S:0 P:0 weight:0 Adjacency-sid:24001
  ...
  Metric: 0          IP-Extended 1.1.1.1/32
    Prefix-SID Index: 1, Algorithm: 0, R:0 N:1 P:0 E:0 V:0 L:0
    Prefix-SID Index: 101, Algorithm: 128, R:0 N:1 P:0 E:0 V:0 L:0
    Prefix-SID Index: 201, Algorithm: 129, R:0 N:1 P:0 E:0 V:0 L:0
    Prefix Attribute Flags: X:0 R:0 N:1 E:0 A:0

Everything from the encoding table earlier in this post shows up here:

  • SR Algorithm lists the algorithms P1 participates in. Algorithm 1 (Strict SPF) is always there by default.
  • Flex-Algo Definition carries Metric-Type: 1 (min. delay) for 128 and Metric-Type: 0 (IGP) for 129. The exclude-any admin group is 0x00000002, which is bit position 1 = RED.
  • ASLA on the P1–P4 link carries both the RED admin group and the 10 ms delay, flagged for the FLEX-ALGO application.
  • Three prefix-SIDs on the same loopback, each with its own Algorithm field.

3. Three labels, three next-hops on the ingress

RP/0/RP0/CPU0:PE5#show mpls forwarding labels 16006
Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes
Label  Label       or ID              Interface                    Switched
------ ----------- ------------------ ------------ --------------- ------------
16006  16006       SR Pfx (idx 6)     Gi0/0/0/0    10.1.5.1        0
       16006       SR Pfx (idx 6)     Gi0/0/0/1    10.3.5.3        0            (!)

RP/0/RP0/CPU0:PE5#show mpls forwarding labels 16106
Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes
Label  Label       or ID              Interface                    Switched
------ ----------- ------------------ ------------ --------------- ------------
16106  16106       SR Pfx (idx 106)   Gi0/0/0/1    10.3.5.3        0
       16106       SR Pfx (idx 106)   Gi0/0/0/0    10.1.5.1        0            (!)

RP/0/RP0/CPU0:PE5#show mpls forwarding labels 16206
Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes
Label  Label       or ID              Interface                    Switched
------ ----------- ------------------ ------------ --------------- ------------
16206  16206       SR Pfx (idx 206)   Gi0/0/0/0    10.1.5.1        0
       16206       SR Pfx (idx 206)   Gi0/0/0/1    10.3.5.3        0            (!)

LabelPrimaryBackup (!)
16006 (algo 0)Gi0/0/0/0 → P1Gi0/0/0/1 → P3
16106 (algo 128)Gi0/0/0/1 → P3Gi0/0/0/0 → P1
16206 (algo 129)Gi0/0/0/0 → P1Gi0/0/0/1 → P3

Same destination (PE6), three different trees. On PE5 all three backups are plain LFAs: the neighbour’s own path in that algorithm doesn’t loop back through PE5.

4. The interesting part happens on P1

16006 and 16206 both leave PE5 towards P1, so the split happens one hop further:

RP/0/RP0/CPU0:P1#show mpls forwarding labels 16006
Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes
Label  Label       or ID              Interface                    Switched
------ ----------- ------------------ ------------ --------------- ------------
16006  16006       SR Pfx (idx 6)     Gi0/0/0/3    10.1.4.4        0
       16006       SR Pfx (idx 6)     Gi0/0/0/1    10.1.2.2        0            (!)

RP/0/RP0/CPU0:P1#show mpls forwarding labels 16206
Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes
Label  Label       or ID              Interface                    Switched
------ ----------- ------------------ ------------ --------------- ------------
16206  16206       SR Pfx (idx 206)   Gi0/0/0/1    10.1.2.2        0
       16206       SR Pfx (idx 206)   Gi0/0/0/2    10.1.3.3        0            (!)

Algo 0 takes the cheap RED link to P4 (Gi0/0/0/3).

Algo 129 never touches it and goes to P2. This is the key insight: the path is enforced hop by hop by every router’s own algo-129 SPF, not by a label stack the head-end imposed.

5. TI-LFA inside the plane

The backup for 16206 on P1 is where Flex-Algo really shows its value. If P1–P2 fails, the best algo-0 detour would be the RED link (P1 → P4 → PE6, cost 15).

Algo 129 is not allowed to use it, so the repair path must go P1 → P3 → P4 → PE6. P3 isn’t a plain LFA here: in algo 129, P3 has two equal-cost paths to P4 (direct, cost 30, and P3 → P1 → P2 → P4, also 30), and the second one loops back through P1. TI-LFA fixes that with an extra segment, P3’s adjacency-SID towards P4:

RP/0/RP0/CPU0:P1#show mpls forwarding labels 16206 detail
Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes
Label  Label       or ID              Interface                    Switched
------ ----------- ------------------ ------------ --------------- ------------
16206  16206       SR Pfx (idx 206)   Gi0/0/0/1    10.1.2.2        0
     Updated: Nov 26 10:12:31.587
     Path Flags: 0x400 [  BKUP-IDX:1 ]
     Version: 214, Priority: 1
     Label Stack (Top -> Bottom): { 16206 }
     NHID: 0x0, Encap-ID: N/A, Path idx: 0, Backup path idx: 1, Weight: 0
     MAC/Encaps: 14/18, MTU: 1500
     Outgoing Interface: GigabitEthernet0/0/0/1
     Packets Switched: 0

       16206       SR Pfx (idx 206)   Gi0/0/0/2    10.1.3.3        0            (!)
     Updated: Nov 26 10:12:31.587
     Path Flags: 0x100 [  IDX:1 BKUP, NoFwd ]
     Version: 214, Priority: 1
     Label Stack (Top -> Bottom): { 24003 16206 }
     NHID: 0x0, Encap-ID: N/A, Path idx: 1, Backup path idx: 0, Weight: 0
     MAC/Encaps: 14/22, MTU: 1500
     Outgoing Interface: GigabitEthernet0/0/0/2
     Packets Switched: 0

The backup pushes { 24003 16206 }. P3 pops 24003, its adjacency-SID for the P3–P4 link, and forwards straight to P4. P4 then follows the algo-129 tree for 16206 to PE6. The RED link is never used, not even for the 50 ms the network needs to converge. Compare with algo 0 on the same router: there, the backup for 16006 is a plain LFA via P2.

Flex-Algo summary

IGP (Algo 0)SR-TE explicit / PCEFlex-Algo
Path logicLowest IGP metricHead-end or controller computedDistributed SPF per algo
ConstraintsNoneAnythingMetric type + affinity / SRLG
Head-end stateNonePer policyNone (one label)
Label stack depth1Can be deep1
FRRTI-LFATI-LFA + policyTI-LFA inside the plane
Controller neededNoOftenNo

Flex-Algo doesn’t replace SR-TE. You still need it for disjoint paths, bandwidth constraints, or anything that requires a global view. But for the “low latency plane” and “avoid these links” requirements, which cover most of them, it gives you the result with one label and zero tunnels.


References

  • RFC 9350 – IGP Flexible Algorithm
  • RFC 8919 – IS-IS Application-Specific Link Attributes
  • RFC 8570 – IS-IS TE Metric Extensions (link delay)
  • RFC 8667 – IS-IS Extensions for Segment Routing
  • Cisco IOS-XR Segment Routing Configuration Guide – “Enabling Segment Routing Flexible Algorithm”

Add a Comment

Your email address will not be published. Required fields are marked *