]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Convert status defines to enum 6060/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 20 Mar 2020 13:03:08 +0000 (09:03 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 20 Mar 2020 22:07:13 +0000 (18:07 -0400)
Convert some status defines for the fsm to an enum
so that we cannot mix and match them in the future.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_fsm.c
bgpd/bgpd.h

index d66afa68c0d06375c21fc1417530add4309a63e9..09856847d184b3fff19e32a87e65616750b3decd 100644 (file)
@@ -130,7 +130,7 @@ static struct peer *peer_xfer_conn(struct peer *from_peer)
        afi_t afi;
        safi_t safi;
        int fd;
-       int status, pstatus;
+       enum bgp_fsm_status status, pstatus;
        enum bgp_fsm_events last_evt, last_maj_evt;
 
        assert(from_peer != NULL);
@@ -456,6 +456,10 @@ void bgp_timer_set(struct peer *peer)
                bgp_keepalives_off(peer);
                BGP_TIMER_OFF(peer->t_routeadv);
                break;
+       case BGP_STATUS_MAX:
+               flog_err(EC_LIB_DEVELOPMENT,
+                        "BGP_STATUS_MAX while a legal state is not valid state for the FSM");
+               break;
        }
 }
 
@@ -2037,7 +2041,7 @@ void bgp_fsm_event_update(struct peer *peer, int valid)
 /* Finite State Machine structure */
 static const struct {
        int (*func)(struct peer *);
-       int next_state;
+       enum bgp_fsm_status next_state;
 } FSM[BGP_STATUS_MAX - 1][BGP_EVENTS_MAX - 1] = {
        {
                /* Idle state: In Idle state, all events other than BGP_Start is
@@ -2198,7 +2202,7 @@ int bgp_event(struct thread *thread)
 
 int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
 {
-       int next;
+       enum bgp_fsm_status next;
        int ret = 0;
        struct peer *other;
        int passive_conn = 0;
index d075f3a7bbcd744d6b83a683fb121aea8aa45831..691b75b1f4a99eeb8754f19b4c53ed42886f33c6 100644 (file)
@@ -857,6 +857,19 @@ enum bgp_fsm_events {
        BGP_EVENTS_MAX,
 };
 
+/* BGP finite state machine status.  */
+enum bgp_fsm_status {
+       Idle = 1,
+       Connect,
+       Active,
+       OpenSent,
+       OpenConfirm,
+       Established,
+       Clearing,
+       Deleted,
+       BGP_STATUS_MAX,
+};
+
 /* BGP neighbor structure. */
 struct peer {
        /* BGP structure.  */
@@ -914,8 +927,8 @@ struct peer {
        struct peer *doppelganger;
 
        /* Status of the peer. */
-       int status;
-       int ostatus;
+       enum bgp_fsm_status status;
+       enum bgp_fsm_status ostatus;
 
        /* FSM events, stored for debug purposes.
         * Note: uchar used for reduced memory usage.
@@ -1568,17 +1581,6 @@ struct bgp_nlri {
 #define BGP_NOTIFY_CAPABILITY_INVALID_LENGTH     2
 #define BGP_NOTIFY_CAPABILITY_MALFORMED_CODE     3
 
-/* BGP finite state machine status.  */
-#define Idle                                     1
-#define Connect                                  2
-#define Active                                   3
-#define OpenSent                                 4
-#define OpenConfirm                              5
-#define Established                              6
-#define Clearing                                 7
-#define Deleted                                  8
-#define BGP_STATUS_MAX                           9
-
 /* BGP timers default value.  */
 #define BGP_INIT_START_TIMER                     1
 /* The following 3 are RFC defaults that are overridden in bgp_vty.c with