diff options
-rw-r--r-- | bgpd/bgp_packet.c | 24 | ||||
-rw-r--r-- | bgpd/bgp_packet.h | 2 | ||||
-rw-r--r-- | bgpd/bgp_peer.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_peer.h | 2 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 19 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 2 | ||||
-rw-r--r-- | bgpd/bgpd.c | 108 |
7 files changed, 88 insertions, 75 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index cb696b9c..cd36723d 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -819,9 +819,9 @@ bgp_open_send (struct peer *peer) } #endif -/* Send BGP notify packet with data potion. */ -void -bgp_notify_send_with_data (struct peer *peer, u_char code, u_char sub_code, +/* Generate notification object */ +static bgp_notify +bgp_notification (struct peer *peer, u_char code, u_char sub_code, u_char *data, size_t datalen) { bgp_notify notification; @@ -846,7 +846,23 @@ bgp_notify_send_with_data (struct peer *peer, u_char code, u_char sub_code, peer->last_reset = PEER_DOWN_NOTIFY_SEND; } - bgp_peer_reenable(peer, notification); + return notification; +} + +/* Send BGP notify packet with data portion. Reenable peer*/ +void +bgp_notify_send_with_data (struct peer *peer, u_char code, u_char sub_code, + u_char *data, size_t datalen) +{ + bgp_peer_reenable(peer, bgp_notification(peer, code, sub_code, data, datalen)); +} + +/* Send BGP notify packet with data portion. Disable peer*/ +void +bgp_notify_send_with_data_disable (struct peer *peer, u_char code, u_char sub_code, + u_char *data, size_t datalen) +{ + bgp_peer_disable(peer, bgp_notification(peer, code, sub_code, data, datalen)); } /* Send BGP notify packet. */ diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h index 81937522..2b50f986 100644 --- a/bgpd/bgp_packet.h +++ b/bgpd/bgp_packet.h @@ -51,6 +51,8 @@ extern void bgp_open_send (struct peer *); extern void bgp_notify_send (struct peer *, u_int8_t, u_int8_t); extern void bgp_notify_send_with_data (struct peer *, u_int8_t, u_int8_t, u_int8_t *, size_t); +extern void bgp_notify_send_with_data_disable (struct peer *peer, u_char code, u_char sub_code, + u_char *data, size_t datalen); extern void bgp_route_refresh_send (struct peer *, afi_t, safi_t, u_char, u_char, int); extern void bgp_capability_send (struct peer *, afi_t, safi_t, int, int); extern void bgp_default_update_send (struct peer *, struct attr *, diff --git a/bgpd/bgp_peer.c b/bgpd/bgp_peer.c index be63844a..54e84e49 100644 --- a/bgpd/bgp_peer.c +++ b/bgpd/bgp_peer.c @@ -413,10 +413,6 @@ bgp_peer_stop (struct peer *peer) peer->synctime = 0; } - /* Stop read and write threads when exists. */ - BGP_READ_OFF (peer->t_read); - BGP_WRITE_OFF (peer->t_write); - /* Stop all timers. */ BGP_TIMER_OFF (peer->t_asorig); BGP_TIMER_OFF (peer->t_routeadv); @@ -931,8 +927,6 @@ peer_free (struct peer *peer) * but just to be sure.. */ bgp_timer_set (peer); - BGP_READ_OFF (peer->t_read); - BGP_WRITE_OFF (peer->t_write); BGP_EVENT_FLUSH (peer); /* unregister */ diff --git a/bgpd/bgp_peer.h b/bgpd/bgp_peer.h index d16de92d..de0be84f 100644 --- a/bgpd/bgp_peer.h +++ b/bgpd/bgp_peer.h @@ -293,8 +293,6 @@ struct peer u_int32_t v_gr_restart; /* Threads. */ - struct thread *t_read; - struct thread *t_write; struct thread *t_asorig; struct thread *t_routeadv; struct thread *t_pmax_restart; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index d592e970..37a39ffc 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1721,22 +1721,23 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, ndata[6] = (peer->pmax[afi][safi]); SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); - bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, + /* Disable the peer, the timer routine will reenable. */ + bgp_notify_send_with_data_disable (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); } /* restart timer start */ if (peer->pmax_restart[afi][safi]) - { - peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; + { + peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; - if (BGP_DEBUG (events, EVENTS)) - zlog_debug ("%s Maximum-prefix restart timer started for %d secs", - peer->host, peer->v_pmax_restart); + if (BGP_DEBUG (events, EVENTS)) + zlog_debug ("%s Maximum-prefix restart timer started for %d secs", + peer->host, peer->v_pmax_restart); - BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, - peer->v_pmax_restart); - } + BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, + peer->v_pmax_restart); + } return 1; } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1f29f6c2..f0462236 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7615,10 +7615,12 @@ bgp_show_peer (struct vty *vty, struct peer *p) thread_timer_remain_second (p->t_connect), VTY_NEWLINE); #endif +#if 0 vty_out (vty, "Read thread: %s Write thread: %s%s", p->t_read ? "on" : "off", p->t_write ? "on" : "off", VTY_NEWLINE); +#endif if (p->notify != NULL && p->notify->code == BGP_NOTIFY_OPEN_ERR && p->notify->subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index f62ee4b4..0604da8c 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -301,8 +301,8 @@ bgp_confederation_id_set (struct bgp *bgp, as_t as) { peer->local_as = as; peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } else @@ -315,8 +315,8 @@ bgp_confederation_id_set (struct bgp *bgp, as_t as) if (peer_sort (peer) == BGP_PEER_EBGP) peer->local_as = as; peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } } @@ -339,8 +339,8 @@ bgp_confederation_id_unset (struct bgp *bgp) { peer->local_as = bgp->as; peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } return 0; @@ -397,8 +397,8 @@ bgp_confederation_peers_add (struct bgp *bgp, as_t as) { peer->local_as = bgp->as; peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } } @@ -448,8 +448,8 @@ bgp_confederation_peers_remove (struct bgp *bgp, as_t as) { peer->local_as = bgp->confed_id; peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } } @@ -732,8 +732,8 @@ peer_as_change (struct peer *peer, as_t as) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } type = peer_sort (peer); peer->as = as; @@ -891,8 +891,8 @@ peer_activate (struct peer *peer, afi_t afi, safi_t safi) #endif { peer->last_reset = PEER_DOWN_AF_ACTIVATE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } #if 0 } @@ -1496,8 +1496,8 @@ peer_group_bind (struct bgp *bgp, union sockunion *su, peer_group2peer_config_copy (group, peer, afi, safi); peer->last_reset = PEER_DOWN_RMAP_BIND; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -1534,8 +1534,8 @@ peer_group_unbind (struct bgp *bgp, struct peer *peer, } peer->last_reset = PEER_DOWN_RMAP_UNBIND; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -2026,8 +2026,8 @@ 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_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } @@ -2395,8 +2395,8 @@ peer_update_source_if_set (struct peer *peer, const char *ifname) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -2422,8 +2422,8 @@ peer_update_source_if_set (struct peer *peer, const char *ifname) peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, ifname); peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } return 0; } @@ -2454,8 +2454,8 @@ peer_update_source_addr_set (struct peer *peer, union sockunion *su) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -2480,8 +2480,8 @@ peer_update_source_addr_set (struct peer *peer, union sockunion *su) peer->update_source = sockunion_dup (su); peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } return 0; } @@ -2526,8 +2526,8 @@ peer_update_source_unset (struct peer *peer) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -2551,8 +2551,8 @@ peer_update_source_unset (struct peer *peer) } peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } return 0; } @@ -2975,8 +2975,8 @@ peer_local_as_set (struct peer *peer, as_t as, int no_prepend) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -2990,8 +2990,8 @@ peer_local_as_set (struct peer *peer, as_t as, int no_prepend) UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } return 0; @@ -3015,8 +3015,8 @@ peer_local_as_unset (struct peer *peer) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return 0; } @@ -3027,8 +3027,8 @@ peer_local_as_unset (struct peer *peer) UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } return 0; } @@ -3055,8 +3055,8 @@ peer_password_set (struct peer *peer, const char *password) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); return BGP_SUCCESS; } @@ -3070,8 +3070,8 @@ peer_password_set (struct peer *peer, const char *password) peer->password = XSTRDUP(MTYPE_PEER_PASSWORD, password); - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); } return ret; @@ -3093,8 +3093,8 @@ peer_password_unset (struct peer *peer) && strcmp (peer->group->conf->password, peer->password) == 0) return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); if (peer->password) XFREE (MTYPE_PEER_PASSWORD, peer->password); @@ -3111,8 +3111,8 @@ peer_password_unset (struct peer *peer) if (!peer->password) continue; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_CONFIG_CHANGE, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_CONFIG_CHANGE); XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; @@ -3841,15 +3841,14 @@ peer_clear (struct peer *peer) zlog_debug ("%s Maximum-prefix restart timer cancelled", peer->host); } -/* TODO: worry about why session is already enabled at this point !! */ -// bgp_peer_enable(peer); - bgp_peer_reenable(peer, NULL) ; + bgp_peer_enable(peer); + return 0; } peer->v_start = BGP_INIT_START_TIMER; - bgp_peer_reenable(peer, bgp_notify_new(BGP_NOTIFY_CEASE, - BGP_NOTIFY_CEASE_ADMIN_RESET, 0)); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_ADMIN_RESET); } return 0; } @@ -4719,7 +4718,8 @@ bgp_terminate (int terminating, int retain_mode) if (terminating) bgp_peer_disable(peer, notification); else - bgp_peer_reenable(peer, notification); + bgp_notify_send(peer, BGP_NOTIFY_CEASE, + BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN); } if (!retain_mode) |