]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: introduce dedicated dataplane pthread
authorMark Stapp <mjs@voltanet.io>
Thu, 30 Aug 2018 17:48:05 +0000 (13:48 -0400)
committerMark Stapp <mjs@voltanet.io>
Wed, 21 Nov 2018 15:25:57 +0000 (10:25 -0500)
Signed-off-by: Mark Stapp <mjs@voltanet.io>
zebra/main.c
zebra/zebra_dplane.c

index 5628b5e022434bba5dcf654a1dbced3577852d3f..20a2185b1b61fbebf87a43147dc5b8a8377c523f 100644 (file)
@@ -390,6 +390,9 @@ int main(int argc, char **argv)
        vty_config_lockless();
        zebrad.master = frr_init();
 
+       /* Initialize pthread library */
+       frr_pthread_init();
+
        /* Zebra related initialize. */
        zebra_router_init();
        zserv_init();
@@ -445,9 +448,6 @@ int main(int argc, char **argv)
        /* Needed for BSD routing socket. */
        pid = getpid();
 
-       /* Intialize pthread library */
-       frr_pthread_init();
-
        /* Start Zebra API server */
        zserv_start(zserv_path);
 
index 3e61418b6486638c834c21869147b49b39a24dab..98db3ca7e5604915b732c762211cc3a26e9fc4b0 100644 (file)
@@ -176,6 +176,9 @@ static struct zebra_dplane_globals {
        _Atomic uint32_t dg_routes_queued_max;
        _Atomic uint32_t dg_route_errors;
 
+       /* Dataplane pthread */
+       struct frr_pthread *dg_pthread;
+
        /* Event-delivery context 'master' for the dplane */
        struct thread_master *dg_master;
 
@@ -1004,13 +1007,23 @@ static void zebra_dplane_init_internal(struct zebra_t *zebra)
        zdplane_info.dg_max_queued_updates = DPLANE_DEFAULT_MAX_QUEUED;
 
        /* TODO -- register default kernel 'provider' during init */
+       zdplane_info.dg_run = true;
+
+       /* Start dataplane pthread */
 
        zdplane_info.dg_run = true;
 
-       /* TODO -- start dataplane pthread. We're using the zebra
-        * core/main thread temporarily
-        */
-       zdplane_info.dg_master = zebra->master;
+       struct frr_pthread_attr pattr = {
+               .start = frr_pthread_attr_default.start,
+               .stop = frr_pthread_attr_default.stop
+       };
+
+       zdplane_info.dg_pthread = frr_pthread_new(&pattr, "Zebra dplane thread",
+                                                 "Zebra dplane");
+
+       zdplane_info.dg_master = zdplane_info.dg_pthread->master;
+
+       frr_pthread_run(zdplane_info.dg_pthread, NULL);
 }
 
 /* Indicates zebra shutdown/exit is in progress. Some operations may be
@@ -1122,8 +1135,12 @@ void zebra_dplane_shutdown(void)
 
        THREAD_OFF(zdplane_info.dg_t_update);
 
-       /* TODO */
-       /* frr_pthread_stop(...) */
+       frr_pthread_stop(zdplane_info.dg_pthread, NULL);
+
+       /* Destroy pthread */
+       frr_pthread_destroy(zdplane_info.dg_pthread);
+       zdplane_info.dg_pthread = NULL;
+       zdplane_info.dg_master = NULL;
 
        /* Notify provider(s) of final shutdown */