BGP 错误消息
了解 BGP 更新消息的错误处理
当任何一个消息属性格式错误时,BGP 消息被视为格式错误。当参与 BGP 会话的路由器收到格式错误的更新消息时,默认情况下会重置整个会话。这是不可取的,因为具有有效路由的更新消息也会受到影响。为避免这种不良行为,需要修改 BGP 更新消息的错误处理。
要配置 BGP 更新消息的错误处理,请在层次结构级别配置bgp-error-tolerance该[edit protocols bgp]语句 、 [edit protocols bgp group group-name]或 。[edit protocols bgp group group-name neighbor address]
bgp-error-tolerance { malformed-route-limit number; malformed-update-log-interval seconds; no-malformed-route-limit; }
如果属性包含与“属性类型”字段的值冲突的属性标志,则属性标志将重置为正确的值并处理更新消息。属性标志中的 Extended Length 位值保持不变,因为此值定义属性长度是 1 个还是 2 个八位位组。因此,属性标志的值会影响 BGP 更新数据包的解析方式。
路径属性的属性标志值没有显式规范。
从 Junos OS 24.2R1 版开始,默认情况下会启用 BGP 错误处理。您仍然可以在此配置语句下配置子选项,如、 malformed-route-limit、 malformed-update-log-interval和 no-malformed-route-limit 。请注意,如果删除该 bgp-error-tolerance 语句,该功能仍将保持启用状态,并且子选项将重置为默认值。
格式错误的更新消息将根据消息中包含的属性值逐案处理。有三种处理格式错误的 BGP 更新消息的方法,按严重性降序列出。
-
Notification message approach— 在本地记录格式错误的消息错误,向对等方的管理部门发送错误代码更新消息,并重置整个 BGP 会话。
在以下情况下选择此方法:
-
BGP 更新消息包含 MP reach 属性或 MP unreach 属性。
-
由于属性长度与属性长度字段的值不匹配,无法正确解析 NLRI 字段或 BGP 更新消息。
-
-
Treat-as-withdraw approach— 格式错误的更新消息中的所有路由都被视为隐藏路由,除非配置了
keep none该语句,在这种情况下,路由将被丢弃。如果没有该keep none语句,则会为隐藏的格式错误路由的数量配置一个限制,当超过该限制时,将丢弃路由,并防止隐藏任何进一步的格式错误的路由。当达到格式错误的路由限制时,Junos OS 会移除新收到的格式错误的路由。 -
Attribute discard approach- 更新消息中格式错误的属性将被丢弃;但是,消息会被处理。如果要丢弃的属性会影响路由选择或安装,则不建议使用此方法。
注意:如果某个属性在更新消息中出现多次,则除第一次之外,该属性的所有出现都将被丢弃,并处理该消息。
将扫描 BGP 更新消息以查找以下属性,并根据这些属性的值被视为格式错误:
-
The origin attribute—通过撤回后处理方法处理。
-
The AS path attribute—通过撤回后处理方法处理。
-
The AS 4 path attribute- 通过属性放弃方法处理。
-
The aggregator attribute- 通过属性放弃方法处理。
-
The aggregator 4 attribute- 通过属性放弃方法处理。
-
The next-hop attribute—通过撤回后处理方法处理。
-
The multiple exit discriminator attribute—通过撤回后处理方法处理。
-
The local preference attribute—通过撤回后处理方法处理。
-
The atomic aggregate attribute- 通过属性放弃方法处理。
-
The community attribute—通过撤回后处理方法处理。
-
The extended community attribute—通过撤回后处理方法处理。
-
The originator attribute—通过撤回后处理方法处理。
-
The cluster attribute—通过撤回后处理方法处理。
-
The PMSI attribute—通过撤回后处理方法处理。
-
The MP reach attribute- 通过通知消息方法处理。
-
The MP unreach attribute- 通过通知消息方法处理。
-
The attribute set attribute—通过撤回后处理方法处理。
-
The AIGP attribute—通过撤回后处理方法处理。
-
Unknown attribute— 如果 BGP 标志未指示这是可选属性,则此格式错误的属性将由通知消息方法处理。
当 BGP 更新消息包含多个格式错误的属性时,将遵循由其中一个属性触发的最严重方法。
以下是 BGP 错误消息输出的示例:
user@R1> show log messages Sep 18 17:54:13 R1 rpd[86600]: Received malformed update from 10.10.10.2 (External AS 64511) Sep 18 17:54:13 R1 rpd[86600]: Family inet-unicast, prefix 100.1.1.0/24 Sep 18 17:54:13 R1 rpd[86600]: Malformed Attribute ORIGIN(1) flag 0x40 length 1 error 6 (Unrecognized ORIGIN attribute). Sep 18 17:54:13 R1 rpd[86600]: Malformed Attribute LOCAL_PREF(5) flag 0x40 length 6 error 5 (Attribute length error).
在此示例中,您可以看到源 (ORIGIN) 和本地优先级 (LOCAL_PREF) 格式错误的属性。
也可以看看
示例:配置 BGP 更新消息的错误处理
此示例说明如何配置 BGP 错误处理。
要求
开始之前:
-
配置路由器接口。
-
配置内部网关协议 (IGP)。
-
配置 BGP。
-
配置路由策略。
概述
当路由设备收到具有格式错误属性的更新消息时,需要路由器重置会话。这在 RFC 4271 边界网关协议 4 (BGP-4) 中指定。会话重置不仅会影响具有违规属性的路由,还会影响通过会话交换的其他有效路由。此外,在可选的传递属性的情况下,此行为可能会带来潜在的安全漏洞。为了最大程度地减少格式错误的更新消息对路由的影响,Internet 草案draft-ietf-idr-error-handling-01.txt BGP UPDATE 消息的修订错误处理 指定了处理具有格式错误属性BGP更新消息的修改。新的错误处理允许维护已建立的会话并保持有效路由的交换,同时删除格式错误的 UPDATE 消息中携带的路由。
拓扑结构
在 图 1 中,设备 R1 与设备 R0 有一个内部 BGP 对等会话,以及一个与设备 R2 的外部 BGP 对等会话。
为了防止格式错误的更新消息导致网络不稳定,设备 R1 配置了 BGP 错误处理,如下所示:
bgp-error-tolerance {
malformed-update-log-interval 10;
malformed-route-limit 5;
}
默认情况下,当任何一个消息属性格式错误时,BGP 消息被视为格式错误。当参与 BGP 会话的路由器收到格式错误的更新消息时,整个会话将被重置。该 bgp-error-tolerance 语句覆盖此行为,以便以下 BGP 错误处理生效:
-
对于致命错误,Junos OS 会发送一条名为“错误代码更新消息”的通知消息,并重置 BGP 会话。MP_{UN}REACH 属性中的错误被视为致命错误。如果一次BGP更新中存在多个 MP_{UN}REACH 属性,也会被视为致命错误。如果 Junos OS 无法正确解析 NLRI 字段或 BGP 更新,则会重置 BGP 会话。当属性长度与属性值的长度不匹配时,可能会发生解析 BGP 更新数据包失败的情况。
-
对于某些非致命错误,Junos OS 会将格式错误的 BGP 更新消息中包含的所有路由视为撤回的路由并将其安装为隐藏路由,除非
keep none该语句包含在 BGP 配置中。Junos OS 对涉及以下任何属性的情况使用此错误处理方法:ORIGIN、AS_PATH、NEXT_HOP、MULTI_EXIT_DISC、LOCAL_PREF、ORIGINATOR、CLUSTER、ATTRSET、PMSI、社区和扩展社区。此外,如果缺少任何必需的已知路径属性,Junos OS 会将 BGP 更新视为格式错误。为了限制这些格式错误的隐藏路由的内存使用量,在达到此类格式错误的隐藏路由的最大数量后,Junos OS 将停止安装新的格式错误的隐藏路由。在此示例中,使用语句将malformed-route-limit最大数字设置为 5。默认值为 1000。或者,您可以允许无限数量的路由因格式错误的属性而隐藏。通过包含no-malformed-route-limit语句来执行此操作。 -
对于其他非致命错误,Junos OS 会丢弃格式错误的路径属性,并继续处理 BGP 更新消息。对可能影响路由选择或安装的路径属性使用此方法是不安全的。Junos OS对涉及以下任何属性的情况使用此错误处理方法:ATOMIC_AGGREGATE、聚合器、AGGREGATOR4和AS4PATH。
为了便于排除格式错误的数据包,Junos OS 会记录错误,其中列出格式错误的路径属性代码、标志、长度、有关对等方和家族的信息以及格式错误 BGP 更新的第一个前缀。如果在短时间内收到大量格式错误的数据包,记录格式错误的数据包可能会降低 Junos OS 的性能。为了限制性能影响,Junos OS 实施了一种算法来记录格式错误的更新,在一段时间内抑制日志记录,并记录摘要。当日志记录抑制计时器到期时,软件将记录在此时间间隔内接收到的格式错误的属性总数。在此示例中,计时器使用 语句 设置为 malformed-update-log-interval 10 秒。默认值为 300 秒(5 分钟)。
第 #d101e193__d101e403 节介绍了设备 R1 上的步骤。
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,然后将命令复制并粘贴到层次结构级别的 [edit] CLI 中。
设备 R0
set interfaces fe-1/2/0 unit 0 description to-R1 set interfaces fe-1/2/0 unit 0 family inet address 172.16.10.5/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set protocols bgp group internal-peers type internal set protocols bgp group internal-peers local-address 192.168.0.3 set protocols bgp group internal-peers export local-direct set protocols bgp group internal-peers neighbor 192.168.0.1 set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement local-direct from protocol [local direct] set policy-options policy-statement local-direct then accept set routing-options autonomous-system 64510 set routing-options router-id 192.168.0.3
设备 R1
set interfaces fe-1/2/1 unit 0 description to-R2 set interfaces fe-1/2/1 unit 0 family inet address 10.10.10.1/30 set interfaces fe-1/2/0 unit 0 description to-R0 set interfaces fe-1/2/0 unit 0 family inet address 172.16.10.6/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols bgp bgp-error-tolerance malformed-update-log-interval 10 set protocols bgp bgp-error-tolerance malformed-route-limit 5 set protocols bgp group internal-peers type internal set protocols bgp group internal-peers local-address 192.168.0.1 set protocols bgp group internal-peers export local-direct set protocols bgp group internal-peers neighbor 192.168.0.3 set protocols bgp group external-peers type external set protocols bgp group external-peers export local-direct set protocols bgp group external-peers peer-as 64511 set protocols bgp group external-peers neighbor 10.10.10.2 set protocols ospf area 0.0.0.0 interface fe-1/2/1.0 set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement local-direct from protocol [local direct] set policy-options policy-statement local-direct then accept set routing-options autonomous-system 64510 set routing-options router-id 192.168.0.1
设备 R2
set interfaces fe-1/2/1 unit 0 description to-R1 set interfaces fe-1/2/1 unit 0 family inet address 10.10.10.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp group external-peers type external set protocols bgp group external-peers export local-direct set protocols bgp group external-peers peer-as 64510 set protocols bgp group external-peers neighbor 10.10.10.1 set protocols ospf area 0.0.0.0 interface fe-1/2/1.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement local-direct from protocol [local direct] set policy-options policy-statement local-direct then accept set routing-options autonomous-system 64511 set routing-options router-id 192.168.10.2
过程
分步程序
下面的示例要求您在各个配置层级中进行导航。有关导航CLI的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用CLI编辑器。
要配置 BGP 错误处理,请执行以下操作:
-
配置路由器接口。
[edit interfaces] user@R1# set fe-1/2/1 unit 0 description to-R2 user@R1# set fe-1/2/1 unit 0 family inet address 10.10.10.1/30 user@R1# set fe-1/2/0 unit 0 description to-R0 user@R1# set fe-1/2/0 unit 0 family inet address 172.16.10.6/30 user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
-
配置内部网关协议 (IGP),例如 OSPF 或 IS-IS。
[edit protocols ospf area 0.0.0.0] user@R1# set interface fe-1/2/1.0 user@R1# set interface fe-1/2/0.0 user@R1# set interface lo0.0 passive
-
配置自治系统 (AS) 编号和路由器 ID。
[edit routing-options] user@R1# set autonomous-system 64510 user@R1# set router-id 192.168.0.1
-
配置路由策略。
[edit policy-options policy-statement local-direct] user@R1# set from protocol [local direct] user@R1# set then accept
-
配置 EBGP 会话。
[edit protocols bgp group external-peers] user@R1# set type external user@R1# set export local-direct user@R1# set peer-as 64511 user@R1# set neighbor 10.10.10.2
-
配置 IBGP 会话。
[edit protocols bgp group internal-peers] user@R1# set type internal user@R1# set local-address 192.168.0.1 user@R1# set export local-direct user@R1# set neighbor 192.168.0.3
-
启用 BGP 容错。
[edit protocols bgp] user@R1# set bgp-error-tolerance
-
(选答)配置日志间隔。
[edit protocols bgp bgp-error-tolerance] user@R1# set malformed-update-log-interval 10
-
(选答)配置要存储的隐藏路由数量限制。
[edit protocols bgp bgp-error-tolerance] user@R1# set malformed-route-limit 5
结果
在配置模式下,输入 show interfaces、 show protocols、 show policy-options和 show routing-options、 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@R1#
show interfaces
fe-1/2/0 {
unit 0 {
description to-R0;
family inet {
address 172.16.10.6/30;
}
}
}
fe-1/2/1 {
unit 0 {
description to-R2;
family inet {
address 10.10.10.1/30;
}
}
}
lo0 {
unit 0 {
family inet {
address 192.168.0.1/32;
}
}
}
user@R1# show protocols
bgp {
bgp-error-tolerance {
malformed-update-log-interval 10;
malformed-route-limit 5;
}
group internal-peers {
type internal;
local-address 192.168.0.1;
export local-direct;
neighbor 192.168.0.3;
}
group external-peers {
type external;
export local-direct;
peer-as 64511;
neighbor 10.10.10.2;
}
}
ospf {
area 0.0.0.0 {
interface fe-1/2/1.0;
interface fe-1/2/0.0;
interface lo0.0 {
passive;
}
}
}
user@R1#
show policy-options
policy-statement local-direct {
from protocol [local direct];
then accept;
}
user@R1#
show routing-options
router-id 192.168.0.1;
autonomous-system 64510;
如果完成设备配置,请从配置模式进入。commit
验证
确认配置工作正常。
检查 BGP 邻接方会话
目的
验证是否启用了 BGP 容错,并显示与格式错误的路径属性相关的计数器。
行动
user@R1# show bgp neighbor
Peer: 10.10.10.2+50058 AS 64511 Local: 10.10.10.1+179 AS 64510
Type: External State: Established Flags: <Sync>
Last State: OpenConfirm Last Event: RecvKeepAlive
Last Error: None
Export: [ local-direct ]
Options: <Preference PeerAS Refresh>
Holdtime: 90 Preference: 170
Number of flaps: 0
Malformed attributes log interval: 10 route limit: 5
Attribute: ORIGIN(1) Last Received: 0 Total Received: 3
Attribute: LOCAL_PREF(5) Last Received: 0 Total Received: 2
Peer ID: 192.168.10.2 Local ID: 192.168.10.1 Active Holdtime: 90
Keepalive Interval: 30 Group index: 0 Peer index: 0
BFD: disabled, down
Local Interface: fe-1/2/1.0
NLRI for restart configured on peer: inet-unicast
NLRI advertised by peer: inet-unicast
NLRI for this session: inet-unicast
Peer supports Refresh capability (2)
Stale routes from peer are kept for: 300
Peer does not support Restarter functionality
NLRI that restart is negotiated for: inet-unicast
NLRI of received end-of-rib markers: inet-unicast
NLRI of all end-of-rib markers sent: inet-unicast
Peer supports 4 byte AS extension (peer-as 64511)
Peer does not support Addpath
Table inet.0 Bit: 10000
RIB State: BGP restart is complete
Send state: in sync
Active prefixes: 0
Received prefixes: 3
Accepted prefixes: 0
Suppressed due to damping: 0
Advertised prefixes: 2
Last traffic (seconds): Received 25 Sent 17 Checked 73
Input messages: Total 2702 Updates 10 Refreshes 0 Octets 51652
Output messages: Total 2701 Updates 6 Refreshes 0 Octets 51571
Output Queue[0]: 0
Peer: 192.168.10.3+179 AS 64510 Local: 192.168.10.1+51127 AS 64510
Type: Internal State: Established Flags: <Sync>
Last State: OpenConfirm Last Event: RecvKeepAlive
Last Error: None
Export: [ local-direct ]
Options: <Preference LocalAddress Refresh>
Local Address: 192.168.10.1 Holdtime: 90 Preference: 170
Number of flaps: 0
Malformed attributes log interval: 10 route limit: 5
Peer ID: 192.168.10.3 Local ID: 192.168.10.1 Active Holdtime: 90
Keepalive Interval: 30 Group index: 1 Peer index: 0
BFD: disabled, down
NLRI for restart configured on peer: inet-unicast
NLRI advertised by peer: inet-unicast
NLRI for this session: inet-unicast
Peer supports Refresh capability (2)
Stale routes from peer are kept for: 300
Peer does not support Restarter functionality
NLRI that restart is negotiated for: inet-unicast
NLRI of received end-of-rib markers: inet-unicast
NLRI of all end-of-rib markers sent: inet-unicast
Peer supports 4 byte AS extension (peer-as 64510)
Peer does not support Addpath
Table inet.0 Bit: 10001
RIB State: BGP restart is complete
Send state: in sync
Active prefixes: 0
Received prefixes: 3
Accepted prefixes: 0
Suppressed due to damping: 0
Advertised prefixes: 2
Last traffic (seconds): Received 5 Sent 24 Checked 51
Input messages: Total 417 Updates 3 Refreshes 0 Octets 8006
Output messages: Total 421 Updates 2 Refreshes 0 Octets 8136
Output Queue[0]: 0
意义
“格式错误的属性”字段显示已启用容错。日志间隔和路由限制字段将显示配置的值。
属性计数器显示,在 EBGP 连接上,从设备 R2 收到了几个格式错误的属性。
检查隐藏路由
目的
查看有关隐藏路径的信息并了解它们隐藏的原因。
行动
user@R1> show route hidden detail
inet.0: 42 destinations, 45 routes (36 active, 0 holddown, 6 hidden)
10.0.0.0/32 (1 entry, 0 announced)
BGP
Next hop type: Router
Address: 0x93d8b0c
Next-hop reference count: 5
Source: 10.10.10.2
Next hop type: Router, Next hop index: 782
Next hop: via fe-1/2/1.0, selected
Session Id: 0x1
State: <Hidden Ext>
Local AS: 1 Peer AS: 1
Age: 5:32 Metric2: 1
Validation State: unverified
Task: BGP_1.10.10.5.62+56218
AS path: I (MalformedAttr)
Router ID: 192.168.0.2
10.0.0.1/32 (1 entry, 0 announced)
BGP
Next hop type: Router
Address: 0x93d8b0c
Next-hop reference count: 5
Source: 10.10.10.2
Next hop type: Router, Next hop index: 782
Next hop: via fe-1/2/1.0, selected
Session Id: 0x1
Indirect next hop: 953c000 - INH Session ID: 0x3
State: <Hidden Int Ext>
Local AS: 1 Peer AS: 1
Age: 5:32 Metric2: 1
Validation State: unverified
Task: BGP_1.10.10.5.62+56218
AS path: I (MalformedAttr)
Router ID: 192.168.0.2
意义
格式错误的隐藏路由在 AS 路径字段中用 MalformedAttr 标记。
您可以通过运行 clear bgp neighbor 10.10.10.2 malformed-route 命令来移除隐藏的路由。
验证隐藏路由的来源
目的
查看有关隐藏路径的信息并了解它们隐藏的原因。
行动
user@R1> show route receive-protocol bgp 10.10.10.2 detail hidden
inet.0: 42 destinations, 45 routes (36 active, 0 holddown, 6 hidden)
10.0.0.0/32 (1 entry, 0 announced)
Nexthop: 10.10.10.2
Localpref: 100
AS path: I (MalformedAttr)
10.0.0.1/32 (1 entry, 0 announced)
Nexthop: 10.10.10.2
Localpref: 100
AS path: I (MalformedAttr)
意义
Junos OS 在命令输出 show route receive-protocol bgp 10.10.10.2 detail hidden 的 AS 路径字段中显示 MalformedAttr。
您可以通过运行 clear bgp neighbor 10.10.10.2 malformed-route 命令来移除隐藏的路由。