diff options
author | paulo <paul@bayleaf.org.uk> | 2010-02-04 18:26:42 +0000 |
---|---|---|
committer | paulo <paul@bayleaf.org.uk> | 2010-02-04 18:26:42 +0000 |
commit | 4b2c10c2f5c483c7e6f9a8007a6f09acb7fcaf6b (patch) | |
tree | 780441de6743613d76c534e48e900a557c42d4a2 | |
parent | c7e46768ad62e4b9cdcef28095fa2bce55ef7cc1 (diff) | |
download | quagga-4b2c10c2f5c483c7e6f9a8007a6f09acb7fcaf6b.tar.bz2 quagga-4b2c10c2f5c483c7e6f9a8007a6f09acb7fcaf6b.tar.xz |
Recover lost bgp_peer.c Changed bgp_terminate to set
PEER_STATE_SHUTDOWN and to not attempt to re-enable session if set.
-rw-r--r-- | bgpd/bgp_peer.c | 56 | ||||
-rw-r--r-- | bgpd/bgpd.c | 3 |
2 files changed, 24 insertions, 35 deletions
diff --git a/bgpd/bgp_peer.c b/bgpd/bgp_peer.c index 934bd7cb..31deb57f 100644 --- a/bgpd/bgp_peer.c +++ b/bgpd/bgp_peer.c @@ -302,7 +302,7 @@ bgp_session_has_stopped(bgp_peer peer) bgp_session session = peer->session ; assert(bgp_session_is_active(session)) ; - bgp_peer_reenable(peer, NULL); + bgp_peer_disable(peer, NULL); /* TODO: needs to deal with NOTIFICATION, if any ?? */ return 0; @@ -326,11 +326,20 @@ bgp_session_has_disabled(bgp_peer peer) mqueue_revoke(routing_nexus->queue, session) ; /* does the session need to be re-enabled? */ - if (session->defer_enable) + if ((session->defer_enable || peer->state == bgp_peer_sIdle) + && !CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN) + && !CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { session->defer_enable = 0; bgp_session_enable(peer); } + else if (peer->state == bgp_peer_sEstablished) + { + /* disable the peer */ + bgp_peer_stop(peer); + bgp_clear_route_all(peer); + peer_change_status(peer, bgp_peer_sClearing); + } /* if the program is terminating then see if this was the last session * and if so ... die .... @@ -449,12 +458,14 @@ bgp_peer_stop (struct peer *peer) peer->v_holdtime = peer->bgp->default_holdtime; } +#if 0 /* Reset prefix count */ peer->pcount[AFI_IP][SAFI_UNICAST] = 0; peer->pcount[AFI_IP][SAFI_MULTICAST] = 0; peer->pcount[AFI_IP][SAFI_MPLS_VPN] = 0; peer->pcount[AFI_IP6][SAFI_UNICAST] = 0; peer->pcount[AFI_IP6][SAFI_MULTICAST] = 0; +#endif return 0; } @@ -819,6 +830,7 @@ peer_delete (struct peer *peer) */ peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE; bgp_peer_stop (peer); + bgp_clear_route_all(peer); peer_change_status (peer, bgp_peer_sDeleted); /* Password configuration */ @@ -986,22 +998,7 @@ peer_nsf_stop (struct peer *peer) bgp_clear_route_all (peer); } - -/* Disable then enable the peer. Sends notification. */ -void -bgp_peer_reenable(bgp_peer peer, bgp_notify notification) -{ - if (bgp_session_is_active(peer->session)) - { - bgp_peer_disable(peer, notification); - bgp_peer_enable(peer); /* may defer if still stopping */ - } - else - bgp_notify_free(notification) ; -} - /* enable the peer */ - void bgp_peer_enable(bgp_peer peer) { @@ -1010,33 +1007,26 @@ bgp_peer_enable(bgp_peer peer) } /* disable the peer - * sent notification, disable session, stop the peer + * sent notification, disable session */ void bgp_peer_disable(bgp_peer peer, bgp_notify notification) { - /* disable the session */ - bgp_session_disable(peer, notification); - - /* and the peer */ - bgp_peer_stop(peer); - if (peer->state == bgp_peer_sEstablished) - peer_change_status (peer, bgp_peer_sClearing); + if (bgp_session_is_active(peer->session)) + bgp_session_disable(peer, notification); + else + { + bgp_notify_free(notification) ; + bgp_peer_stop(peer); + } } -/* Called after event occurred, this function change status and reset - read/write and timer thread. */ +/* Called after event occurred, this function changes status */ void peer_change_status (bgp_peer peer, int status) { bgp_dump_state (peer, peer->state, status); - /* Transition into Clearing or Deleted must /always/ clear all routes.. - * (and must do so before actually changing into Deleted.. - */ - if (status >= bgp_peer_sClearing) - bgp_clear_route_all (peer); - /* Preserve old status and change into new status. */ peer->ostate = peer->state; peer->state = status; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 2ea4d798..a3b73d74 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4716,8 +4716,7 @@ bgp_terminate (int terminating, int retain_mode) if (retain_mode) bgp_peer_disable(peer, NULL); else if (terminating) - bgp_notify_send(peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN); + peer_flag_set(peer, PEER_FLAG_SHUTDOWN); else bgp_notify_send(peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_ADMIN_RESET); |