From: Donald Sharp Date: Wed, 13 Apr 2016 16:21:47 +0000 (-0400) Subject: zebra: Refactor struct zebra_t X-Git-Tag: frr-2.0-rc1~970 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=44e9909db444bead27483886b013b96fcf0aca47;p=matthieu%2Ffrr.git zebra: Refactor struct zebra_t 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 Reviewed-by: Don Slice Reviewed-by: Vivek Venkatraman --- diff --git a/zebra/connected.c b/zebra/connected.c index fea7fc06fc..272689b594 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -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 diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 43c63a83f0..31e6d4510c 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -61,10 +61,6 @@ #include "sockunion.h" #include "log.h" - -/* Master of threads. */ -extern struct zebra_t zebrad; - extern int irdp_sock; static const char * diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index af493c5c01..069a2df006 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -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. */ diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c index 0d31050c55..a2ca82099b 100644 --- a/zebra/irdp_packet.c +++ b/zebra/irdp_packet.c @@ -69,7 +69,6 @@ int irdp_sock = -1; -extern struct zebra_t zebrad; extern struct thread *t_irdp_raw; static void diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 028109cb2c..a8ce4d07df 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -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 diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 5bd0df92a7..4de7c56ee5 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -40,10 +40,6 @@ #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]; diff --git a/zebra/rib.h b/zebra/rib.h index ae1f923cde..431389cf3c 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -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 diff --git a/zebra/router-id.c b/zebra/router-id.c index 968fbc677d..a3195cdc9f 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -42,10 +42,6 @@ #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) { diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 499881877e..9f8b96b6e5 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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; diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 1d81b1e109..af8a32d92a 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -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}; diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 819f05162c..4ba7d1b4c3 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -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; diff --git a/zebra/zebra_ptm_redistribute.c b/zebra/zebra_ptm_redistribute.c index 8533219d28..a255f5a1e5 100644 --- a/zebra/zebra_ptm_redistribute.c +++ b/zebra/zebra_ptm_redistribute.c @@ -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, diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 5e0e8149c9..995fe52bf1 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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: diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 4b80dcceda..a584602e90 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -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); } } diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 613b817481..f083693e4e 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -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; diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index fbd0379fcd..11fc0ef40d 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -84,8 +84,6 @@ #define IPADDRESS ASN_IPADDRESS #define OBJECTIDENTIFIER ASN_OBJECT_ID -extern struct zebra_t zebrad; - oid ipfw_oid [] = { IPFWMIB }; /* Hook functions. */ diff --git a/zebra/zserv.c b/zebra/zserv.c index 94f437ee19..e42d146fdf 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -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; diff --git a/zebra/zserv.h b/zebra/zserv.h index f3fc21074d..8fcf8e495e 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -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);