]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Refactor struct zebra_t
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 13 Apr 2016 16:21:47 +0000 (12:21 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 15 Apr 2016 00:56:45 +0000 (20:56 -0400)
We were including 'extern struct zebra_t zebrad;' all
over the place.  This made no sense.  Refactor
into zserv.h where the definition was and remove resulting
unnecessary code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
18 files changed:
zebra/connected.c
zebra/irdp_interface.c
zebra/irdp_main.c
zebra/irdp_packet.c
zebra/kernel_socket.c
zebra/redistribute.c
zebra/rib.h
zebra/router-id.c
zebra/rt_netlink.c
zebra/rtadv.c
zebra/zebra_ptm.c
zebra/zebra_ptm_redistribute.c
zebra/zebra_rib.c
zebra/zebra_rnh.c
zebra/zebra_routemap.c
zebra/zebra_snmp.c
zebra/zserv.c
zebra/zserv.h

index fea7fc06fcfd36a84e3084ada4a9d3c169a6bec0..272689b5947b407e2b1f5fa1ddc89fea276a7eb0 100644 (file)
@@ -37,7 +37,6 @@
 #include "zebra/interface.h"
 #include "zebra/connected.h"
 #include "zebra/rtadv.h"
-extern struct zebra_t zebrad;
 
 /* communicate the withdrawal of a connected address */
 static void
index 43c63a83f07f13fe30ad950c9c830343f3fa1948..31e6d4510c00eeb977b5ee72ab91931d7e011ad2 100644 (file)
 #include "sockunion.h"
 #include "log.h"
 
-
-/* Master of threads. */
-extern struct zebra_t zebrad;
-
 extern int irdp_sock;
 
 static const char *
index af493c5c01e63629beaf0fad4936927dc2635e5e..069a2df006bc1c6fe8b5df26dce02684435dba4c 100644 (file)
@@ -69,8 +69,6 @@
 
 extern struct zebra_privs_t zserv_privs;
 
-/* Master of threads. */
-extern struct zebra_t zebrad;
 struct thread *t_irdp_raw;
 
 /* Timer interval of irdp. */
index 0d31050c5594a54c5b8837f33bd37f1c143daa2e..a2ca82099bde944dc1c5672c47e6e82f43de3b9b 100644 (file)
@@ -69,7 +69,6 @@
 
 int irdp_sock = -1;
 
-extern struct zebra_t zebrad;
 extern struct thread *t_irdp_raw;
 
 static void
index 028109cb2c4205963ff92022f63f08db19e38ef8..a8ce4d07df46b05eadb658e92addc17446201094 100644 (file)
@@ -41,7 +41,6 @@
 #include "zebra/rib.h"
 
 extern struct zebra_privs_t zserv_privs;
-extern struct zebra_t zebrad;
 
 /*
  * Given a sockaddr length, round it up to include pad bytes following
index 5bd0df92a755dee3f3d9d2f61715ab52a04db196..4de7c56ee5ac4172abbb91ba41e54398d9682211 100644 (file)
 
 #define ZEBRA_PTM_SUPPORT
 
-
-/* master zebra server structure */
-extern struct zebra_t zebrad;
-
 /* array holding redistribute info about table redistribution */
 /* bit AFI is set if that AFI is redistributing routes from this table */
 static u_char zebra_import_table_used[ZEBRA_KERNEL_TABLE_MAX];
index ae1f923cdea33d9d0c63ea4bdb2fc56bc3412467..431389cf3ce8480a7ba7b9afbe4df82f48f2824a 100644 (file)
@@ -471,8 +471,7 @@ extern void rib_close_table (struct route_table *);
 extern void rib_close (void);
 extern void rib_init (void);
 extern unsigned long rib_score_proto (u_char proto, u_short instance);
-struct zebra_t;
-extern void rib_queue_add (struct zebra_t *zebra, struct route_node *rn);
+extern void rib_queue_add (struct route_node *rn);
 
 
 extern int
index 968fbc677d3a7e76fa917fb00f598ae8e45ba666..a3195cdc9fbe88c5aaf758cf6363d7e927d0e326 100644 (file)
 #include "zebra/router-id.h"
 #include "zebra/redistribute.h"
 
-
-/* master zebra server structure */
-extern struct zebra_t zebrad;
-
 static struct connected *
 router_id_find_node (struct list *l, struct connected *ifc)
 {
index 499881877ee5c15fddf56025f40bb9b52d65af92..9f8b96b6e543c88860181bff8766ac8895c3ba15 100644 (file)
@@ -64,8 +64,6 @@ static const struct message nlmsg_str[] = {
   {0, NULL}
 };
 
-extern struct zebra_t zebrad;
-
 extern struct zebra_privs_t zserv_privs;
 
 extern u_int32_t nl_rcvbufsize;
index 1d81b1e1093c8347c89429a9593e11bc4206d0e7..af8a32d92a49c8d38ff692b68031b9e5a0d8336c 100644 (file)
@@ -58,8 +58,6 @@ extern struct zebra_privs_t zserv_privs;
 #define ALLNODE   "ff02::1"
 #define ALLROUTER "ff02::2"
 
-extern struct zebra_t zebrad;
-
 enum rtadv_event {RTADV_START, RTADV_STOP, RTADV_TIMER, 
                  RTADV_TIMER_MSEC, RTADV_READ};
 
index 819f05162cb669f744f3da1958de69446690ae93..4ba7d1b4c32745a944cffffeb239662c6e936a07 100644 (file)
@@ -76,8 +76,6 @@ const char ZEBRA_PTM_BFD_MAX_HOP_CNT_FIELD[] = "maxHopCnt";
 const char ZEBRA_PTM_BFD_SEND_EVENT[] = "sendEvent";
 const char ZEBRA_PTM_BFD_VRF_NAME_FIELD[] = "vrfName";
 
-extern struct zebra_t zebrad;
-
 static ptm_lib_handle_t *ptm_hdl;
 
 struct zebra_ptm_cb ptm_cb;
index 8533219d283163330f58121054b1e68f9fbbdc76..a255f5a1e5d084b58cfd0c28f9562a0969023f06 100644 (file)
@@ -26,9 +26,6 @@
 #include "zebra/zserv.h"
 #include "zebra/zebra_ptm_redistribute.h"
 
-/* master zebra server structure */
-extern struct zebra_t zebrad;
-
 static int
 zsend_interface_bfd_update (int cmd, struct zserv *client,
                             struct interface *ifp, struct prefix *dp,
index 5e0e8149c9ac011e15ac539a72907dada560931c..995fe52bf15911f325ab5f1c577039c6d2636ce5 100644 (file)
@@ -47,9 +47,6 @@
 #include "zebra/interface.h"
 #include "zebra/connected.h"
 
-/* Default rtm_table for all clients */
-extern struct zebra_t zebrad;
-
 /* Should we allow non Quagga processes to delete our routes */
 extern int allow_delete;
 
@@ -1753,9 +1750,9 @@ rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn)
 
 /* Add route_node to work queue and schedule processing */
 void
-rib_queue_add (struct zebra_t *zebra, struct route_node *rn)
+rib_queue_add (struct route_node *rn)
 {
-  assert (zebra && rn);
+  assert (rn);
   
   /* Pointless to queue a route_node with no RIB entries to add or remove */
   if (!rnode_to_ribs (rn))
@@ -1766,9 +1763,7 @@ rib_queue_add (struct zebra_t *zebra, struct route_node *rn)
       return;
     }
 
-  assert (zebra);
-
-  if (zebra->ribq == NULL)
+  if (zebrad.ribq == NULL)
     {
       zlog_err ("%s: work_queue does not exist!", __func__);
       return;
@@ -1782,10 +1777,10 @@ rib_queue_add (struct zebra_t *zebra, struct route_node *rn)
    * holder, if necessary, then push the work into it in any case.
    * This semantics was introduced after 0.99.9 release.
    */
-  if (!zebra->ribq->items->count)
-    work_queue_add (zebra->ribq, zebra->mq);
+  if (!zebrad.ribq->items->count)
+    work_queue_add (zebrad.ribq, zebrad.mq);
 
-  rib_meta_queue_add (zebra->mq, rn);
+  rib_meta_queue_add (zebrad.mq, rn);
 
   return;
 }
@@ -1918,7 +1913,7 @@ rib_link (struct route_node *rn, struct rib *rib, int process)
     zebra_add_import_table_entry(rn, rib);
   else
     if (process)
-      rib_queue_add (&zebrad, rn);
+      rib_queue_add (rn);
 }
 
 static void
@@ -1998,7 +1993,7 @@ rib_delnode (struct route_node *rn, struct rib *rib)
     }
   else
     {
-      rib_queue_add (&zebrad, rn);
+      rib_queue_add (rn);
     }
 }
 
@@ -2304,7 +2299,7 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p, vrf_id_t vrf_id)
     }
   }
   if (changed)
-    rib_queue_add (&zebrad, rn);
+    rib_queue_add (rn);
 }
 
 int
@@ -2600,7 +2595,7 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro
           si->type == STATIC_IPV6_GATEWAY)
         zebra_evaluate_rnh(si->vrf_id, nh_p.family, 1, RNH_NEXTHOP_TYPE, &nh_p);
       else
-        rib_queue_add (&zebrad, rn);
+        rib_queue_add (rn);
     }
   else
     {
@@ -3506,10 +3501,10 @@ rib_update_table (struct route_table *table, rib_update_event_t event)
                    * take care.
                    */
                   if (nh)
-                    rib_queue_add (&zebrad, rn);
+                    rib_queue_add (rn);
                 }
               else
-                  rib_queue_add (&zebrad, rn);
+                  rib_queue_add (rn);
             }
           break;
 
@@ -3519,7 +3514,7 @@ rib_update_table (struct route_table *table, rib_update_event_t event)
            * some cases (TODO).
            */
           if (rnode_to_ribs (rn))
-            rib_queue_add (&zebrad, rn);
+            rib_queue_add (rn);
           break;
 
         default:
index 4b80dcceda57dedf9a1119ef76a73677ad197454..a584602e9014c67b57aac3851cc46376efb07c61 100644 (file)
@@ -46,9 +46,6 @@
 #include "zebra/zebra_rnh.h"
 #include "zebra/interface.h"
 
-/* Default rtm_table for all clients */
-extern struct zebra_t zebrad;
-
 static void free_state(vrf_id_t vrf_id, struct rib *rib, struct route_node *rn);
 static void copy_state(struct rnh *rnh, struct rib *rib,
                       struct route_node *rn);
@@ -575,7 +572,7 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
 
       SET_FLAG(srib->flags, ZEBRA_FLAG_CHANGED);
       SET_FLAG(srib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
-      rib_queue_add(&zebrad, static_rn);
+      rib_queue_add(static_rn);
     }
 }
 
index 613b817481dd16fa5d2a78560ad7d7d3f9a0e922..f083693e4e52a78045a7423c29df056f43988e27 100644 (file)
@@ -42,7 +42,6 @@ char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1];   /* "any" == ZEBRA_ROUTE_MAX */
 /* NH Tracking route map */
 char *nht_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1];      /* "any" == ZEBRA_ROUTE_MAX */
 
-extern struct zebra_t zebrad;
 struct nh_rmap_obj
 {
   struct nexthop *nexthop;
index fbd0379fcd355e8d774e2f2c109f3871aa827991..11fc0ef40d6517cc0c82984cbbb9a09e7c9e1235 100644 (file)
@@ -84,8 +84,6 @@
 #define IPADDRESS ASN_IPADDRESS
 #define OBJECTIDENTIFIER ASN_OBJECT_ID
 
-extern struct zebra_t zebrad;
-
 oid ipfw_oid [] = { IPFWMIB };
 
 /* Hook functions. */
index 94f437ee196ab9e76ff79c60950fed3b98848286..e42d146fdff2c75d9608f24d48463a39c5588a3f 100644 (file)
@@ -52,8 +52,6 @@
 /* Event list of zebra. */
 enum event { ZEBRA_SERV, ZEBRA_READ, ZEBRA_WRITE };
 
-extern struct zebra_t zebrad;
-
 static void zebra_event (enum event event, int sock, struct zserv *client);
 
 extern struct zebra_privs_t zserv_privs;
index f3fc21074db087100fa7d253707a628d21418795..8fcf8e495e12857c2492d4e952736c86a6aedf77 100644 (file)
@@ -130,6 +130,7 @@ struct zebra_t
   struct work_queue *ribq;
   struct meta_queue *mq;
 };
+extern struct zebra_t zebrad;
 
 /* Prototypes. */
 extern void zebra_init (void);