diff options
-rw-r--r-- | bgpd/bgp_common.h | 16 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_msg_read.c | 50 | ||||
-rw-r--r-- | bgpd/bgp_msg_read.h | 2 | ||||
-rw-r--r-- | bgpd/bgp_open.h | 2 | ||||
-rw-r--r-- | bgpd/bgp_open_state.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_peer.c | 70 | ||||
-rw-r--r-- | bgpd/bgp_peer.h | 10 | ||||
-rw-r--r-- | bgpd/bgp_session.c | 46 | ||||
-rw-r--r-- | bgpd/bgp_session.h | 3 | ||||
-rw-r--r-- | bgpd/bgpd.c | 292 |
11 files changed, 240 insertions, 255 deletions
diff --git a/bgpd/bgp_common.h b/bgpd/bgp_common.h index 65f2476c..52d29998 100644 --- a/bgpd/bgp_common.h +++ b/bgpd/bgp_common.h @@ -76,9 +76,10 @@ enum bgp_session_states bgp_session_sEnabled = 1, /* attempting to connect */ bgp_session_sEstablished = 2, - bgp_session_sStopped = 3, /* for whatever reason */ + bgp_session_sStopping = 3, /* for whatever reason */ + bgp_session_sStopped = 4, /* for whatever reason */ - bgp_session_max_state = 3 + bgp_session_max_state = 4 } ; typedef enum bgp_session_events bgp_session_event_t ; @@ -113,6 +114,17 @@ enum bgp_session_events bgp_session_eDiscard, /* discarded by sibling */ } ; +typedef enum bgp_peer_states bgp_peer_state_t ; +enum bgp_peer_states +{ + bgp_peer_min_state = 0, + + bgp_peer_disabled = 0, /* peer disabled */ + bgp_peer_enabled = 1, /* peer enabled */ + + bgp_peer_max_state = 1 +} ; + /*============================================================================== * Other common types and .... */ diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index c53aaba2..c7eca751 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -551,7 +551,7 @@ main (int argc, char **argv) qpn_exec(cli_nexus); /* must be last to start - on main thread */ /* terminating, wait for all threads to finish */ - /* TOD: join with routing_nexus */ + /* TODO: join with routing_nexus */ /* thread_result = qpt_thread_join(routing_nexus->thread_id); */ thread_result = qpt_thread_join(bgp_nexus->thread_id); bgp_exit(0); diff --git a/bgpd/bgp_msg_read.c b/bgpd/bgp_msg_read.c index 020f2f0c..98b21d23 100644 --- a/bgpd/bgp_msg_read.c +++ b/bgpd/bgp_msg_read.c @@ -749,6 +749,10 @@ bgp_msg_capability_parse (bgp_connection connection, size_t length, u_char **err memcpy (*error, sp, caphdr.length + 2); *error += caphdr.length + 2; } + + /* Add given unknown capability and its value */ + bgp_open_state_unknown_add(open_recv, caphdr.code, + stream_pnt (s), caphdr.length); } if (stream_get_getp(s) != (start + caphdr.length)) { @@ -802,6 +806,7 @@ bgp_msg_capability_restart (bgp_connection connection, struct capability_header struct stream *s = connection->ibuf; bgp_session session = connection->session; bgp_open_state open_recv = session->open_recv; + bgp_open_state open_send = session->open_send; u_int16_t restart_flag_time; int restart_bit = 0; size_t end = stream_get_getp (s) + caphdr->length; @@ -821,8 +826,6 @@ bgp_msg_capability_restart (bgp_connection connection, struct capability_header open_recv->restart_time); } - /* TODO restart */ -#if 0 while (stream_get_getp (s) + 4 < end) { afi_t afi = stream_getw (s); @@ -834,31 +837,34 @@ bgp_msg_capability_restart (bgp_connection connection, struct capability_header if (BGP_DEBUG (normal, NORMAL)) zlog_debug ("%s Addr-family %d/%d(afi/safi) not supported." " Ignore the Graceful Restart capability", - peer->host, afi, safi); - } - else if (!peer->afc[afi][safi]) - { - if (BGP_DEBUG (normal, NORMAL)) - zlog_debug ("%s Addr-family %d/%d(afi/safi) not enabled." - " Ignore the Graceful Restart capability", - peer->host, afi, safi); + session->host, afi, safi); } else { - if (BGP_DEBUG (normal, NORMAL)) - zlog_debug ("%s Address family %s is%spreserved", peer->host, - afi_safi_print (afi, safi), - CHECK_FLAG (peer->af_cap[afi][safi], - PEER_CAP_RESTART_AF_PRESERVE_RCV) - ? " " : " not "); - - SET_FLAG (peer->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV); - if (CHECK_FLAG (flag, RESTART_F_BIT)) - SET_FLAG (peer->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV); - + qafx_bit_t qb = qafx_bit(qafx_num_from_qAFI_qSAFI(afi, safi)); + + if (!(open_send->can_mp_ext & qb)) + { + if (BGP_DEBUG (normal, NORMAL)) + zlog_debug ("%s Addr-family %d/%d(afi/safi) not enabled." + " Ignore the Graceful Restart capability", + session->host, afi, safi); + } + else + { + if (BGP_DEBUG (normal, NORMAL)) + zlog_debug ("%s Address family %s is%spreserved", session->host, + afi_safi_print (afi, safi), + CHECK_FLAG (flag, RESTART_F_BIT) + ? " " : " not "); + + open_recv->can_preserve |= qb; + if (CHECK_FLAG (flag, RESTART_F_BIT)) + open_recv->has_preserved |= qb; + } } } -#endif + return 0; } diff --git a/bgpd/bgp_msg_read.h b/bgpd/bgp_msg_read.h index f1d3f188..cc1272e8 100644 --- a/bgpd/bgp_msg_read.h +++ b/bgpd/bgp_msg_read.h @@ -23,7 +23,7 @@ #ifndef BGP_MSG_READ_H_ #define BGP_MSG_READ_H_ -#include "bgpd/bgp_session.h" +#include "bgpd/bgp_common.h" extern int bgp_msg_check_header(bgp_connection connection); diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h index edd29733..9139c550 100644 --- a/bgpd/bgp_open.h +++ b/bgpd/bgp_open.h @@ -22,6 +22,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define _QUAGGA_BGP_OPEN_H #include "log.h" +#include "stream.h" +#include "vty.h" /* Standard header for capability TLV */ struct capability_header diff --git a/bgpd/bgp_open_state.c b/bgpd/bgp_open_state.c index ada4ee70..9d86e03f 100644 --- a/bgpd/bgp_open_state.c +++ b/bgpd/bgp_open_state.c @@ -302,7 +302,7 @@ bgp_peer_open_state_receive(bgp_peer peer) for (safi = qSAFI_min ; safi <= qSAFI_max ; ++safi) { qafx_bit_t qb = qafx_bit(qafx_num_from_qAFI_qSAFI(afi, safi)); - if (peer->afc[afi][safi] && (qb & open_recv->can_preserve)) + if (peer->afc[afi][safi] && (qb & open_recv->can_g_restart)) { SET_FLAG (peer->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV); if (qb & open_recv->has_preserved) diff --git a/bgpd/bgp_peer.c b/bgpd/bgp_peer.c index 9e9f8b06..d154fa26 100644 --- a/bgpd/bgp_peer.c +++ b/bgpd/bgp_peer.c @@ -122,28 +122,22 @@ bgp_session_do_event(mqueue_block mqb, mqb_flag_t flag) { BGP_SESSION_LOCK(session) ; - switch(args->state) + switch(args->event) { - /* If now Enabled, then the BGP Engine is attempting to connect */ - /* (may be waiting for the Idle Hold Time to expire. */ - case bgp_session_sEnabled: - bgp_session_enable(peer); - break ; - /* If now Established, then the BGP Engine has exchanged BGP Open */ /* messages, and received the KeepAlive that acknowledges our Open. */ - case bgp_session_sEstablished: - bgp_session_has_established(peer); + case bgp_session_eEstablished: + if (args->state == bgp_session_sEstablished) + bgp_session_has_established(peer); break ; + default: /* If now Stopped, then for some reason the BGP Engine has either */ /* stopped trying to connect, or the session has been stopped. */ - case bgp_session_sStopped: - bgp_session_has_stopped(peer); + if (args->state == bgp_session_sStopped) + bgp_session_has_stopped(peer); break ; - default: - break; } BGP_SESSION_UNLOCK(session) ; @@ -267,10 +261,26 @@ bgp_session_has_established(bgp_peer peer) return 0; } +/* State change to stopped, session mutex locked */ +static int +bgp_session_has_stopped(bgp_peer peer) +{ + bgp_session session = peer->session; + + /* does the session need to be re-enabled? */ + if (session->defer_enable) + { + session->defer_enable = 0; + bpg_session_enable(peer); + } + + return 0; +} + /* Administrative BGP peer stop event. */ /* May be called multiple times for the same peer */ static int -bgp_session_has_stopped(bgp_peer peer) +bgp_peer_stop (struct peer *peer) { afi_t afi; safi_t safi; @@ -895,3 +905,35 @@ peer_free (struct peer *peer) XFREE (MTYPE_BGP_PEER, peer); } + +/* Config change, disable then re-enable the peer */ +void +bgp_peer_config_change(bgp_peer peer, bgp_notify notification) +{ + bgp_peer_disable(peer, notification); + bgp_peer_enable(peer); /* may defer if still stopping */ +} + +/* enable the peer */ + +void +bgp_peer_enable(bgp_peer peer) +{ + /* enable the session */ + bgp_session_enable(peer); + peer->state = bgp_peer_enabled; +} + +/* disable the peer + * sent notification, disable session, stop the peer + */ +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); + peer->state = bgp_peer_disabled; +} diff --git a/bgpd/bgp_peer.h b/bgpd/bgp_peer.h index 43a89e12..27cfae68 100644 --- a/bgpd/bgp_peer.h +++ b/bgpd/bgp_peer.h @@ -154,6 +154,7 @@ struct peer /* Status of the peer. */ int status; int ostatus; + bgp_peer_state_t state; /* Peer index, used for dumping TABLE_DUMP_V2 format */ uint16_t table_dump_index; @@ -470,6 +471,15 @@ extern const char *peer_down_str[]; extern void bgp_session_do_event(mqueue_block mqb, mqb_flag_t flag); +void +bgp_peer_config_change(bgp_peer peer, bgp_notify notification); + +extern void +bgp_peer_enable(bgp_peer peer); + +extern void +bgp_peer_disable(bgp_peer peer, bgp_notify notification); + extern struct peer * peer_new (struct bgp *bgp); diff --git a/bgpd/bgp_session.c b/bgpd/bgp_session.c index 3f6333fa..25615f99 100644 --- a/bgpd/bgp_session.c +++ b/bgpd/bgp_session.c @@ -29,6 +29,10 @@ #include "lib/memory.h" #include "lib/sockunion.h" +/* prototypes */ +static int +bgp_session_defer_if_stopping(bgp_session session); + /*============================================================================== * BGP Session. * @@ -182,7 +186,7 @@ bgp_session_free(bgp_session session) static void bgp_session_do_enable(mqueue_block mqb, mqb_flag_t flag) ; -extern void +void bgp_session_enable(bgp_peer peer) { bgp_session session ; @@ -204,12 +208,16 @@ bgp_session_enable(bgp_peer peer) else { assert(session->peer == peer) ; + /* if session is stopping then defer the enable */ + if (bgp_session_defer_if_stopping(session)) + return; assert(!bgp_session_is_active(session)) ; } ; /* Initialise what we need to make and run connections */ session->state = bgp_session_sIdle; session->made = 0; + session->defer_enable = 0; session->event = bgp_session_null_event; bgp_notify_free(&session->notification); session->err = 0; @@ -300,6 +308,7 @@ bgp_session_disable(bgp_peer peer, bgp_notify notification) { bgp_session session ; mqueue_block mqb ; + struct bgp_session_disable_args* args ; session = peer->session ; assert((session != NULL) && (session->peer == peer)) ; @@ -328,25 +337,31 @@ bgp_session_disable(bgp_peer peer, bgp_notify notification) */ mqb = mqb_init_new(NULL, bgp_session_do_disable, session) ; - confirm(sizeof(struct bgp_session_enable_args) == 0) ; + args = mqb_get_args(mqb) ; + args->notification = notification ; bgp_to_bgp_engine_priority(mqb) ; } ; /*------------------------------------------------------------------------------ - * BGP Engine: session enable message action + * BGP Engine: session disable message action */ static void bgp_session_do_disable(mqueue_block mqb, mqb_flag_t flag) { if (flag == mqb_action) { + bgp_session session = mqb_get_arg0(mqb) ; + struct bgp_session_disable_args* args = mqb_get_args(mqb) ; + session->state = bgp_session_sStopping; + /* TODO: disable session */ + bgp_notify_free(&args->notification) ; /* discard any bgp_notify */ } ; mqb_free(mqb) ; -} ; +} /*============================================================================== * Send session event signal from BGP Engine to Routeing Engine @@ -463,3 +478,26 @@ bgp_session_is_active(bgp_session session) return active ; } ; + +/*------------------------------------------------------------------------------ + * If session is stopping we defer re-enabling the session until it has stopped. + * + * returns 1 if stopping and defer + * returns 0 if not stopping + */ +static int +bgp_session_defer_if_stopping(bgp_session session) +{ + int defer_enable = 0 ; + + if (session == NULL) + return defer_enable; + + BGP_SESSION_LOCK(session) ; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ + + session->defer_enable = defer_enable = (session->state == bgp_session_sStopping); + + BGP_SESSION_UNLOCK(session) ; /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ + + return defer_enable ; +} ; diff --git a/bgpd/bgp_session.h b/bgpd/bgp_session.h index cd4bf107..193e1936 100644 --- a/bgpd/bgp_session.h +++ b/bgpd/bgp_session.h @@ -112,7 +112,8 @@ struct bgp_session * session was ever established. */ bgp_session_state_t state ; - flag_t made ; /* set when -> sEstablished */ + flag_t made ; /* set when -> sEstablished */ + int defer_enable ; /* set when waiting for stop */ /* The BGP Engine records the last event, NOTIFICATION and errno here. * diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index f2e33a46..060f850b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -292,15 +292,9 @@ bgp_confederation_id_set (struct bgp *bgp, as_t as) if (peer_sort (peer) == BGP_PEER_EBGP) { peer->local_as = as; - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } } else @@ -312,14 +306,9 @@ bgp_confederation_id_set (struct bgp *bgp, as_t as) /* Reset the local_as to be our EBGP one */ if (peer_sort (peer) == BGP_PEER_EBGP) peer->local_as = as; - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } } } @@ -341,15 +330,9 @@ bgp_confederation_id_unset (struct bgp *bgp) if (peer_sort (peer) != BGP_PEER_IBGP) { peer->local_as = bgp->as; - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } } return 0; @@ -405,14 +388,9 @@ bgp_confederation_peers_add (struct bgp *bgp, as_t as) if (peer->as == as) { peer->local_as = bgp->as; - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } } } @@ -461,14 +439,9 @@ bgp_confederation_peers_remove (struct bgp *bgp, as_t as) if (peer->as == as) { peer->local_as = bgp->confed_id; - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } } } @@ -750,14 +723,9 @@ peer_as_change (struct peer *peer, as_t as) /* Stop peer. */ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } type = peer_sort (peer); peer->as = as; @@ -892,9 +860,11 @@ peer_activate (struct peer *peer, afi_t afi, safi_t safi) peer->afc[afi][safi] = 1; if (! active && peer_active (peer)) - bgp_timer_set (peer); + bgp_peer_enable (peer); else - { +#if 0 + /* TODO: Dynamic capability */ + { if (peer->status == Established) { if (CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV)) @@ -910,13 +880,16 @@ peer_activate (struct peer *peer, afi_t afi, safi_t safi) } } else +#endif { peer->last_reset = PEER_DOWN_AF_ACTIVATE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } +#if 0 } } +#endif } return 0; } @@ -1154,8 +1127,6 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer, else peer->password = NULL; - bgp_md5_set (peer); - /* maximum-prefix */ peer->pmax[afi][safi] = conf->pmax[afi][safi]; peer->pmax_threshold[afi][safi] = conf->pmax_threshold[afi][safi]; @@ -1546,14 +1517,9 @@ peer_group_bind (struct bgp *bgp, union sockunion *su, peer_group2peer_config_copy (group, peer, afi, safi); - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_RMAP_BIND; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_RMAP_BIND; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -1589,15 +1555,9 @@ peer_group_unbind (struct bgp *bgp, struct peer *peer, peer_global_config_reset (peer); } - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_RMAP_UNBIND; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); - + peer->last_reset = PEER_DOWN_RMAP_UNBIND; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -1732,13 +1692,6 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name) } } - /* Create BGP server socket, if first instance. */ - if (list_isempty(bm->bgp)) - { - if (bgp_socket (bm->port, bm->address) < 0) - return BGP_ERR_INVALID_VALUE; - } - bgp = bgp_create (as, name); listnode_add (bm->bgp, bgp); bgp_router_id_set(bgp, &router_id_zebra); @@ -1784,8 +1737,6 @@ bgp_delete (struct bgp *bgp) * routes to be processed still referencing the struct bgp. */ listnode_delete (bm->bgp, bgp); - if (list_isempty(bm->bgp)) - bgp_close (); bgp_unlock(bgp); /* initial reference */ @@ -2076,22 +2027,19 @@ peer_flag_modify_action (struct peer *peer, u_int32_t flag) peer->host); } - if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)) - peer_nsf_stop (peer); + if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)) + peer_nsf_stop (peer); - if (peer->status == Established) - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN); - else - BGP_EVENT_ADD (peer, BGP_Stop); + bgp_peer_disable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, 0)); } else { peer->v_start = BGP_INIT_START_TIMER; - BGP_EVENT_ADD (peer, BGP_Stop); + bgp_peer_disable(peer, NULL); } } - else if (peer->status == Established) + else { if (flag == PEER_FLAG_DYNAMIC_CAPABILITY) peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE; @@ -2100,11 +2048,9 @@ peer_flag_modify_action (struct peer *peer, u_int32_t flag) else if (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK) peer->last_reset = PEER_DOWN_MULTIHOP_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } - else - BGP_EVENT_ADD (peer, BGP_Stop); } /* Change specified peer flag. */ @@ -2471,14 +2417,9 @@ peer_update_source_if_set (struct peer *peer, const char *ifname) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -2503,14 +2444,9 @@ peer_update_source_if_set (struct peer *peer, const char *ifname) peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, ifname); - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } return 0; } @@ -2540,14 +2476,9 @@ peer_update_source_addr_set (struct peer *peer, union sockunion *su) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -2571,14 +2502,9 @@ peer_update_source_addr_set (struct peer *peer, union sockunion *su) peer->update_source = sockunion_dup (su); - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } return 0; } @@ -2622,14 +2548,9 @@ peer_update_source_unset (struct peer *peer) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -2652,14 +2573,9 @@ peer_update_source_unset (struct peer *peer) peer->update_if = NULL; } - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } return 0; } @@ -3081,15 +2997,9 @@ peer_local_as_set (struct peer *peer, as_t as, int no_prepend) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); - + peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -3102,14 +3012,9 @@ peer_local_as_set (struct peer *peer, as_t as, int no_prepend) else UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } return 0; @@ -3132,15 +3037,9 @@ peer_local_as_unset (struct peer *peer) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); - + peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); return 0; } @@ -3150,14 +3049,9 @@ peer_local_as_unset (struct peer *peer) peer->change_local_as = 0; UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); - if (peer->status == Established) - { - peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE); - } - else - BGP_EVENT_ADD (peer, BGP_Stop); + peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } return 0; } @@ -3184,12 +3078,9 @@ peer_password_set (struct peer *peer, const char *password) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->status == Established) - bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); - else - BGP_EVENT_ADD (peer, BGP_Stop); - - return (bgp_md5_set (peer) >= 0) ? BGP_SUCCESS : BGP_ERR_TCPSIG_FAILED; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + return BGP_SUCCESS; } for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer)) @@ -3202,13 +3093,8 @@ peer_password_set (struct peer *peer, const char *password) peer->password = XSTRDUP(MTYPE_PEER_PASSWORD, password); - if (peer->status == Established) - bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); - else - BGP_EVENT_ADD (peer, BGP_Stop); - - if (bgp_md5_set (peer) < 0) - ret = BGP_ERR_TCPSIG_FAILED; + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); } return ret; @@ -3230,18 +3116,13 @@ peer_password_unset (struct peer *peer) && strcmp (peer->group->conf->password, peer->password) == 0) return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; - if (peer->status == Established) - bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); - else - BGP_EVENT_ADD (peer, BGP_Stop); + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); if (peer->password) XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; - - bgp_md5_set (peer); - return 0; } @@ -3253,15 +3134,11 @@ peer_password_unset (struct peer *peer) if (!peer->password) continue; - if (peer->status == Established) - bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); - else - BGP_EVENT_ADD (peer, BGP_Stop); + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; - - bgp_md5_set (peer); } return 0; @@ -3984,7 +3861,7 @@ peer_clear (struct peer *peer) { BGP_TIMER_OFF (peer->t_pmax_restart); if (BGP_DEBUG (events, EVENTS)) - zlog_debug ("%s Maximum-prefix restart timer canceled", + zlog_debug ("%s Maximum-prefix restart timer cancelled", peer->host); } BGP_EVENT_ADD (peer, BGP_Start); @@ -3992,11 +3869,8 @@ peer_clear (struct peer *peer) } peer->v_start = BGP_INIT_START_TIMER; - if (peer->status == Established) - bgp_notify_send (peer, BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_ADMIN_RESET); - else - BGP_EVENT_ADD (peer, BGP_Stop); + bgp_peer_config_change(peer, bgp_notify_new(BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_ADMIN_RESET, 0)); } return 0; } |