跳到主要内容

3. MPLS 上的 OSPF 段路由 YANG 模块

本节给出 MPLS 数据平面上 OSPF 段路由扩展的完整 YANG 模块说明.

模块结构 (Module Structure)

ietf-ospf-sr-mpls YANG 模块增广 OSPF 基础 YANG 模型 [RFC9129], 并与段路由基础模块 [RFC9020] 集成. 它同时支持 OSPFv2 [RFC8665] 和 OSPFv3 [RFC8666].

模块头 (Module Header)

module ietf-ospf-sr-mpls {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-ospf-sr-mpls";
prefix ospf-sr-mpls;

import ietf-routing {
prefix rt;
reference
"RFC 8349: A YANG Data Model for Routing Management
(NMDA Version)";
}

import ietf-segment-routing-mpls {
prefix sr-mpls;
reference
"RFC 9020: YANG Data Model for Segment Routing";
}

import ietf-ospf {
prefix ospf;
reference
"RFC 9129: YANG Data Model for the OSPF Protocol";
}

organization
"IETF LSR - Link State Routing Working Group";

contact
"WG Web: `https://datatracker.ietf.org/wg/lsr/`
WG List: <mailto:[email protected]>

Editor: Yingzhen Qu
<mailto:[email protected]>
Editor: Acee Lindem
<mailto:[email protected]>
Editor: Jeffrey Zhang
<mailto:[email protected]>
Editor: Ing-Wher Chen
<mailto:[email protected]>";

description
"This YANG module defines the configuration and operational
state for OSPF extensions for Segment Routing (SR) over the
MPLS data plane.

This YANG module conforms to the Network Management
Datastore Architecture (NMDA) as described in RFC 8342.

Copyright (c) 2025 IETF Trust and the persons identified as
authors of the code. All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Revised BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(https://trustee.ietf.org/license-info).

This version of this YANG module is part of RFC 9903;
see the RFC itself for full legal notices.";

revision 2025-12 {
description
"Initial revision.";
reference
"RFC 9903: A YANG Data Model for OSPF Segment Routing
over the MPLS Data Plane";
}
}

关键数据节点 (Key Data Nodes)

段路由全局配置 (Segment Routing Global Configuration)

SRGB 配置:

  • 路径 (Path): /rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/segment-routing/srgb
  • 类型 (Type): 包含 lower-bound 和 upper-bound 叶子的容器
  • 描述 (Description): 定义段路由全局块范围

SRLB 配置:

  • 路径 (Path): /rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/segment-routing/srlb
  • 类型 (Type): 包含 lower-bound 和 upper-bound 叶子的容器
  • 描述 (Description): 定义段路由本地块范围

MSD 配置:

  • 路径 (Path): /rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/segment-routing/msd
  • 类型 (Type): uint8
  • 描述 (Description): 节点能够压入的最大 SID 深度

区域级配置 (Area-Level Configuration)

启用段路由 (Segment Routing Enable):

  • 路径 (Path): /rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/areas/area/segment-routing/enabled
  • 类型 (Type): boolean
  • 默认值 (Default): false
  • 描述 (Description): 在区域内所有接口上启用 SR-MPLS

接口级配置 (Interface-Level Configuration)

Adjacency-SID 配置:

  • 路径 (Path): /rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/areas/area/interfaces/interface/segment-routing/adjacency-sid
  • 类型 (Type): 容器
  • 内容 (Contents):
    • value: SID 值或索引
    • neighbor: 邻居 router-id (用于多接入网络)
    • flags: 保护标志和值/索引标志

TI-LFA 配置:

  • 路径 (Path): /rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/areas/area/interfaces/interface/fast-reroute/ti-lfa
  • 类型 (Type): 容器
  • 内容 (Contents):
    • enable: 启用/禁用 TI-LFA
    • node-protection: 启用节点保护

运行状态数据 (Operational State Data)

OSPFv2 LSA 扩展

该模块使用与 SR 相关的 TLV 增广 OSPFv2 LSA:

Extended Prefix Opaque LSA:

  • Extended Prefix TLV
    • Prefix-SID Sub-TLV
      • Flags: NP-flag、M-flag、E-flag、V-flag、L-flag
      • Algorithm
      • SID/Index/Label

Extended Link Opaque LSA:

  • Extended Link TLV
    • Adj-SID Sub-TLV
      • Flags: B-flag、V-flag、L-flag、G-flag、P-flag
      • Weight
      • SID/Label

Router Information Opaque LSA:

  • SR-Algorithm TLV
  • SID/Label Range TLV
  • SR Local Block TLV
  • SRMS Preference TLV

OSPFv3 LSA 扩展

该模块使用与 SR 相关的 TLV 增广 OSPFv3 E-LSA:

E-Router LSA:

  • SR-Algorithm TLV
  • SID/Label Range TLV
  • SR Local Block TLV

E-Intra-Area-Prefix LSA:

  • Prefix-SID Sub-TLV (类似 OSPFv2)

E-Link LSA:

  • Adj-SID Sub-TLV
  • LAN Adj-SID Sub-TLV
    • Neighbor Router-ID
    • Flags and SID/Label

核心术语 (Core Terminology)

Prefix-SID (Prefix Segment Identifier)

与 IP 前缀关联的段标识符. Prefix-SID 在 SR 域内全局唯一, 表示到该前缀的 ECMP 感知最短路径.

关键属性 (Key Attributes):

  • 全局作用域 (Global Scope): 使用 SRGB 标签范围
  • 算法 (Algorithm): 与特定算法关联, 例如 SPF
  • Node-SID: 当前缀是路由器环回地址时使用

Adjacency-SID (Adjacency Segment Identifier)

表示到相邻路由器的特定邻接关系的段标识符.

关键属性 (Key Attributes):

  • 本地作用域 (Local Scope): 使用 SRLB 或动态标签范围
  • 严格转发 (Strict Forwarding): 流量专门通过该邻接转发
  • 保护 (Protection): 可由备用路径保护

LAN Adjacency-SID

在多接入网络 (LAN) 上使用的特殊 Adjacency-SID 形式, 同时标识本地接口和邻居路由器.

SRGB (Segment Routing Global Block)

SR 域内为全局段保留的标签范围. 为确保 SR 正常运行, 所有节点应具有一致的 SRGB 配置.

SRLB (Segment Routing Local Block)

为本地段保留的标签范围. SRLB 标签仅具有本地意义, 不在整个域内传播.

MSD (Maximum SID Depth)

节点可压入数据包的最大 SID 数量. 该值会被通告, 以帮助路径计算引擎确定可行的 SR 路径.

使用示例 (Usage Example)

完整配置示例见 Appendix A.

完整模块定义 (Complete Module Definition)

有关包含所有数据节点、增广和通知的完整 YANG 模块定义, 请参见:


注意: 完整 YANG 模块代码 (约 600 多行) 包含每个数据节点的详细描述、约束和引用. 网络运营者应使用 YANG 验证工具来确保配置符合模块约束.

实现考虑事项 (Implementation Considerations)

OSPFv2 与 OSPFv3 的差异

尽管两个协议支持相同的 SR 概念, LSA 编码不同:

  • OSPFv2: 使用 Opaque LSA (Type 9/10/11)
  • OSPFv3: 使用带 TLV 编码的 E-LSA

该 YANG 模块提供统一的配置接口, 抽象了这些差异.

互操作性 (Interoperability)

在 OSPF 网络中部署 SR-MPLS 时:

  1. SRGB 一致性: 确保所有节点具有兼容的 SRGB 范围
  2. 算法支持: 验证所有节点支持相同的 SR 算法
  3. MSD 通告: 正确配置并通告 MSD 值
  4. Prefix-SID 唯一性: 避免域内 SID 冲突

迁移策略 (Migration Strategies)

对于迁移到 SR-MPLS 的网络:

  1. 增量部署 (Incremental Deployment): 初始只在部分节点上启用 SR
  2. 与 LDP 共存 (Coexistence with LDP): 过渡期间 SR-MPLS 可以与 LDP 共存
  3. 映射服务器 (Mapping Server): 对尚不具备 SR 能力的节点使用 SR Mapping Server
  4. 监控 (Monitoring): 持续监控 SR 路径建立和流量流动