Skip to content

Commit

Permalink
bgpd: bgp_event_update switch to a switch
Browse files Browse the repository at this point in the history
The return code from a event handling perspective
is an enum.  Let's intentionally make it a switch
so that all cases are ensured to be covered now
and in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Aug 25, 2023
1 parent 8dd97a7 commit d4a9b10
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,7 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
struct peer *other;
int passive_conn = 0;
int dyn_nbr;
struct peer_connection *connection = peer->connection;

other = peer->doppelganger;
passive_conn =
Expand All @@ -2643,7 +2644,9 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
ret = (*(FSM[peer->connection->status - 1][event - 1].func))(
peer->connection);

if (ret >= BGP_FSM_SUCCESS) {
switch (ret) {
case BGP_FSM_SUCCESS:
case BGP_FSM_SUCCESS_STATE_TRANSFER:
if (ret == BGP_FSM_SUCCESS_STATE_TRANSFER &&
next == Established) {
/* The case when doppelganger swap accurred in
Expand All @@ -2670,10 +2673,9 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)

/* Make sure timer is set. */
bgp_timer_set(peer);

} else {
struct peer_connection *connection = peer->connection;

break;
case BGP_FSM_FAILURE:
case BGP_FSM_FAILURE_AND_DELETE:
/*
* If we got a return value of -1, that means there was an
* error, restart the FSM. Since bgp_stop() was called on the
Expand All @@ -2697,6 +2699,8 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
bgp_timer_set(peer);
}
fsm_result = FSM_PEER_STOPPED;

break;
}

return fsm_result;
Expand Down

0 comments on commit d4a9b10

Please sign in to comment.