]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Move status and ostatus to `struct peer_connection`
authorDonald Sharp <sharpd@nvidia.com>
Thu, 3 Jun 2021 21:13:52 +0000 (17:13 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 18 Aug 2023 13:29:04 +0000 (09:29 -0400)
The status and ostatus are a function of the `struct peer_connection`
move it into that data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
21 files changed:
bgpd/bgp_bfd.c
bgpd/bgp_bmp.c
bgpd/bgp_dump.c
bgpd/bgp_evpn.c
bgpd/bgp_fsm.c
bgpd/bgp_fsm.h
bgpd/bgp_io.c
bgpd/bgp_network.c
bgpd/bgp_packet.c
bgpd/bgp_route.c
bgpd/bgp_script.c
bgpd/bgp_snmp_bgp4.c
bgpd/bgp_snmp_bgp4v2.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h
bgpd/rfapi/rfapi.c
bgpd/rfapi/vnc_zebra.c
tests/bgpd/test_capability.c
tests/bgpd/test_mp_attr.c
tests/bgpd/test_packet.c

index d1ddfd046025e1be25da3b3d25d4078725d86fda..598368ae660fe29a32429cf46cf6a3063fe30dc7 100644 (file)
@@ -56,7 +56,7 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,
                peer->last_reset = PEER_DOWN_BFD_DOWN;
 
                /* rfc9384 */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_BFD_DOWN);
 
index baf164679c725586c871eaaa0c7df7e46d2e4037..4d604addda9c60097c98342355edf299cae61d9b 100644 (file)
@@ -703,7 +703,7 @@ static int bmp_peer_status_changed(struct peer *peer)
        if (!bmpbgp)
                return 0;
 
-       if (peer->status == Deleted) {
+       if (peer->connection.status == Deleted) {
                bbpeer = bmp_bgp_peer_find(peer->qobj_node.nid);
                if (bbpeer) {
                        XFREE(MTYPE_BMP_OPEN, bbpeer->open_rx);
@@ -715,10 +715,12 @@ static int bmp_peer_status_changed(struct peer *peer)
        }
 
        /* Check if this peer just went to Established */
-       if ((peer->ostatus != OpenConfirm) || !(peer_established(peer)))
+       if ((peer->connection.ostatus != OpenConfirm) ||
+           !(peer_established(peer)))
                return 0;
 
-       if (peer->doppelganger && (peer->doppelganger->status != Deleted)) {
+       if (peer->doppelganger &&
+           (peer->doppelganger->connection.status != Deleted)) {
                bbpeer = bmp_bgp_peer_get(peer);
                bbdopp = bmp_bgp_peer_find(peer->doppelganger->qobj_node.nid);
                if (bbdopp) {
index fe77e7e2500630d3ad0a3ba821cf3434ed541dc7..489b3c6587e11f4cd58df03654c3d70529d13ac7 100644 (file)
@@ -512,8 +512,8 @@ int bgp_dump_state(struct peer *peer)
                        bgp_dump_all.type);
        bgp_dump_common(obuf, peer, 1); /* force this in as4speak*/
 
-       stream_putw(obuf, peer->ostatus);
-       stream_putw(obuf, peer->status);
+       stream_putw(obuf, peer->connection.ostatus);
+       stream_putw(obuf, peer->connection.status);
 
        /* Set length. */
        bgp_dump_set_size(obuf, MSG_PROTOCOL_BGP4MP);
index 3442eee1e19a8f20f0e83bb770165b41b93dae5b..ef62799940eaaedbf3c9a46b6ff6632180425fa8 100644 (file)
@@ -6462,7 +6462,7 @@ void bgp_reimport_evpn_routes_upon_martian_change(
                if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
                        continue;
 
-               if (peer->status != Established)
+               if (peer->connection.status != Established)
                        continue;
 
                if (CHECK_FLAG(peer->af_flags[afi][safi],
index 20a5c4ce33572ee633b6728cce047583bc996c02..b951ada1961340d8cdcb371fafdceb59f8b2e0c0 100644 (file)
@@ -233,16 +233,16 @@ static struct peer *peer_xfer_conn(struct peer *from_peer)
        peer->v_gr_restart = from_peer->v_gr_restart;
        peer->cap = from_peer->cap;
        peer->remote_role = from_peer->remote_role;
-       status = peer->status;
-       pstatus = peer->ostatus;
+       status = peer->connection.status;
+       pstatus = peer->connection.ostatus;
        last_evt = peer->last_event;
        last_maj_evt = peer->last_major_event;
-       peer->status = from_peer->status;
-       peer->ostatus = from_peer->ostatus;
+       peer->connection.status = from_peer->connection.status;
+       peer->connection.ostatus = from_peer->connection.ostatus;
        peer->last_event = from_peer->last_event;
        peer->last_major_event = from_peer->last_major_event;
-       from_peer->status = status;
-       from_peer->ostatus = pstatus;
+       from_peer->connection.status = status;
+       from_peer->connection.ostatus = pstatus;
        from_peer->last_event = last_evt;
        from_peer->last_major_event = last_maj_evt;
        peer->remote_id = from_peer->remote_id;
@@ -310,7 +310,7 @@ static struct peer *peer_xfer_conn(struct peer *from_peer)
                BGP_EVENT_ADD(from_peer, BGP_Stop);
                return NULL;
        }
-       if (from_peer->status > Active) {
+       if (from_peer->connection.status > Active) {
                if (bgp_getsockname(from_peer) < 0) {
                        flog_err(EC_LIB_SOCKET,
                                 "%%bgp_getsockname() failed for %s from_peer %s fd %d (peer fd %d)",
@@ -354,7 +354,7 @@ void bgp_timer_set(struct peer *peer)
        afi_t afi;
        safi_t safi;
 
-       switch (peer->status) {
+       switch (peer->connection.status) {
        case Idle:
                /* First entry point of peer's finite state machine.  In Idle
                   status start timer is on unless peer is shutdown or peer is
@@ -1225,8 +1225,8 @@ static void bgp_update_delay_process_status_change(struct peer *peer)
                if (CHECK_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV))
                        bgp_update_restarted_peers(peer);
        }
-       if (peer->ostatus == Established
-           && bgp_update_delay_active(peer->bgp)) {
+       if (peer->connection.ostatus == Established &&
+           bgp_update_delay_active(peer->bgp)) {
                /* Adjust the update-delay state to account for this flap.
                   NOTE: Intentionally skipping adjusting implicit_eors or
                   explicit_eors
@@ -1302,14 +1302,15 @@ void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status)
        }
 
        /* Preserve old status and change into new status. */
-       peer->ostatus = peer->status;
-       peer->status = status;
+       peer->connection.ostatus = peer->connection.status;
+       peer->connection.status = status;
 
        /* Reset received keepalives counter on every FSM change */
        peer->rtt_keepalive_rcv = 0;
 
        /* Fire backward transition hook if that's the case */
-       if (peer->ostatus == Established && peer->status != Established)
+       if (peer->connection.ostatus == Established &&
+           peer->connection.status != Established)
                hook_call(peer_backward_transition, peer);
 
        /* Save event that caused status change. */
@@ -1338,8 +1339,10 @@ void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status)
        if (bgp_debug_neighbor_events(peer))
                zlog_debug("%s fd %d went from %s to %s", peer->host,
                           peer->connection.fd,
-                          lookup_msg(bgp_status_msg, peer->ostatus, NULL),
-                          lookup_msg(bgp_status_msg, peer->status, NULL));
+                          lookup_msg(bgp_status_msg, peer->connection.ostatus,
+                                     NULL),
+                          lookup_msg(bgp_status_msg, peer->connection.status,
+                                     NULL));
 }
 
 /* Flush the event queue and ensure the peer is shut down */
@@ -1381,7 +1384,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
        }
 
        /* Can't do this in Clearing; events are used for state transitions */
-       if (peer->status != Clearing) {
+       if (peer->connection.status != Clearing) {
                /* Delete all existing events of the peer */
                BGP_EVENT_FLUSH(peer);
        }
@@ -1556,7 +1559,8 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
                /* Received ORF prefix-filter */
                peer->orf_plist[afi][safi] = NULL;
 
-               if ((peer->status == OpenConfirm) || (peer_established(peer))) {
+               if ((peer->connection.status == OpenConfirm) ||
+                   peer_established(peer)) {
                        /* ORF received prefix-filter pnt */
                        snprintf(orf_name, sizeof(orf_name), "%s.%d.%d",
                                 peer->host, afi, safi);
@@ -1711,7 +1715,7 @@ static enum bgp_fsm_state_progress bgp_connect_success(struct peer *peer)
                             "%s: bgp_getsockname(): failed for peer %s, fd %d",
                             __func__, peer->host, peer->connection.fd);
                bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
-                               bgp_fsm_error_subcode(peer->status));
+                               bgp_fsm_error_subcode(peer->connection.status));
                bgp_writes_on(&peer->connection);
                return BGP_FSM_FAILURE;
        }
@@ -1755,7 +1759,7 @@ bgp_connect_success_w_delayopen(struct peer *peer)
                             "%s: bgp_getsockname(): failed for peer %s, fd %d",
                             __func__, peer->host, peer->connection.fd);
                bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
-                               bgp_fsm_error_subcode(peer->status));
+                               bgp_fsm_error_subcode(peer->connection.status));
                bgp_writes_on(&peer->connection);
                return BGP_FSM_FAILURE;
        }
@@ -1965,7 +1969,8 @@ static enum bgp_fsm_state_progress bgp_reconnect(struct peer *peer)
 static enum bgp_fsm_state_progress bgp_fsm_open(struct peer *peer)
 {
        /* If DelayOpen is active, we may still need to send an open message */
-       if ((peer->status == Connect) || (peer->status == Active))
+       if ((peer->connection.status == Connect) ||
+           (peer->connection.status == Active))
                bgp_open_send(peer);
 
        /* Send keepalive and make keepalive timer */
@@ -1979,10 +1984,12 @@ static enum bgp_fsm_state_progress bgp_fsm_open(struct peer *peer)
 static enum bgp_fsm_state_progress bgp_fsm_event_error(struct peer *peer)
 {
        flog_err(EC_BGP_FSM, "%s [FSM] unexpected packet received in state %s",
-                peer->host, lookup_msg(bgp_status_msg, peer->status, NULL));
+                peer->host,
+                lookup_msg(bgp_status_msg, peer->connection.status, NULL));
 
        return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR,
-                                   bgp_fsm_error_subcode(peer->status));
+                                   bgp_fsm_error_subcode(
+                                           peer->connection.status));
 }
 
 /* Hold timer expire.  This is error of BGP connection. So cut the
@@ -2288,13 +2295,14 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
                BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
        }
 
-       if (peer->doppelganger && (peer->doppelganger->status != Deleted)) {
+       if (peer->doppelganger &&
+           (peer->doppelganger->connection.status != Deleted)) {
                if (bgp_debug_neighbor_events(peer))
                        zlog_debug(
                                "[Event] Deleting stub connection for peer %s",
                                peer->host);
 
-               if (peer->doppelganger->status > Active)
+               if (peer->doppelganger->connection.status > Active)
                        bgp_notify_send(peer->doppelganger, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);
                else
@@ -2336,7 +2344,7 @@ static enum bgp_fsm_state_progress bgp_ignore(struct peer *peer)
        flog_err(EC_BGP_FSM,
                 "%s [FSM] Ignoring event %s in state %s, prior events %s, %s, fd %d",
                 peer->host, bgp_event_str[peer->cur_event],
-                lookup_msg(bgp_status_msg, peer->status, NULL),
+                lookup_msg(bgp_status_msg, peer->connection.status, NULL),
                 bgp_event_str[peer->last_event],
                 bgp_event_str[peer->last_major_event], peer->connection.fd);
        return BGP_FSM_SUCCESS;
@@ -2348,7 +2356,7 @@ static enum bgp_fsm_state_progress bgp_fsm_exception(struct peer *peer)
        flog_err(EC_BGP_FSM,
                 "%s [FSM] Unexpected event %s in state %s, prior events %s, %s, fd %d",
                 peer->host, bgp_event_str[peer->cur_event],
-                lookup_msg(bgp_status_msg, peer->status, NULL),
+                lookup_msg(bgp_status_msg, peer->connection.status, NULL),
                 bgp_event_str[peer->last_event],
                 bgp_event_str[peer->last_major_event], peer->connection.fd);
        return bgp_stop(peer);
@@ -2359,7 +2367,7 @@ void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops)
        if (!peer)
                return;
 
-       switch (peer->status) {
+       switch (peer->connection.status) {
        case Idle:
                if (has_valid_nexthops)
                        BGP_EVENT_ADD(peer, BGP_Start);
@@ -2588,12 +2596,13 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
        dyn_nbr = peer_dynamic_neighbor(peer);
 
        /* Logging this event. */
-       next = FSM[peer->status - 1][event - 1].next_state;
+       next = FSM[peer->connection.status - 1][event - 1].next_state;
 
-       if (bgp_debug_neighbor_events(peer) && peer->status != next)
+       if (bgp_debug_neighbor_events(peer) && peer->connection.status != next)
                zlog_debug("%s [FSM] %s (%s->%s), fd %d", peer->host,
                           bgp_event_str[event],
-                          lookup_msg(bgp_status_msg, peer->status, NULL),
+                          lookup_msg(bgp_status_msg, peer->connection.status,
+                                     NULL),
                           lookup_msg(bgp_status_msg, next, NULL),
                           peer->connection.fd);
 
@@ -2601,8 +2610,9 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
        peer->cur_event = event;
 
        /* Call function. */
-       if (FSM[peer->status - 1][event - 1].func)
-               ret = (*(FSM[peer->status - 1][event - 1].func))(peer);
+       if (FSM[peer->connection.status - 1][event - 1].func)
+               ret = (*(FSM[peer->connection.status - 1][event - 1].func))(
+                       peer);
 
        if (ret >= BGP_FSM_SUCCESS) {
                if (ret == BGP_FSM_SUCCESS_STATE_TRANSFER &&
@@ -2615,7 +2625,7 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
                }
 
                /* If status is changed. */
-               if (next != peer->status) {
+               if (next != peer->connection.status) {
                        bgp_fsm_change_status(peer, next);
 
                        /*
@@ -2645,7 +2655,8 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
                        flog_err(EC_BGP_FSM,
                                 "%s [FSM] Failure handling event %s in state %s, prior events %s, %s, fd %d, last reset: %s",
                                 peer->host, bgp_event_str[peer->cur_event],
-                                lookup_msg(bgp_status_msg, peer->status, NULL),
+                                lookup_msg(bgp_status_msg,
+                                           peer->connection.status, NULL),
                                 bgp_event_str[peer->last_event],
                                 bgp_event_str[peer->last_major_event],
                                 peer->connection.fd,
index daf31b266ecb2d31ed6cf97c024332738d26d034..547897de3940459ef45684953c229f7a2bc45f6c 100644 (file)
@@ -17,15 +17,14 @@ enum bgp_fsm_state_progress {
 /* Macro for BGP read, write and timer thread.  */
 #define BGP_TIMER_ON(T, F, V)                                                  \
        do {                                                                   \
-               if ((peer->status != Deleted))                                 \
+               if ((peer->connection.status != Deleted))                      \
                        event_add_timer(bm->master, (F), peer, (V), &(T));     \
        } while (0)
 
-#define BGP_EVENT_ADD(P, E)                                                    \
-       do {                                                                   \
-               if ((P)->status != Deleted)                                    \
-                       event_add_event(bm->master, bgp_event, (P), (E),       \
-                                       NULL);                                 \
+#define BGP_EVENT_ADD(P, E)                                                     \
+       do {                                                                    \
+               if ((P)->connection.status != Deleted)                          \
+                       event_add_event(bm->master, bgp_event, (P), (E), NULL); \
        } while (0)
 
 #define BGP_EVENT_FLUSH(P)                                                     \
index 25180ee53e23480c23eb6105c00ffce8e1808201..5b7d234f9d11801800632cc4c109a381a53fae5d 100644 (file)
@@ -49,7 +49,7 @@ void bgp_writes_on(struct peer_connection *connection)
 
        assert(fpt->running);
 
-       assert(peer->status != Deleted);
+       assert(connection->status != Deleted);
        assert(connection->obuf);
        assert(connection->ibuf);
        assert(connection->ibuf_work);
@@ -80,7 +80,7 @@ void bgp_reads_on(struct peer_connection *connection)
        struct frr_pthread *fpt = bgp_pth_io;
        assert(fpt->running);
 
-       assert(peer->status != Deleted);
+       assert(connection->status != Deleted);
        assert(connection->ibuf);
        assert(connection->fd);
        assert(connection->ibuf_work);
index 9a162b151e2e50275952bb058fc9b53879db9560..6a3b4e8c874eba72952827d714016c095573b0f8 100644 (file)
@@ -482,11 +482,11 @@ static void bgp_accept(struct event *thread)
         * Established and then the Clearing_Completed event is generated. Also,
         * block incoming connection in Deleted state.
         */
-       if (peer1->status == Clearing || peer1->status == Deleted) {
+       if (peer1->connection.status == Clearing ||
+           peer1->connection.status == Deleted) {
                if (bgp_debug_neighbor_events(peer1))
-                       zlog_debug(
-                               "[Event] Closing incoming conn for %s (%p) state %d",
-                               peer1->host, peer1, peer1->status);
+                       zlog_debug("[Event] Closing incoming conn for %s (%p) state %d",
+                                  peer1->host, peer1, peer1->connection.status);
                close(bgp_sock);
                return;
        }
@@ -522,8 +522,8 @@ static void bgp_accept(struct event *thread)
 
        if (bgp_debug_neighbor_events(peer1))
                zlog_debug("[Event] connection from %s fd %d, active peer status %d fd %d",
-                          inet_sutop(&su, buf), bgp_sock, peer1->status,
-                          peer1->connection.fd);
+                          inet_sutop(&su, buf), bgp_sock,
+                          peer1->connection.status, peer1->connection.fd);
 
        if (peer1->doppelganger) {
                /* We have an existing connection. Kill the existing one and run
index cd822fb32ca8235af9a51dbe6fdf7b7503dbd9a9..e13d1fd937ec063b2d68be8e332858539fd9faec 100644 (file)
@@ -1326,13 +1326,14 @@ static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)
         * states. Note that a peer GR is handled by closing the existing
         * connection upon receipt of new one.
         */
-       if (peer_established(peer) || peer->status == Clearing) {
+       if (peer_established(peer) || peer->connection.status == Clearing) {
                bgp_notify_send(new, BGP_NOTIFY_CEASE,
                                BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);
                return -1;
        }
 
-       if ((peer->status != OpenConfirm) && (peer->status != OpenSent))
+       if ((peer->connection.status != OpenConfirm) &&
+           (peer->connection.status != OpenSent))
                return 0;
 
        /*
@@ -1413,7 +1414,7 @@ static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)
  * Side effects
  * ------------
  * - May send NOTIFY messages
- * - May not modify peer->status
+ * - May not modify peer->connection.status
  * - May not call bgp_event_update()
  */
 
@@ -1921,9 +1922,10 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
                flog_err(EC_BGP_INVALID_STATUS,
                         "%s [FSM] Update packet received under status %s",
                         peer->host,
-                        lookup_msg(bgp_status_msg, peer->status, NULL));
+                        lookup_msg(bgp_status_msg, peer->connection.status,
+                                   NULL));
                bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
-                               bgp_fsm_error_subcode(peer->status));
+                               bgp_fsm_error_subcode(peer->connection.status));
                return BGP_Stop;
        }
 
@@ -2369,13 +2371,13 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)
 
        /* Status must be Established. */
        if (!peer_established(peer)) {
-               flog_err(
-                       EC_BGP_INVALID_STATUS,
-                       "%s [Error] Route refresh packet received under status %s",
-                       peer->host,
-                       lookup_msg(bgp_status_msg, peer->status, NULL));
+               flog_err(EC_BGP_INVALID_STATUS,
+                        "%s [Error] Route refresh packet received under status %s",
+                        peer->host,
+                        lookup_msg(bgp_status_msg, peer->connection.status,
+                                   NULL));
                bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
-                               bgp_fsm_error_subcode(peer->status));
+                               bgp_fsm_error_subcode(peer->connection.status));
                return BGP_Stop;
        }
 
@@ -2957,13 +2959,13 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size)
 
        /* Status must be Established. */
        if (!peer_established(peer)) {
-               flog_err(
-                       EC_BGP_NO_CAP,
-                       "%s [Error] Dynamic capability packet received under status %s",
-                       peer->host,
-                       lookup_msg(bgp_status_msg, peer->status, NULL));
+               flog_err(EC_BGP_NO_CAP,
+                        "%s [Error] Dynamic capability packet received under status %s",
+                        peer->host,
+                        lookup_msg(bgp_status_msg, peer->connection.status,
+                                   NULL));
                bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
-                               bgp_fsm_error_subcode(peer->status));
+                               bgp_fsm_error_subcode(peer->connection.status));
                return BGP_Stop;
        }
 
@@ -3001,7 +3003,8 @@ void bgp_process_packet(struct event *thread)
        fsm_update_result = 0;
 
        /* Guard against scheduled events that occur after peer deletion. */
-       if (peer->status == Deleted || peer->status == Clearing)
+       if (peer->connection.status == Deleted ||
+           peer->connection.status == Clearing)
                return;
 
        unsigned int processed = 0;
index 3b3cbb28a991da372f047376da11cefd4ecad91e..a91292d971f8722e836a4a509794484f6ad8924f 100644 (file)
@@ -2754,13 +2754,11 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
                                                continue;
                                        if (BGP_PATH_HOLDDOWN(pi2))
                                                continue;
-                                       if (pi2->peer != bgp->peer_self
-                                           && !CHECK_FLAG(
-                                                   pi2->peer->sflags,
-                                                   PEER_STATUS_NSF_WAIT))
-                                               if (pi2->peer->status
-                                                   != Established)
-                                                       continue;
+                                       if (pi2->peer != bgp->peer_self &&
+                                           !CHECK_FLAG(pi2->peer->sflags,
+                                                       PEER_STATUS_NSF_WAIT) &&
+                                           !peer_established(pi2->peer))
+                                               continue;
 
                                        if (!aspath_cmp_left(pi1->attr->aspath,
                                                             pi2->attr->aspath)
index 68df175c186bb371007e176e3aca790eeb0bf7b4..fe075f37b0613dabfa5a40dd068ac3291101db5d 100644 (file)
@@ -26,7 +26,8 @@ void lua_pushpeer(lua_State *L, const struct peer *peer)
        lua_setfield(L, -2, "remote_id");
        lua_pushinaddr(L, &peer->local_id);
        lua_setfield(L, -2, "local_id");
-       lua_pushstring(L, lookup_msg(bgp_status_msg, peer->status, NULL));
+       lua_pushstring(L, lookup_msg(bgp_status_msg, peer->connection.status,
+                                    NULL));
        lua_setfield(L, -2, "state");
        lua_pushstring(L, peer->desc ? peer->desc : "");
        lua_setfield(L, -2, "description");
index 123d33bd1430caa6900632a91a063210a4fa7a2b..4f90907d289624977d534b4cd2c5f37c2118590e 100644 (file)
@@ -251,7 +251,7 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length,
        case BGPPEERIDENTIFIER:
                return SNMP_IPADDRESS(peer->remote_id);
        case BGPPEERSTATE:
-               return SNMP_INTEGER(peer->status);
+               return SNMP_INTEGER(peer->connection.status);
        case BGPPEERADMINSTATUS:
                *write_method = write_bgpPeerTable;
 #define BGP_PeerAdmin_stop 1
@@ -756,7 +756,8 @@ int bgpTrapEstablished(struct peer *peer)
        oid index[sizeof(oid) * IN_ADDR_SIZE];
 
        /* Check if this peer just went to Established */
-       if ((peer->ostatus != OpenConfirm) || !(peer_established(peer)))
+       if ((peer->connection.ostatus != OpenConfirm) ||
+           !(peer_established(peer)))
                return 0;
 
        ret = inet_aton(peer->host, &addr);
index 712b5d4af87725ee33fef8e6d722cf9583dab040..179970af113ad2b1a3f1c51adb987cebca3160b7 100644 (file)
@@ -265,7 +265,7 @@ static uint8_t *bgpv2PeerTable(struct variable *v, oid name[], size_t *length,
                else
                        return SNMP_INTEGER(BGP_PEER_ADMIN_STATUS_RUNNING);
        case BGP4V2_PEER_STATE:
-               return SNMP_INTEGER(peer->status);
+               return SNMP_INTEGER(peer->connection.status);
        case BGP4V2_PEER_DESCRIPTION:
                if (peer->desc)
                        return SNMP_STRING(peer->desc);
index 5b224c4c56fbfb234b5523fcfb06d659fae5b242..9086e8af7636c05194998fa90c95a32c64f63045 100644 (file)
@@ -2888,7 +2888,7 @@ DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd,
         * with aspath containing AS_SET or AS_CONFED_SET.
         */
        for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_AS_SETS_REJECT;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -2914,7 +2914,7 @@ DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd,
         * with aspath containing AS_SET or AS_CONFED_SET.
         */
        for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_AS_SETS_REJECT;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -4851,7 +4851,7 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
                        peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY);
 
                /* v6only flag changed. Reset bgp seesion */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5040,7 +5040,7 @@ DEFUN (no_neighbor,
 
                        peer_notify_unconfig(peer);
                        peer_delete(peer);
-                       if (other && other->status != Deleted) {
+                       if (other && other->connection.status != Deleted) {
                                peer_notify_unconfig(other);
                                peer_delete(other);
                        }
@@ -11791,7 +11791,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                                        json_object_string_add(
                                                json_peer, "state",
                                                lookup_msg(bgp_status_msg,
-                                                          peer->status, NULL));
+                                                          peer->connection.status,
+                                                          NULL));
                                else if (CHECK_FLAG(
                                                 peer->sflags,
                                                 PEER_STATUS_PREFIX_OVERFLOW))
@@ -11802,7 +11803,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                                        json_object_string_add(
                                                json_peer, "state",
                                                lookup_msg(bgp_status_msg,
-                                                          peer->status, NULL));
+                                                          peer->connection.status,
+                                                          NULL));
 
                                /* BGP peer state */
                                if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)
@@ -11997,7 +11999,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                                        else
                                                vty_out(vty, " %12s",
                                                        lookup_msg(bgp_status_msg,
-                                                                  peer->status, NULL));
+                                                                  peer->connection
+                                                                          .status,
+                                                                  NULL));
 
                                        vty_out(vty, " %8u", 0);
                                }
@@ -13577,9 +13581,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                                     "nbrCommonAdmin");
 
                /* Status. */
-               json_object_string_add(
-                       json_neigh, "bgpState",
-                       lookup_msg(bgp_status_msg, p->status, NULL));
+               json_object_string_add(json_neigh, "bgpState",
+                                      lookup_msg(bgp_status_msg,
+                                                 p->connection.status, NULL));
 
                if (peer_established(p)) {
                        time_t uptime;
@@ -13597,9 +13601,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                        json_object_int_add(json_neigh,
                                            "bgpTimerUpEstablishedEpoch",
                                            epoch_tbuf);
-               }
-
-               else if (p->status == Active) {
+               } else if (p->connection.status == Active) {
                        if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))
                                json_object_string_add(json_neigh, "bgpStateIs",
                                                       "passive");
@@ -13705,14 +13707,13 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
 
                /* Status. */
                vty_out(vty, "  BGP state = %s",
-                       lookup_msg(bgp_status_msg, p->status, NULL));
+                       lookup_msg(bgp_status_msg, p->connection.status, NULL));
 
                if (peer_established(p))
                        vty_out(vty, ", up for %8s",
                                peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN,
                                            0, NULL));
-
-               else if (p->status == Active) {
+               else if (p->connection.status == Active) {
                        if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))
                                vty_out(vty, " (passive)");
                        else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT))
@@ -16427,7 +16428,8 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group,
                                peer_status = "Idle (PfxCt)";
                        else
                                peer_status = lookup_msg(bgp_status_msg,
-                                                        peer->status, NULL);
+                                                        peer->connection.status,
+                                                        NULL);
 
                        dynamic = peer_dynamic_neighbor(peer);
 
index a1d918482948508ac8557e8914c4f21b16ac6b5f..3b34f12e2a2fdff9470e8a227eb274b147d5e863 100644 (file)
@@ -134,8 +134,9 @@ static int bgp_check_main_socket(bool create, struct bgp *bgp)
 
 void bgp_session_reset(struct peer *peer)
 {
-       if (peer->doppelganger && (peer->doppelganger->status != Deleted)
-           && !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE)))
+       if (peer->doppelganger &&
+           (peer->doppelganger->connection.status != Deleted) &&
+           !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE)))
                peer_delete(peer->doppelganger);
 
        BGP_EVENT_ADD(peer, BGP_Stop);
@@ -155,9 +156,9 @@ static void bgp_session_reset_safe(struct peer *peer, struct listnode **nnode)
        n = (nnode) ? *nnode : NULL;
        npeer = (n) ? listgetdata(n) : NULL;
 
-       if (peer->doppelganger && (peer->doppelganger->status != Deleted)
-           && !(CHECK_FLAG(peer->doppelganger->flags,
-                           PEER_FLAG_CONFIG_NODE))) {
+       if (peer->doppelganger &&
+           (peer->doppelganger->connection.status != Deleted) &&
+           !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE))) {
                if (peer->doppelganger == npeer)
                        /* nnode and *nnode are confirmed to be non-NULL here */
                        *nnode = (*nnode)->next;
@@ -305,7 +306,7 @@ static int bgp_router_id_set(struct bgp *bgp, const struct in_addr *id,
        for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
                IPV4_ADDR_COPY(&peer->local_id, id);
 
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_RID_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -484,7 +485,7 @@ void bgp_cluster_id_set(struct bgp *bgp, struct in_addr *cluster_id)
                if (peer->sort != BGP_PEER_IBGP)
                        continue;
 
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_CLID_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -508,7 +509,7 @@ void bgp_cluster_id_unset(struct bgp *bgp)
                if (peer->sort != BGP_PEER_IBGP)
                        continue;
 
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_CLID_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -581,7 +582,7 @@ void bgp_confederation_id_set(struct bgp *bgp, as_t as, const char *as_str)
                        if (ptype == BGP_PEER_EBGP) {
                                peer->local_as = as;
                                if (BGP_IS_VALID_STATE_FOR_NOTIF(
-                                           peer->status)) {
+                                           peer->connection.status)) {
                                        peer->last_reset =
                                                PEER_DOWN_CONFED_ID_CHANGE;
                                        bgp_notify_send(
@@ -599,7 +600,7 @@ void bgp_confederation_id_set(struct bgp *bgp, as_t as, const char *as_str)
                                if (ptype == BGP_PEER_EBGP)
                                        peer->local_as = as;
                                if (BGP_IS_VALID_STATE_FOR_NOTIF(
-                                           peer->status)) {
+                                           peer->connection.status)) {
                                        peer->last_reset =
                                                PEER_DOWN_CONFED_ID_CHANGE;
                                        bgp_notify_send(
@@ -626,7 +627,8 @@ void bgp_confederation_id_unset(struct bgp *bgp)
                /* We're looking for peers who's AS is not local */
                if (peer_sort(peer) != BGP_PEER_IBGP) {
                        peer->local_as = bgp->as;
-                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+                       if (BGP_IS_VALID_STATE_FOR_NOTIF(
+                                   peer->connection.status)) {
                                peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE;
                                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                                BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -680,7 +682,7 @@ void bgp_confederation_peers_add(struct bgp *bgp, as_t as, const char *as_str)
                                peer->local_as = bgp->as;
                                (void)peer_sort(peer);
                                if (BGP_IS_VALID_STATE_FOR_NOTIF(
-                                           peer->status)) {
+                                           peer->connection.status)) {
                                        peer->last_reset =
                                                PEER_DOWN_CONFED_PEER_CHANGE;
                                        bgp_notify_send(
@@ -737,7 +739,7 @@ void bgp_confederation_peers_remove(struct bgp *bgp, as_t as)
                                peer->local_as = bgp->confed_id;
                                (void)peer_sort(peer);
                                if (BGP_IS_VALID_STATE_FOR_NOTIF(
-                                           peer->status)) {
+                                           peer->connection.status)) {
                                        peer->last_reset =
                                                PEER_DOWN_CONFED_PEER_CHANGE;
                                        bgp_notify_send(
@@ -1171,7 +1173,7 @@ static void peer_free(struct peer *peer)
        afi_t afi;
        safi_t safi;
 
-       assert(peer->status == Deleted);
+       assert(peer->connection.status == Deleted);
 
        QOBJ_UNREG(peer);
 
@@ -1427,8 +1429,8 @@ struct peer *peer_new(struct bgp *bgp)
        /* Set default value. */
        peer->v_start = BGP_INIT_START_TIMER;
        peer->v_connect = bgp->default_connect_retry;
-       peer->status = Idle;
-       peer->ostatus = Idle;
+       peer->connection.status = Idle;
+       peer->connection.ostatus = Idle;
        peer->cur_event = peer->last_event = peer->last_major_event = 0;
        peer->bgp = bgp_lock(bgp);
        peer = peer_lock(peer); /* initial reference */
@@ -1944,7 +1946,7 @@ void peer_as_change(struct peer *peer, as_t as, int as_specified,
 
        /* Stop peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -2316,7 +2318,8 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi)
                                                BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                        }
                }
-               if (peer->status == OpenSent || peer->status == OpenConfirm) {
+               if (peer->connection.status == OpenSent ||
+                   peer->connection.status == OpenConfirm) {
                        peer->last_reset = PEER_DOWN_AF_ACTIVATE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -2331,9 +2334,8 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi)
                 * activation.
                 */
                other = peer->doppelganger;
-               if (other
-                   && (other->status == OpenSent
-                       || other->status == OpenConfirm)) {
+               if (other && (other->connection.status == OpenSent ||
+                             other->connection.status == OpenConfirm)) {
                        other->last_reset = PEER_DOWN_AF_ACTIVATE;
                        bgp_notify_send(other, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -2554,7 +2556,7 @@ int peer_delete(struct peer *peer)
        struct listnode *pn;
        int accept_peer;
 
-       assert(peer->status != Deleted);
+       assert(peer->connection.status != Deleted);
 
        bgp = peer->bgp;
        accept_peer = CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER);
@@ -2892,7 +2894,7 @@ int peer_group_remote_as(struct bgp *bgp, const char *group_name, as_t *as,
 
 void peer_notify_unconfig(struct peer *peer)
 {
-       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                BGP_NOTIFY_CEASE_PEER_UNCONFIG);
 }
@@ -2907,7 +2909,7 @@ static void peer_notify_shutdown(struct peer *peer)
                return;
        }
 
-       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
 }
@@ -2919,7 +2921,7 @@ void peer_group_notify_unconfig(struct peer_group *group)
 
        for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
                other = peer->doppelganger;
-               if (other && other->status != Deleted) {
+               if (other && other->connection.status != Deleted) {
                        other->group = NULL;
                        peer_notify_unconfig(other);
                } else
@@ -2945,7 +2947,7 @@ int peer_group_delete(struct peer_group *group)
                        bgp_zebra_terminate_radv(bgp, peer);
 
                peer_delete(peer);
-               if (other && other->status != Deleted) {
+               if (other && other->connection.status != Deleted) {
                        other->group = NULL;
                        peer_delete(other);
                }
@@ -2994,7 +2996,7 @@ int peer_group_remote_as_delete(struct peer_group *group)
 
                peer_delete(peer);
 
-               if (other && other->status != Deleted) {
+               if (other && other->connection.status != Deleted) {
                        other->group = NULL;
                        peer_delete(other);
                }
@@ -3174,7 +3176,7 @@ int peer_group_bind(struct bgp *bgp, union sockunion *su, struct peer *peer,
 
                SET_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE);
 
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_RMAP_BIND;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -3730,7 +3732,7 @@ void bgp_instance_down(struct bgp *bgp)
 
        /* Bring down peers, so corresponding routes are purged. */
        for (ALL_LIST_ELEMENTS(bgp->peer, node, next, peer)) {
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
                else
@@ -4413,10 +4415,10 @@ void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,
        if (type == peer_change_reset) {
                /* If we're resetting session, we've to delete both peer struct
                 */
-               if ((peer->doppelganger)
-                   && (peer->doppelganger->status != Deleted)
-                   && (!CHECK_FLAG(peer->doppelganger->flags,
-                                   PEER_FLAG_CONFIG_NODE)))
+               if ((peer->doppelganger) &&
+                   (peer->doppelganger->connection.status != Deleted) &&
+                   (!CHECK_FLAG(peer->doppelganger->flags,
+                                PEER_FLAG_CONFIG_NODE)))
                        peer_delete(peer->doppelganger);
 
                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
@@ -4426,10 +4428,10 @@ void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,
                        bgp_route_refresh_send(peer, afi, safi, 0, 0, 0,
                                               BGP_ROUTE_REFRESH_NORMAL);
                else {
-                       if ((peer->doppelganger)
-                           && (peer->doppelganger->status != Deleted)
-                           && (!CHECK_FLAG(peer->doppelganger->flags,
-                                           PEER_FLAG_CONFIG_NODE)))
+                       if ((peer->doppelganger) &&
+                           (peer->doppelganger->connection.status != Deleted) &&
+                           (!CHECK_FLAG(peer->doppelganger->flags,
+                                        PEER_FLAG_CONFIG_NODE)))
                                peer_delete(peer->doppelganger);
 
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
@@ -4585,7 +4587,8 @@ static void peer_flag_modify_action(struct peer *peer, uint64_t flag)
                                                peer);
                        }
 
-                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+                       if (BGP_IS_VALID_STATE_FOR_NOTIF(
+                                   peer->connection.status)) {
                                char *msg = peer->tx_shutdown_message;
                                size_t msglen;
                                uint8_t msgbuf[BGP_ADMIN_SHUTDOWN_MSG_LEN + 1];
@@ -4615,7 +4618,7 @@ static void peer_flag_modify_action(struct peer *peer, uint64_t flag)
                        peer->v_start = BGP_INIT_START_TIMER;
                        BGP_EVENT_ADD(peer, BGP_Stop);
                }
-       } else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+       } else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                if (flag == PEER_FLAG_DYNAMIC_CAPABILITY)
                        peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
                else if (flag == PEER_FLAG_PASSIVE)
@@ -4652,7 +4655,7 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg)
                        continue;
 
                /* send a RFC 4486 notification message if necessary */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        if (msg) {
                                size_t datalen = strlen(msg);
 
@@ -5074,7 +5077,7 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
 
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                if (peer->sort != BGP_PEER_IBGP) {
-                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                                BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                        else
@@ -5092,7 +5095,7 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
 
                        peer->ttl = group->conf->ttl;
 
-                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                                BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                        else
@@ -5129,7 +5132,7 @@ int peer_ebgp_multihop_unset(struct peer *peer)
        peer->ttl = ttl;
 
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                else
@@ -5147,7 +5150,8 @@ int peer_ebgp_multihop_unset(struct peer *peer)
                        peer->ttl = BGP_DEFAULT_TTL;
 
                        if (peer->connection.fd >= 0) {
-                               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+                               if (BGP_IS_VALID_STATE_FOR_NOTIF(
+                                           peer->connection.status))
                                        bgp_notify_send(
                                                peer, BGP_NOTIFY_CEASE,
                                                BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5302,7 +5306,7 @@ int peer_update_source_if_set(struct peer *peer, const char *ifname)
        /* Check if handling a regular peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5340,7 +5344,7 @@ int peer_update_source_if_set(struct peer *peer, const char *ifname)
                member->update_source = NULL;
 
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
                        member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
                        bgp_notify_send(member, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5373,7 +5377,7 @@ void peer_update_source_addr_set(struct peer *peer, const union sockunion *su)
        /* Check if handling a regular peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5410,7 +5414,7 @@ void peer_update_source_addr_set(struct peer *peer, const union sockunion *su)
                XFREE(MTYPE_PEER_UPDATE_SOURCE, member->update_if);
 
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
                        member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
                        bgp_notify_send(member, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5461,7 +5465,7 @@ void peer_update_source_unset(struct peer *peer)
        /* Check if handling a regular peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -5497,7 +5501,7 @@ void peer_update_source_unset(struct peer *peer)
                XFREE(MTYPE_PEER_UPDATE_SOURCE, member->update_if);
 
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
                        member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
                        bgp_notify_send(member, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -6462,7 +6466,7 @@ int peer_local_as_unset(struct peer *peer)
        /* Check if handling a regular peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Send notification or stop peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
                        peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -6490,7 +6494,7 @@ int peer_local_as_unset(struct peer *peer)
                XFREE(MTYPE_BGP, member->change_local_as_pretty);
 
                /* Send notification or stop peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) {
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
                        member->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
                        bgp_notify_send(member, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
@@ -6522,7 +6526,7 @@ int peer_password_set(struct peer *peer, const char *password)
        /* Check if handling a regular peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                else
@@ -6558,7 +6562,7 @@ int peer_password_set(struct peer *peer, const char *password)
                member->password = XSTRDUP(MTYPE_PEER_PASSWORD, password);
 
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status))
                        bgp_notify_send(member, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                else
@@ -6603,7 +6607,7 @@ int peer_password_unset(struct peer *peer)
        /* Check if handling a regular peer. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                else
@@ -6630,7 +6634,7 @@ int peer_password_unset(struct peer *peer)
                XFREE(MTYPE_PEER_PASSWORD, member->password);
 
                /* Send notification or reset peer depending on state. */
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status))
                        bgp_notify_send(member, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_CONFIG_CHANGE);
                else
@@ -7835,7 +7839,8 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
                                sockopt_minttl(peer->su.sa.sa_family,
                                               peer->connection.fd,
                                               MAXTTL + 1 - gtsm_hops);
-                       if ((peer->status < Established) && peer->doppelganger &&
+                       if ((peer->connection.status < Established) &&
+                           peer->doppelganger &&
                            (peer->doppelganger->connection.fd >= 0))
                                sockopt_minttl(peer->su.sa.sa_family,
                                               peer->doppelganger->connection.fd,
@@ -7861,7 +7866,7 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
                                                       gpeer->connection.fd,
                                                       MAXTTL + 1 -
                                                               gpeer->gtsm_hops);
-                               if ((gpeer->status < Established) &&
+                               if ((gpeer->connection.status < Established) &&
                                    gpeer->doppelganger &&
                                    (gpeer->doppelganger->connection.fd >= 0))
                                        sockopt_minttl(gpeer->su.sa.sa_family,
@@ -7903,7 +7908,8 @@ int peer_ttl_security_hops_unset(struct peer *peer)
                                sockopt_minttl(peer->su.sa.sa_family,
                                               peer->connection.fd, 0);
 
-                       if ((peer->status < Established) && peer->doppelganger &&
+                       if ((peer->connection.status < Established) &&
+                           peer->doppelganger &&
                            (peer->doppelganger->connection.fd >= 0))
                                sockopt_minttl(peer->su.sa.sa_family,
                                               peer->doppelganger->connection.fd,
@@ -7920,7 +7926,7 @@ int peer_ttl_security_hops_unset(struct peer *peer)
                                        sockopt_minttl(peer->su.sa.sa_family,
                                                       peer->connection.fd, 0);
 
-                               if ((peer->status < Established) &&
+                               if ((peer->connection.status < Established) &&
                                    peer->doppelganger &&
                                    (peer->doppelganger->connection.fd >= 0))
                                        sockopt_minttl(peer->su.sa.sa_family,
@@ -7977,7 +7983,7 @@ int peer_clear(struct peer *peer, struct listnode **nnode)
                        return 0;
 
                peer->v_start = BGP_INIT_START_TIMER;
-               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                        bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                        BGP_NOTIFY_CEASE_ADMIN_RESET);
                else
@@ -8280,8 +8286,8 @@ static int peer_unshut_after_cfg(struct bgp *bgp)
                                   peer->host);
 
                peer->shut_during_cfg = false;
-               if (peer_active(peer) && peer->status != Established) {
-                       if (peer->status != Idle)
+               if (peer_active(peer) && peer->connection.status != Established) {
+                       if (peer->connection.status != Idle)
                                BGP_EVENT_ADD(peer, BGP_Stop);
                        BGP_EVENT_ADD(peer, BGP_Start);
                }
@@ -8382,7 +8388,7 @@ void bgp_terminate(void)
                                                peer);
                                continue;
                        }
-                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+                       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
                                bgp_notify_send(peer, BGP_NOTIFY_CEASE,
                                                BGP_NOTIFY_CEASE_PEER_UNCONFIG);
                }
index dcee9caec89929e237916de6c843d3d484ca1f4e..5215c6a08dec15759c649fc3cf0bc0d0e5e39e8e 100644 (file)
@@ -1123,6 +1123,10 @@ struct llgr_info {
 struct peer_connection {
        struct peer *peer;
 
+       /* Status of the peer connection. */
+       enum bgp_fsm_status status;
+       enum bgp_fsm_status ostatus;
+
        int fd;
 
        /* Packet receive and send buffer. */
@@ -1187,10 +1191,6 @@ struct peer {
        /* the doppelganger peer structure, due to dual TCP conn setup */
        struct peer *doppelganger;
 
-       /* Status of the peer. */
-       enum bgp_fsm_status status;
-       enum bgp_fsm_status ostatus;
-
        /* FSM events, stored for debug purposes.
         * Note: uchar used for reduced memory usage.
         */
@@ -2594,7 +2594,7 @@ static inline char *timestamp_string(time_t ts)
 
 static inline bool peer_established(struct peer *peer)
 {
-       return peer->status == Established;
+       return peer->connection.status == Established;
 }
 
 static inline bool peer_dynamic_neighbor(struct peer *peer)
index d24a07cd8a829bc8c7fd50009c8643a66be03404..6e99c74bcb6a207556e7e2a20b4183cd9aa62646 100644 (file)
@@ -1236,7 +1236,7 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp,
         * Fill in BGP peer structure
         */
        rfd->peer = peer_new(bgp);
-       rfd->peer->status = Established; /* keep bgp core happy */
+       rfd->peer->connection.status = Established; /* keep bgp core happy */
 
        bgp_peer_connection_buffers_free(&rfd->peer->connection);
 
index 8a30edce91ca854c9e5c68386463c4bead190e06..4fd057e848d75243790107356d65217f5ce3f2a0 100644 (file)
@@ -171,7 +171,7 @@ static void vnc_redistribute_add(struct prefix *p, uint32_t metric,
                         * Same setup as in rfapi_open()
                         */
                        vncHD1VR.peer = peer_new(bgp);
-                       vncHD1VR.peer->status =
+                       vncHD1VR.peer->connection.status =
                                Established; /* keep bgp core happy */
 
                        bgp_peer_connection_buffers_free(
index da17471fd181e828e2f6f2e7c132fa9e202406af..6b6d9107151f908f02f315cc0eddfca103704a3e 100644 (file)
@@ -972,7 +972,7 @@ int main(void)
                parse_test(peer, &opt_params[i++], OPT_PARAM);
 
        SET_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV);
-       peer->status = Established;
+       peer->connection.status = Established;
 
        i = 0;
        while (dynamic_cap_msgs[i].name)
index ae7903e0ccfc4adf7041972be539d522aa896018..29c706676c34cb236408a1807bc931127d6d85ac 100644 (file)
@@ -1085,7 +1085,7 @@ int main(void)
 
        peer = peer_create_accept(bgp);
        peer->host = (char *)"foo";
-       peer->status = Established;
+       peer->connection.status = Established;
        peer->curr = stream_new(BGP_MAX_PACKET_SIZE);
 
        ifp.ifindex = 0;
index 8d943e5aef9c7d6493be308b2dd2ff65cc08a5bd..638852f37c47e41650601e19eee24f56bf33af59 100644 (file)
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
                }
 
        SET_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV);
-       peer->status = Established;
+       peer->connection.status = Established;
 
        peer->connection.fd = open(argv[1], O_RDONLY | O_NONBLOCK);
        t.arg = peer;