BGP Connection Collision Detection(RFC4271)
If a pair of BGP speakers try to establish a BGP connection with each
other simultaneously, then two parallel connections well be formed.
If the source IP address used by one of these connections is the same
as the destination IP address used by the other, and the destination
IP address used by the first connection is the same as the source IP
address used by the other, connection collision has occurred. In the
event of connection collision, one of the connections MUST be closed.
Based on the value of the BGP Identifier, a convention is established
for detecting which BGP connection is to be preserved when a
collision occurs. The convention is to compare the BGP Identifiers
of the peers involved in the collision and to retain only the
connection initiated by the BGP speaker with the higher-valued BGP
Identifier.
Upon receipt of an OPEN message, the local system MUST examine all of
its connections that are in the OpenConfirm state. A BGP speaker MAY
also examine connections in an OpenSent state if it knows the BGP
Identifier of the peer by means outside of the protocol. If, among
these connections, there is a connection to a remote BGP speaker
whose BGP Identifier equals the one in the OPEN message, and this
connection collides with the connection over which the OPEN message
is received, then the local system performs the following collision
resolution procedure:
1) The BGP Identifier of the local system is compared to the BGP
Identifier of the remote system (as specified in the OPEN
message). Comparing BGP Identifiers is done by converting them
to host byte order and treating them as 4-octet unsigned
integers.
2) If the value of the local BGP Identifier is less than the
remote one, the local system closes the BGP connection that
already exists (the one that is already in the OpenConfirm
state), and accepts the BGP connection initiated by the remote
system.
3) Otherwise, the local system closes the newly created BGP
connection (the one associated with the newly received OPEN
message), and continues to use the existing one (the one that
is already in the OpenConfirm state).
Unless allowed via configuration, a connection collision with an
existing BGP connection that is in the Established state causes
closing of the newly created connection.
Note that a connection collision cannot be detected with connections
that are in Idle, Connect, or Active states.
Closing the BGP connection (that results from the collision
resolution procedure) is accomplished by sending the NOTIFICATION
message with the Error Code Cease
BGP连接冲突检测
如果一对BGP设备彼此同时尝试建立BGP连接,那么2个并行的连接将会建立。如果源地址等于另一个连接的目的IP,同时目的IP也用于了另外一个连接的源IP,那么连接冲突就发生了。
基于BGP的ID值
通常会基于BGP的路由器ID来完成约定俗称的比较,如果BGP连接发生冲突,那么仅保留由较大路由器ID的BGP设备发起TCP连接。
收到OPEN报文后,本设备必须检查所有处于OpenConfirm状态的连接。 BGP设备如果远端设备的BGP路由器ID,可能也会检查处于OpenSent状态的链接。
如果本地BGP标识符的值小于远程BGP标识符的值,则本地系统将关闭已存在的BGP连接(已经处于OpenConfirm状态的BGP连接),并接受由远程系统启动的BGP连接。
否则,本地系统将关闭新创建的BGP连接(与新接收到的OPEN消息关联的连接),并继续使用现有的BGP连接(已经处于OpenConfirm状态的连接)。
注意TCP连接冲突不能检测处于IDLE、连接或者Active状态的BGP状态,关闭由于TCP连接冲突的BGP连接通过发送BGP差错报文完成
为了避免这种极端情况发生,可以使用如下命令开控制主被动:
[R3-bgp]peer Ender listen-only //被动接受
R3(config-router)#neighbor Ender transport connection-mode passive