diff options
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r-- | bgpd/bgp_route.c | 105 |
1 files changed, 24 insertions, 81 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 6b7828ca..1e9c8dce 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -56,8 +56,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_vty.h" /* Extern from bgp_dump.c */ -extern char *bgp_origin_str[]; -extern char *bgp_origin_long_str[]; +extern const char *bgp_origin_str[]; +extern const char *bgp_origin_long_str[]; static struct bgp_node * bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, @@ -127,18 +127,13 @@ bgp_info_extra_get (struct bgp_info *ri) /* Allocate new bgp info structure. */ static struct bgp_info * -bgp_info_new () +bgp_info_new (void) { - struct bgp_info *new; - - new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); - memset (new, 0, sizeof (struct bgp_info)); - - return new; + return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); } /* Free bgp route information. */ -static void +void bgp_info_free (struct bgp_info *binfo) { if (binfo->attr) @@ -151,39 +146,6 @@ bgp_info_free (struct bgp_info *binfo) XFREE (MTYPE_BGP_ROUTE, binfo); } -struct bgp_info * -bgp_info_lock (struct bgp_info *binfo) -{ - binfo->lock++; - return binfo; -} - -struct bgp_info * -bgp_info_unlock (struct bgp_info *binfo) -{ - assert (binfo && binfo->lock > 0); - binfo->lock--; - - if (binfo->lock == 0) - { -#if 0 - zlog_debug ("%s: unlocked and freeing", __func__); - zlog_backtrace (LOG_DEBUG); -#endif - bgp_info_free (binfo); - return NULL; - } - -#if 0 - if (binfo->lock == 1) - { - zlog_debug ("%s: unlocked to 1", __func__); - zlog_backtrace (LOG_DEBUG); - } -#endif - - return binfo; -} void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) @@ -1567,6 +1529,7 @@ bgp_processq_del (struct work_queue *wq, void *data) { struct bgp_process_queue *pq = data; + bgp_unlock(pq->bgp); bgp_unlock_node (pq->rn); XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); } @@ -1616,6 +1579,7 @@ bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) pqnode->rn = bgp_lock_node (rn); /* unlocked by bgp_processq_del */ pqnode->bgp = bgp; + bgp_lock(bgp); pqnode->afi = afi; pqnode->safi = safi; @@ -2678,10 +2642,10 @@ bgp_clear_node_complete (struct work_queue *wq) { struct peer *peer = wq->spec.data; - peer_unlock (peer); /* bgp_clear_node_complete */ - /* Tickle FSM to start moving again */ BGP_EVENT_ADD (peer, Clearing_Completed); + + peer_unlock (peer); /* bgp_clear_node_complete */ } static void @@ -2848,19 +2812,6 @@ bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) */ if (!peer->clear_node_queue->thread) bgp_clear_node_complete (peer->clear_node_queue); - else - { - /* clearing queue scheduled. Normal if in Established state - * (and about to transition out of it), but otherwise... - */ - if (peer->status != Established) - { - plog_err (peer->log, "%s [Error] State %s is not Established," - " but routes were cleared - bug!", - peer->host, LOOKUP (bgp_status_msg, peer->status)); - assert (peer->status == Established); - } - } } void @@ -2916,7 +2867,7 @@ bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) /* Delete all kernel routes. */ void -bgp_cleanup_routes () +bgp_cleanup_routes (void) { struct bgp *bgp; struct listnode *node, *nnode; @@ -2947,7 +2898,7 @@ bgp_cleanup_routes () } void -bgp_reset () +bgp_reset (void) { vty_reset (); bgp_zclient_reset (); @@ -3119,12 +3070,9 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, } static struct bgp_static * -bgp_static_new () +bgp_static_new (void) { - struct bgp_static *new; - new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); - memset (new, 0, sizeof (struct bgp_static)); - return new; + return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); } static void @@ -4507,12 +4455,9 @@ struct bgp_aggregate }; static struct bgp_aggregate * -bgp_aggregate_new () +bgp_aggregate_new (void) { - struct bgp_aggregate *new; - new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); - memset (new, 0, sizeof (struct bgp_aggregate)); - return new; + return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); } static void @@ -5832,6 +5777,7 @@ damp_route_vty_out (struct vty *vty, struct prefix *p, { struct attr *attr; int len; + char timebuf[BGP_UPTIME_LEN]; /* short status lead text */ route_vty_short_status_out (vty, binfo); @@ -5849,7 +5795,7 @@ damp_route_vty_out (struct vty *vty, struct prefix *p, else vty_out (vty, "%*s", len, " "); - vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); + vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); /* Print attribute */ attr = binfo->attr; @@ -5865,8 +5811,6 @@ damp_route_vty_out (struct vty *vty, struct prefix *p, vty_out (vty, "%s", VTY_NEWLINE); } -#define BGP_UPTIME_LEN 25 - /* flap route */ static void flap_route_vty_out (struct vty *vty, struct prefix *p, @@ -5910,7 +5854,7 @@ flap_route_vty_out (struct vty *vty, struct prefix *p, if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) - vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); + vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); else vty_out (vty, "%*s ", 8, " "); @@ -10857,12 +10801,9 @@ struct bgp_distance }; static struct bgp_distance * -bgp_distance_new () +bgp_distance_new (void) { - struct bgp_distance *new; - new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); - memset (new, 0, sizeof (struct bgp_distance)); - return new; + return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); } static void @@ -10957,8 +10898,9 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, return CMD_SUCCESS; } +#if 0 static void -bgp_distance_reset () +bgp_distance_reset (void) { struct bgp_node *rn; struct bgp_distance *bdistance; @@ -10973,6 +10915,7 @@ bgp_distance_reset () bgp_unlock_node (rn); } } +#endif /* Apply BGP information to distance method. */ u_char @@ -11565,7 +11508,7 @@ bgp_config_write_distance (struct vty *vty, struct bgp *bgp) /* Allocate routing table structure and install commands. */ void -bgp_route_init () +bgp_route_init (void) { /* Init BGP distance table. */ bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |