跳到主要内容

4.2. OSPFv2 任播属性通告的 YANG 数据模型 (YANG Data Model for OSPFv2 Anycast Property Advertisement)

ietf-ospf-anycast-flag 模块从 [RFC8349] 和 [RFC9129] 导入类型定义 (typedefs). 完整模块按 RFC 文本原样保留.

该模块通过 augment 扩展 OSPFv2 interface 配置, 增加 anycast-flag leaf, 用于表示前缀是否为任播地址. 其中的 must constraint 防止 anycast-flag 和 OSPF node-flag 同时为 true, 从而避免同一前缀同时被解释为任播和节点特定地址. 下方 YANG 内容是规范性代码, 因此保留英文描述, namespace, prefix, identity, leaf, error-message 和 revision 信息.

实现者阅读该模块时应关注三个位置: 首先, identity ac-flag 将任播属性接入 OSPFv2 extended prefix flag 体系; 其次, augment 路径限定该 leaf 只扩展 OSPFv2 interface 数据; 最后, default "false" 表示未显式设置时前缀不被视为任播地址. 代码块中的 descriptionreference 字符串属于 YANG module 的规范内容, 不翻译也不改写, 以保证生成的模块文本与 RFC 可逐字节比对.

从管理面角度看, 该 leaf 是布尔配置状态, 用于控制 OSPFv2 对前缀任播属性的通告. 当它为 true 时, 实现会把对应前缀作为任播前缀处理; 当它为 false 或未配置时, 则不声明任播属性. 该模型没有定义新的 RPC 或 action, 主要风险集中在错误配置和未授权写访问: 如果任播标志被错误设置, 接收方可能对前缀语义作出错误判断. 因此, 下方 module 中的约束和默认值是互操作行为的一部分, 应与协议章节和安全考虑章节一起阅读.

在实现映射时, 管理系统通常会把该 leaf 与接口前缀配置一同呈现, 并在提交配置前执行同一 must 约束. 如果设备支持候选配置或事务性提交, 约束检查应覆盖同一事务中对 anycast-flagnode-flag 的组合修改. 对只读遥测而言, 控制器可以把该值作为前缀属性暴露给拓扑或路径计算组件, 但仍应把它解释为 OSPFv2 通告语义, 而不是独立的地址分配机制.

<CODE BEGINS> file "[email protected]"
module ietf-ospf-anycast-flag {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-ospf-anycast-flag";
prefix ospf-anycast-flag;

import ietf-routing {
prefix rt;
reference
"RFC 8349: A YANG Data Model for Routing
Management (NMDA Version)";
}
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]>

Author: Ran Chen
<mailto:[email protected]>
Author: Detao Zhao
<mailto:[email protected]>
Author: Peter Psenak
<mailto:[email protected]>
Author: Ketan Talaulikar
<mailto:[email protected]>
Author: Changwang Lin
<mailto:[email protected]>";

description
"This YANG module adds the support of managing an OSPFv2
prefix as anycast.

The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
'MAY', and 'OPTIONAL' in this document are to be interpreted as
described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
they appear in all capitals, as shown here.

Copyright (c) 2026 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).

All revisions of IETF and IANA published modules can
be found at the YANG Parameters registry group
(https://www.iana.org/assignments/yang-parameters);

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

revision 2026-05-19 {
description
"Initial version";
reference
"RFC 9983: OSPFv2 Anycast Property Advertisement";
}

identity ac-flag {
base ospf:ospfv2-extended-prefix-flag;
description
"Indicates that the prefix is configured as anycast.";
}

augment "/rt:routing/rt:control-plane-protocols/"
+ "rt:control-plane-protocol/ospf:ospf/"
+ "ospf:areas/ospf:area/ospf:interfaces/ospf:interface" {
when "derived-from(/rt:routing/rt:control-plane-protocols/"
+ "rt:control-plane-protocol/rt:type, 'ospf:ospfv2')" {
description
"This augments the OSPFv2 interface.";
}
description
"This augments OSPFv2 interface with anycast
property advertisement.";
leaf anycast-flag {
type boolean;
must "not(../anycast-flag = 'true' and "
+ "/rt:routing/rt:control-plane-protocols/"
+ "rt:control-plane-protocol/ospf:ospf/"
+ "ospf:areas/ospf:area/ospf:interfaces/"
+ "ospf:interface/ospf:node-flag = 'true')" {
error-message "The anycast-flag and the node-flag MUST "
+ "NOT both be set to 1 (true).";
description
"Ensures architectural consistency by preventing a prefix
from being marked as both anycast and node-specific.";
}
default "false";
description
"Indicates that the prefix is an anycast address,
if set to 1 (true).";
}
}
}
<CODE ENDS>