bgpd: fix using of two pointers for struct thread_master *

Ticket: CM-7861
Reviewed by: CCR-3651
Testing: See bug

bgp is using both bm->master and master pointers interchangebly
for thread manipulation.  Since they are the same thing consolidate
to one pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2015-10-14 08:50:39 -04:00
parent 87d4a78163
commit 9229d914dd
12 changed files with 27 additions and 34 deletions

View File

@ -116,7 +116,7 @@ bgp_reuse_timer (struct thread *t)
damp->t_reuse = NULL; damp->t_reuse = NULL;
damp->t_reuse = damp->t_reuse =
thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE); thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE);
t_now = bgp_clock (); t_now = bgp_clock ();
@ -448,7 +448,7 @@ bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
/* Register reuse timer. */ /* Register reuse timer. */
if (! damp->t_reuse) if (! damp->t_reuse)
damp->t_reuse = damp->t_reuse =
thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE); thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE);
return 0; return 0;
} }

View File

@ -159,13 +159,13 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval)
secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour; secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour;
interval = interval - secs_into_day % interval; /* always > 0 */ interval = interval - secs_into_day % interval; /* always > 0 */
} }
bgp_dump->t_interval = thread_add_timer (master, bgp_dump_interval_func, bgp_dump->t_interval = thread_add_timer (bm->master, bgp_dump_interval_func,
bgp_dump, interval); bgp_dump, interval);
} }
else else
{ {
/* One-off dump: execute immediately, don't affect any scheduled dumps */ /* One-off dump: execute immediately, don't affect any scheduled dumps */
bgp_dump->t_interval = thread_add_event (master, bgp_dump_interval_func, bgp_dump->t_interval = thread_add_event (bm->master, bgp_dump_interval_func,
bgp_dump, 0); bgp_dump, 0);
} }

View File

@ -799,7 +799,7 @@ bgp_maxmed_onstartup_begin (struct bgp *bgp)
zlog_info ("Begin maxmed onstartup mode - timer %d seconds", zlog_info ("Begin maxmed onstartup mode - timer %d seconds",
bgp->v_maxmed_onstartup); bgp->v_maxmed_onstartup);
THREAD_TIMER_ON (master, bgp->t_maxmed_onstartup, THREAD_TIMER_ON (bm->master, bgp->t_maxmed_onstartup,
bgp_maxmed_onstartup_timer, bgp_maxmed_onstartup_timer,
bgp, bgp->v_maxmed_onstartup); bgp, bgp->v_maxmed_onstartup);
@ -869,11 +869,11 @@ bgp_update_delay_begin (struct bgp *bgp)
peer->update_delay_over = 0; peer->update_delay_over = 0;
/* Start the update-delay timer */ /* Start the update-delay timer */
THREAD_TIMER_ON (master, bgp->t_update_delay, bgp_update_delay_timer, THREAD_TIMER_ON (bm->master, bgp->t_update_delay, bgp_update_delay_timer,
bgp, bgp->v_update_delay); bgp, bgp->v_update_delay);
if (bgp->v_establish_wait != bgp->v_update_delay) if (bgp->v_establish_wait != bgp->v_update_delay)
THREAD_TIMER_ON (master, bgp->t_establish_wait, bgp_establish_wait_timer, THREAD_TIMER_ON (bm->master, bgp->t_establish_wait, bgp_establish_wait_timer,
bgp, bgp->v_establish_wait); bgp, bgp->v_establish_wait);
quagga_timestamp(3, bgp->update_delay_begin_time, quagga_timestamp(3, bgp->update_delay_begin_time,

View File

@ -26,7 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define BGP_READ_ON(T,F,V) \ #define BGP_READ_ON(T,F,V) \
do { \ do { \
if (!(T) && (peer->status != Deleted)) \ if (!(T) && (peer->status != Deleted)) \
THREAD_READ_ON(master,T,F,peer,V); \ THREAD_READ_ON(bm->master,T,F,peer,V); \
} while (0) } while (0)
#define BGP_READ_OFF(T) \ #define BGP_READ_OFF(T) \
@ -38,13 +38,13 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define BGP_WRITE_ON(T,F,V) \ #define BGP_WRITE_ON(T,F,V) \
do { \ do { \
if (!(T) && (peer->status != Deleted)) \ if (!(T) && (peer->status != Deleted)) \
THREAD_WRITE_ON(master,(T),(F),peer,(V)); \ THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \
} while (0) } while (0)
#define BGP_PEER_WRITE_ON(T,F,V, peer) \ #define BGP_PEER_WRITE_ON(T,F,V, peer) \
do { \ do { \
if (!(T) && ((peer)->status != Deleted)) \ if (!(T) && ((peer)->status != Deleted)) \
THREAD_WRITE_ON(master,(T),(F),(peer),(V)); \ THREAD_WRITE_ON(bm->master,(T),(F),(peer),(V)); \
} while (0) } while (0)
#define BGP_WRITE_OFF(T) \ #define BGP_WRITE_OFF(T) \
@ -56,7 +56,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define BGP_TIMER_ON(T,F,V) \ #define BGP_TIMER_ON(T,F,V) \
do { \ do { \
if (!(T) && (peer->status != Deleted)) \ if (!(T) && (peer->status != Deleted)) \
THREAD_TIMER_ON(master,(T),(F),peer,(V)); \ THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \
} while (0) } while (0)
#define BGP_TIMER_OFF(T) \ #define BGP_TIMER_OFF(T) \
@ -68,13 +68,13 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define BGP_EVENT_ADD(P,E) \ #define BGP_EVENT_ADD(P,E) \
do { \ do { \
if ((P)->status != Deleted) \ if ((P)->status != Deleted) \
thread_add_event (master, bgp_event, (P), (E)); \ thread_add_event (bm->master, bgp_event, (P), (E)); \
} while (0) } while (0)
#define BGP_EVENT_FLUSH(P) \ #define BGP_EVENT_FLUSH(P) \
do { \ do { \
assert (peer); \ assert (peer); \
thread_cancel_event (master, (P)); \ thread_cancel_event (bm->master, (P)); \
} while (0) } while (0)
#define BGP_MSEC_JITTER 10 #define BGP_MSEC_JITTER 10

View File

@ -105,9 +105,6 @@ char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG;
/* Route retain mode flag. */ /* Route retain mode flag. */
static int retain_mode = 0; static int retain_mode = 0;
/* Master of threads. */
struct thread_master *master;
/* Manually specified configuration file name. */ /* Manually specified configuration file name. */
char *config_file = NULL; char *config_file = NULL;
@ -296,8 +293,8 @@ bgp_exit (int status)
bgp_scan_finish (); bgp_scan_finish ();
/* reverse bgp_master_init */ /* reverse bgp_master_init */
if (master) if (bm->master)
thread_master_free (master); thread_master_free (bm->master);
if (zlog_default) if (zlog_default)
closezlog (zlog_default); closezlog (zlog_default);
@ -407,15 +404,13 @@ main (int argc, char **argv)
} }
} }
/* Make thread master. */
master = bm->master;
/* Initializations. */ /* Initializations. */
srand (time (NULL)); srand (time (NULL));
signal_init (master, array_size(bgp_signals), bgp_signals); signal_init (bm->master, array_size(bgp_signals), bgp_signals);
zprivs_init (&bgpd_privs); zprivs_init (&bgpd_privs);
cmd_init (1); cmd_init (1);
vty_init (master); vty_init (bm->master);
memory_init (); memory_init ();
/* BGP related initialization. */ /* BGP related initialization. */
@ -449,7 +444,7 @@ main (int argc, char **argv)
bm->port); bm->port);
/* Start finite state machine, here we go! */ /* Start finite state machine, here we go! */
while (thread_fetch (master, &thread)) while (thread_fetch (bm->master, &thread))
thread_call (&thread); thread_call (&thread);
/* Not reached. */ /* Not reached. */

View File

@ -236,7 +236,7 @@ bgp_accept (struct thread *thread)
zlog_err ("accept_sock is nevative value %d", accept_sock); zlog_err ("accept_sock is nevative value %d", accept_sock);
return -1; return -1;
} }
listener->thread = thread_add_read (master, bgp_accept, listener, accept_sock); listener->thread = thread_add_read (bm->master, bgp_accept, listener, accept_sock);
/* Accept client connection. */ /* Accept client connection. */
bgp_sock = sockunion_accept (accept_sock, &su); bgp_sock = sockunion_accept (accept_sock, &su);
@ -611,7 +611,7 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen)
listener = XMALLOC (MTYPE_BGP_LISTENER, sizeof(*listener)); listener = XMALLOC (MTYPE_BGP_LISTENER, sizeof(*listener));
listener->fd = sock; listener->fd = sock;
memcpy(&listener->su, sa, salen); memcpy(&listener->su, sa, salen);
listener->thread = thread_add_read (master, bgp_accept, listener, sock); listener->thread = thread_add_read (bm->master, bgp_accept, listener, sock);
listnode_add (bm->listen_sockets, listener); listnode_add (bm->listen_sockets, listener);
return 0; return 0;

View File

@ -2110,7 +2110,7 @@ bgp_process_main (struct work_queue *wq, void *data)
if (!bgp->t_rmap_def_originate_eval) if (!bgp->t_rmap_def_originate_eval)
{ {
bgp_lock (bgp); bgp_lock (bgp);
THREAD_TIMER_ON(master, bgp->t_rmap_def_originate_eval, THREAD_TIMER_ON(bm->master, bgp->t_rmap_def_originate_eval,
update_group_refresh_default_originate_route_map, update_group_refresh_default_originate_route_map,
bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER); bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER);
} }
@ -3233,7 +3233,7 @@ bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
* multiple peers and the announcement doesn't happen in the * multiple peers and the announcement doesn't happen in the
* vty context. * vty context.
*/ */
THREAD_TIMER_MSEC_ON (master, paf->t_announce_route, THREAD_TIMER_MSEC_ON (bm->master, paf->t_announce_route,
bgp_announce_route_timer_expired, paf, bgp_announce_route_timer_expired, paf,
(subgrp->peer_count == 1) ? (subgrp->peer_count == 1) ?
BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS : BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS :

View File

@ -2969,7 +2969,7 @@ bgp_route_map_mark_update (const char *rmap_name)
if (bgp->rmap_update_timer) if (bgp->rmap_update_timer)
{ {
bgp->t_rmap_update = bgp->t_rmap_update =
thread_add_timer(master, bgp_route_map_update_timer, bgp, thread_add_timer(bm->master, bgp_route_map_update_timer, bgp,
bgp->rmap_update_timer); bgp->rmap_update_timer);
/* Signal the groups that a route-map update event has started */ /* Signal the groups that a route-map update event has started */
update_group_policy_update(bgp, BGP_POLICY_ROUTE_MAP, rmap_name, 1, 1); update_group_policy_update(bgp, BGP_POLICY_ROUTE_MAP, rmap_name, 1, 1);

View File

@ -1182,7 +1182,7 @@ update_subgroup_trigger_merge_check (struct update_subgroup *subgrp,
return 0; return 0;
subgrp->t_merge_check = subgrp->t_merge_check =
thread_add_background (master, thread_add_background (bm->master,
update_subgroup_merge_check_thread_cb, update_subgroup_merge_check_thread_cb,
subgrp, 0); subgrp, 0);

View File

@ -743,7 +743,7 @@ subgroup_announce_all (struct update_subgroup *subgrp)
*/ */
if (!subgrp->t_coalesce) if (!subgrp->t_coalesce)
{ {
THREAD_TIMER_MSEC_ON (master, subgrp->t_coalesce, subgroup_coalesce_timer, THREAD_TIMER_MSEC_ON (bm->master, subgrp->t_coalesce, subgroup_coalesce_timer,
subgrp, subgrp->v_coalesce); subgrp, subgrp->v_coalesce);
} }
} }

View File

@ -2710,7 +2710,7 @@ bgp_create (as_t *as, const char *name)
bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
THREAD_TIMER_ON (master, bgp->t_startup, bgp_startup_timer_expire, THREAD_TIMER_ON (bm->master, bgp->t_startup, bgp_startup_timer_expire,
bgp, bgp->restart_time); bgp, bgp->restart_time);
update_bgp_group_init(bgp); update_bgp_group_init(bgp);
@ -6889,7 +6889,7 @@ bgp_init (void)
bgp_scan_init (); bgp_scan_init ();
/* Init zebra. */ /* Init zebra. */
bgp_zebra_init(master); bgp_zebra_init(bm->master);
/* BGP VTY commands installation. */ /* BGP VTY commands installation. */
bgp_vty_init (); bgp_vty_init ();

View File

@ -1110,8 +1110,6 @@ typedef enum
extern struct bgp_master *bm; extern struct bgp_master *bm;
extern struct thread_master *master;
/* Prototypes. */ /* Prototypes. */
extern void bgp_terminate (void); extern void bgp_terminate (void);
extern void bgp_reset (void); extern void bgp_reset (void);