bgpd: fix using of two pointers for struct thread_master *

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>
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 05c30ff..359fce3 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -115,7 +115,7 @@
     
   damp->t_reuse = NULL;
   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 ();
 
@@ -447,7 +447,7 @@
   /* Register reuse timer.  */
   if (! 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;
 }
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index a3c9526..3d88dee 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -156,13 +156,13 @@
 	  secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour;
 	  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);
     }
   else
     {
       /* 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);
     }
 
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index a749f8e..752d6e2 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -26,7 +26,7 @@
 #define BGP_READ_ON(T,F,V)			\
   do {						\
     if (!(T) && (peer->status != Deleted))	\
-      THREAD_READ_ON(master,T,F,peer,V);	\
+      THREAD_READ_ON(bm->master,T,F,peer,V);	\
   } while (0)
 
 #define BGP_READ_OFF(T)				\
@@ -38,7 +38,7 @@
 #define BGP_WRITE_ON(T,F,V)			\
   do {						\
     if (!(T) && (peer->status != Deleted))	\
-      THREAD_WRITE_ON(master,(T),(F),peer,(V)); \
+      THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \
   } while (0)
     
 #define BGP_WRITE_OFF(T)			\
@@ -50,7 +50,7 @@
 #define BGP_TIMER_ON(T,F,V)			\
   do {						\
     if (!(T) && (peer->status != Deleted))	\
-      THREAD_TIMER_ON(master,(T),(F),peer,(V)); \
+      THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \
   } while (0)
 
 #define BGP_TIMER_OFF(T)			\
@@ -62,13 +62,13 @@
 #define BGP_EVENT_ADD(P,E)			\
   do {						\
     if ((P)->status != Deleted)			\
-      thread_add_event (master, bgp_event, (P), (E)); \
+      thread_add_event (bm->master, bgp_event, (P), (E)); \
   } while (0)
 
 #define BGP_EVENT_FLUSH(P)			\
   do { 						\
     assert (peer); 				\
-    thread_cancel_event (master, (P)); 		\
+    thread_cancel_event (bm->master, (P)); 	\
   } while (0)
 
 /* Prototypes. */
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 7c2988c..cacff23 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -105,9 +105,6 @@
 /* Route retain mode flag. */
 static int retain_mode = 0;
 
-/* Master of threads. */
-struct thread_master *master;
-
 /* Manually specified configuration file name.  */
 char *config_file = NULL;
 
@@ -302,8 +299,8 @@
     stream_free (bgp_nexthop_buf);
 
   /* reverse bgp_master_init */
-  if (master)
-    thread_master_free (master);
+  if (bm->master)
+    thread_master_free (bm->master);
 
   if (zlog_default)
     closezlog (zlog_default);
@@ -416,15 +413,12 @@
 	}
     }
 
-  /* Make thread master. */
-  master = bm->master;
-
   /* Initializations. */
   srandom (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);
   cmd_init (1);
-  vty_init (master);
+  vty_init (bm->master);
   memory_init ();
   vrf_init ();
 
@@ -459,7 +453,7 @@
 	       bm->port);
 
   /* Start finite state machine, here we go! */
-  while (thread_fetch (master, &thread))
+  while (thread_fetch (bm->master, &thread))
     thread_call (&thread);
 
   /* Not reached. */
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 7059e8a..8621854 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -207,7 +207,7 @@
       zlog_err ("accept_sock is nevative value %d", accept_sock);
       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. */
   bgp_sock = sockunion_accept (accept_sock, &su);
@@ -480,7 +480,7 @@
   listener = XMALLOC (MTYPE_BGP_LISTENER, sizeof(*listener));
   listener->fd = sock;
   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);
 
   return 0;
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 183a28b..bb658af 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -529,7 +529,7 @@
 bgp_scan_timer (struct thread *t)
 {
   bgp_scan_thread =
-    thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval);
+    thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval);
 
   if (BGP_DEBUG (events, EVENTS))
     zlog_debug ("Performing BGP general scanning");
@@ -1103,7 +1103,7 @@
   safi_t safi;
 
   bgp_import_thread = 
-    thread_add_timer (master, bgp_import, NULL, bgp_import_interval);
+    thread_add_timer (bm->master, bgp_import, NULL, bgp_import_interval);
 
   if (BGP_DEBUG (events, EVENTS))
     zlog_debug ("Import timer expired.");
@@ -1230,7 +1230,7 @@
     {
       thread_cancel (bgp_scan_thread);
       bgp_scan_thread = 
-	thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval);
+	thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval);
     }
 
   return CMD_SUCCESS;
@@ -1249,7 +1249,7 @@
     {
       thread_cancel (bgp_scan_thread);
       bgp_scan_thread = 
-	thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval);
+	thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval);
     }
 
   return CMD_SUCCESS;
@@ -1400,9 +1400,9 @@
 void
 bgp_scan_init (void)
 {
-  zlookup = zclient_new (master);
+  zlookup = zclient_new (bm->master);
   zlookup->sock = -1;
-  zlookup->t_connect = thread_add_event (master, zlookup_connect, zlookup, 0);
+  zlookup->t_connect = thread_add_event (bm->master, zlookup_connect, zlookup, 0);
 
   bgp_scan_interval = BGP_SCAN_INTERVAL_DEFAULT;
   bgp_import_interval = BGP_IMPORT_INTERVAL_DEFAULT;
@@ -1421,10 +1421,10 @@
 #endif /* HAVE_IPV6 */
 
   /* Make BGP scan thread. */
-  bgp_scan_thread = thread_add_timer (master, bgp_scan_timer, 
+  bgp_scan_thread = thread_add_timer (bm->master, bgp_scan_timer, 
                                       NULL, bgp_scan_interval);
   /* Make BGP import there. */
-  bgp_import_thread = thread_add_timer (master, bgp_import, NULL, 0);
+  bgp_import_thread = thread_add_timer (bm->master, bgp_import, NULL, 0);
 
   install_element (BGP_NODE, &bgp_scan_time_cmd);
   install_element (BGP_NODE, &no_bgp_scan_time_cmd);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index af8bdb4..3fdd9ff 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1978,7 +1978,7 @@
   if (name)
     bgp->name = strdup (name);
 
-  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);
 
   return bgp;
@@ -5421,7 +5421,7 @@
   bgp_vty_init ();
 
   /* Init zebra. */
-  bgp_zebra_init (master);
+  bgp_zebra_init (bm->master);
 
   /* BGP inits. */
   bgp_attr_init ();
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 7ae0acb..95c16de 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -834,8 +834,6 @@
 
 extern struct bgp_master *bm;
 
-extern struct thread_master *master;
-
 /* Prototypes. */
 extern void bgp_terminate (void);
 extern void bgp_reset (void);