OPEN message is received.
A TCP Connection Request for an Invalid port (Tcp_CR_Invalid
(Event 15)) is ignored.
If a TcpConnectionFails event (Event 18) is received, the local
system:
- closes the BGP connection,
- restarts the ConnectRetryTimer,
- continues to listen for a connection that may be initiated by
the remote BGP peer, and
- changes its state to Active.
When an OPEN message is received, all fields are checked for
correctness. If there are no errors in the OPEN message (Event
19), the local system:
- resets the DelayOpenTimer to zero,
- sets the BGP ConnectRetryTimer to zero,
- sends a KEEPALIVE message, and
- sets a KeepaliveTimer (via the text below)
- sets the HoldTimer according to the negotiated value (see
Section 4.2),
- changes its state to OpenConfirm.
If the negotiated hold time value is zero, then the HoldTimer and
KeepaliveTimer are not started. If the value of the Autonomous
System field is the same as the local Autonomous System number,
then the connection is an "internal" connection; otherwise, it is
an "external" connection. (This will impact UPDATE processing as
described below.)
If the BGP message header checking (Event 21) or OPEN message
checking detects an error (Event 22)(see Section 6.2), the local
system:
- sends a NOTIFICATION message with the appropriate error code,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is TRUE, and
- changes its state to Idle.
Collision detection mechanisms (Section 6.8) need to be applied
when a valid BGP OPEN message is received (Event 19 or Event 20).
Please refer to Section 6.8 for the details of the comparison. A
CollisionDetectDump event occurs when the BGP implementation
determines, by means outside the scope of this document, that a
connection collision has occurred.
If a connection in the OpenSent state is determined to be the
connection that must be closed, an OpenCollisionDump (Event 23) is
signaled to the state machine. If such an event is received in
the OpenSent state, the local system:
- sends a NOTIFICATION with a Cease,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If a NOTIFICATION message is received with a version error (Event
24), the local system:
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection, and
- changes its state to Idle.
In response to any other event (Events 9, 11-13, 20, 25-28), the
local system:
- sends the NOTIFICATION with the Error Code Finite State
Machine Error,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
OpenConfirm State:
In this state, BGP waits for a KEEPALIVE or NOTIFICATION message.
Any start event (Events 1, 3-7) is ignored in the OpenConfirm
state.
In response to a ManualStop event (Event 2) initiated by the
operator, the local system:
- sends the NOTIFICATION message with a Cease,
- releases all BGP resources,
- drops the TCP connection,
- sets the ConnectRetryCounter to zero,
- sets the ConnectRetryTimer to zero, and
- changes its state to Idle.
In response to the AutomaticStop event initiated by the system
(Event 8), the local system:
- sends the NOTIFICATION message with a Cease,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If the HoldTimer_Expires event (Event 10) occurs before a
KEEPALIVE message is received, the local system:
- sends the NOTIFICATION message with the Error Code Hold Timer
Expired,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If the local system receives a KeepaliveTimer_Expires event (Event
11), the local system:
- sends a KEEPALIVE message,
- restarts the KeepaliveTimer, and
- remains in the OpenConfirmed state.
In the event of a TcpConnection_Valid event (Event 14), or the
success of a TCP connection (Event 16 or Event 17) while in
OpenConfirm, the local system needs to track the second
connection.
If a TCP connection is attempted with an invalid port (Event 15),
the local system will ignore the second connection attempt.
If the local system receives a TcpConnectionFails event (Event 18)
from the underlying TCP or a NOTIFICATION message (Event 25), the
local system:
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If the local system receives a NOTIFICATION message with a version
error (NotifMsgVerErr (Event 24)), the local system:
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection, and
- changes its state to Idle.
If the local system receives a valid OPEN message (BGPOpen (Event
19)), the collision detect function is processed per Section 6.8.
If this connection is to be dropped due to connection collision,
the local system:
- sends a NOTIFICATION with a Cease,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection (send TCP FIN),
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If an OPEN message is received, all fields are checked for
correctness. If the BGP message header checking (BGPHeaderErr
(Event 21)) or OPEN message checking detects an error (see Section
6.2) (BGPOpenMsgErr (Event 22)), the local system:
- sends a NOTIFICATION message with the appropriate error code,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If, during the processing of another OPEN message, the BGP
implementation determines, by a means outside the scope of this
document, that a connection collision has occurred and this
connection is to be closed, the local system will issue an
OpenCollisionDump event (Event 23). When the local system
receives an OpenCollisionDump event (Event 23), the local system:
- sends a NOTIFICATION with a Cease,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If the local system receives a KEEPALIVE message (KeepAliveMsg
(Event 26)), the local system:
- restarts the HoldTimer and
- changes its state to Established.
In response to any other event (Events 9, 12-13, 20, 27-28), the
local system:
- sends a NOTIFICATION with a code of Finite State Machine
Error,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
Established State:
In the Established state, the BGP FSM can exchange UPDATE,
NOTIFICATION, and KEEPALIVE messages with its peer.
Any Start event (Events 1, 3-7) is ignored in the Established
state.
In response to a ManualStop event (initiated by an operator)
(Event 2), the local system:
- sends the NOTIFICATION message with a Cease,
- sets the ConnectRetryTimer to zero,
- deletes all routes associated with this connection,
- releases BGP resources,
- drops the TCP connection,
- sets the ConnectRetryCounter to zero, and
- changes its state to Idle.
In response to an AutomaticStop event (Event 8), the local system:
- sends a NOTIFICATION with a Cease,
- sets the ConnectRetryTimer to zero
- deletes all routes associated with this connection,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
One reason for an AutomaticStop event is: A BGP receives an UPDATE
messages with a number of prefixes for a given peer such that the
total prefixes received exceeds the maximum number of prefixes
configured. The local system automatically disconnects the peer.
If the HoldTimer_Expires event occurs (Event 10), the local
system:
- sends a NOTIFICATION message with the Error Code Hold Timer
Expired,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
If the KeepaliveTimer_Expires event occurs (Event 11), the local
system:
- sends a KEEPALIVE message, and
- restarts its KeepaliveTimer, unless the negotiated HoldTime
value is zero.
Each time the local system sends a KEEPALIVE or UPDATE message, it
restarts its KeepaliveTimer, unless the negotiated HoldTime value
is zero.
A TcpConnection_Valid (Event 14), received for a valid port, will
cause the second connection to be tracked.
An invalid TCP connection (Tcp_CR_Invalid event (Event 15)) will
be ignored.
In response to an indication that the TCP connection is
successfully established (Event 16 or Event 17), the second
connection SHALL be tracked until it sends an OPEN message.
If a valid OPEN message (BGPOpen (Event 19)) is received, and if
the CollisionDetectEstablishedState optional attribute is TRUE,
the OPEN message will be checked to see if it collides (Section
6.8) with any other connection. If the BGP implementation
determines that this connection needs to be terminated, it will
process an OpenCollisionDump event (Event 23). If this connection
needs to be terminated, the local system:
- sends a NOTIFICATION with a Cease,
- sets the ConnectRetryTimer to zero,
- deletes all routes associated with this connection,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations is set to TRUE, and
- changes its state to Idle.
If the local system receives a NOTIFICATION message (Event 24 or
Event 25) or a TcpConnectionFails (Event 18) from the underlying
TCP, the local system:
- sets the ConnectRetryTimer to zero,
- deletes all routes associated with this connection,
- releases all the BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- changes its state to Idle.
If the local system receives a KEEPALIVE message (Event 26), the
local system:
- restarts its HoldTimer, if the negotiated HoldTime value is
non-zero, and
- remains in the Established state.
If the local system receives an UPDATE message (Event 27), the
local system:
- processes the message,
- restarts its HoldTimer, if the negotiated HoldTime value is
non-zero, and
- remains in the Established state.
If the local system receives an UPDATE message, and the UPDATE
message error handling procedure (see Section 6.3) detects an
error (Event 28), the local system:
- sends a NOTIFICATION message with an Update error,
- sets the ConnectRetryTimer to zero,
- deletes all routes associated with this connection,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
In response to any other event (Events 9, 12-13, 20-22), the local
system:
- sends a NOTIFICATION message with the Error Code Finite State
Machine Error,
- deletes all routes associated with this connection,
- sets the ConnectRetryTimer to zero,
- releases all BGP resources,
- drops the TCP connection,
- increments the ConnectRetryCounter by 1,
- (optionally) performs peer oscillation damping if the
DampPeerOscillations attribute is set to TRUE, and
- changes its state to Idle.
9. UPDATE Message Handling
An UPDATE message may be received only in the Established state.
Receiving an UPDATE message in any other state is an error. When an
UPDATE message is received, each field is checked for validity, as
specified in Section 6.3.
If an optional non-transitive attribute is unrecognized, it is
quietly ignored. If an optional transitive attribute is
unrecognized, the Partial bit (the third high-order bit) in the
attribute flags octet is set to 1, and the attribute is retained for
propagation to other BGP speakers.
If an optional attribute is recognized and has a valid value, then,
depending on the type of the optional attribute, it is processed
locally, retained, and updated, if necessary, for possible
propagation to other BGP speakers.
If the UPDATE message contains a non-empty WITHDRAWN ROUTES field,
the previously advertised routes, whose destinations (expressed as IP
prefixes) are contained in this field, SHALL be removed from the
Adj-RIB-In. This BGP speaker SHALL run its Decision Process because
the previously advertised route is no longer available for use.
If the UPDATE message contains a feasible route, the Adj-RIB-In will
be updated with this route as follows: if the NLRI of the new route
is identical to the one the route currently has stored in the Adj-
RIB-In, then the new route SHALL replace the older route in the Adj-
RIB-In, thus implicitly withdrawing the older route from service.
Otherwise, if the Adj-RIB-In has no route with NLRI identical to the
new route, the new route SHALL be placed in the Adj-RIB-In.
Once the BGP speaker updates the Adj-RIB-In, the speaker SHALL run
its Decision Process.
9.1. Decision Process
The Decision Process selects routes for subsequent advertisement by
applying the policies in the local Policy Information Base (PIB) to
the routes stored in its Adj-RIBs-In. The output of the Decision
Process is the set of routes that will be advertised to peers; the
selected routes will be stored in the local speaker’s Adj-RIBs-Out,
according to policy.
The BGP Decision Process described here is conceptual, and does not
have to be implemented precisely as described, as long as the
implementations support the described functionality and they exhibit
the same externally visible behavior.
The selection process is formalized by defining a function that takes
the attribute of a given route as an argument and returns either (a)
a non-negative integer denoting the degree of preference for the
route, or (b) a value denoting that this route is ineligible to be
installed in Loc-RIB and will be excluded from the next phase of
route selection.
The function that calculates the degree of preference for a given
route SHALL NOT use any of the following as its inputs: the existence
of other routes, the non-existence of other routes, or the path
attributes of other routes. Route selection then consists of the
individual application of the degree of preference function to each
feasible route, followed by the choice of the one with the highest
degree of preference.
The Decision Process operates on routes contained in the Adj-RIBs-In,
and is responsible for:
- selection of routes to be used locally by the speaker
- selection of routes to be advertised to other BGP peers
- route aggregation and route information reduction
The Decision Process takes place in three distinct phases, each
triggered by a different event:
a) Phase 1 is responsible for calculating the degree of preference
for each route received from a peer.
b) Phase 2 is invoked on completion of phase 1. It is responsible
for choosing the best route out of all those available for each
distinct destination, and for installing each chosen route into
the Loc-RIB.
c) Phase 3 is invoked after the Loc-RIB has been modified. It is
responsible for disseminating routes in the Loc-RIB to each
peer, according to the policies contained in the PIB. Route
aggregation and information reduction can optionally be
performed within this phase.
9.1.1. Phase 1: Calculation of Degree of Preference
The Phase 1 decision function is invoked whenever the local BGP
speaker receives, from a peer, an UPDATE message that advertises a
new route, a replacement route, or withdrawn routes.
The Phase 1 decision function is a separate process,f which completes
when it has no further work to do.
The Phase 1 decision function locks an Adj-RIB-In prior to operating
on any route contained within it, and unlocks it after operating on
all new or unfeasible routes contained within it.
For each newly received or replacement feasible route, the local BGP
speaker determines a degree of preference as follows:
If the route is learned from an internal peer, either the value of
the LOCAL_PREF attribute is taken as the degree of preference, or
the local system computes the degree of preference of the route
based on preconfigured policy information. Note that the latter
may result in formation of persistent routing loops.
If the route is learned from an external peer, then the local BGP
speaker computes the degree of preference based on preconfigured
policy information. If the return value indicates the route is
ineligible, the route MAY NOT serve as an input to the next phase
of route selection; otherwise, the return value MUST be used as
the LOCAL_PREF value in any IBGP readvertisement.
The exact nature of this policy information, and the computation
involved, is a local matter.
9.1.2. Phase 2: Route Selection
The Phase 2 decision function is invoked on completion of Phase 1.
The Phase 2 function is a separate process, which completes when it
has no further work to do. The Phase 2 process considers all routes
that are eligible in the Adj-RIBs-In.
The Phase 2 decision function is blocked from running while the Phase
3 decision function is in process. The Phase 2 function locks all
Adj-RIBs-In prior to commencing its function, and unlocks them on
completion.
If the NEXT_HOP attribute of a BGP route depicts an address that is
not resolvable, or if it would become unresolvable if the route was
installed in the routing table, the BGP route MUST be excluded from
the Phase 2 decision function.
If the AS_PATH attribute of a BGP route contains an AS loop, the BGP
route should be excluded from the Phase 2 decision function. AS loop