summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_io.c14
-rw-r--r--bgpd/bgp_keepalives.c4
-rw-r--r--bgpd/bgpd.c23
-rw-r--r--bgpd/bgpd.h8
4 files changed, 25 insertions, 24 deletions
diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c
index c3bfbe4a9..95c3f15a6 100644
--- a/bgpd/bgp_io.c
+++ b/bgpd/bgp_io.c
@@ -23,7 +23,7 @@
#include <zebra.h>
#include <pthread.h> // for pthread_mutex_unlock, pthread_mutex_lock
-#include "frr_pthread.h" // for frr_pthread_get, frr_pthread
+#include "frr_pthread.h"
#include "linklist.h" // for list_delete, list_delete_all_node, lis...
#include "log.h" // for zlog_debug, safe_strerror, zlog_err
#include "memory.h" // for MTYPE_TMP, XCALLOC, XFREE
@@ -56,7 +56,7 @@ static bool validate_header(struct peer *);
void bgp_writes_on(struct peer *peer)
{
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *fpt = bgp_pth_io;
assert(fpt->running);
assert(peer->status != Deleted);
@@ -74,7 +74,7 @@ void bgp_writes_on(struct peer *peer)
void bgp_writes_off(struct peer *peer)
{
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *fpt = bgp_pth_io;
assert(fpt->running);
thread_cancel_async(fpt->master, &peer->t_write, NULL);
@@ -85,7 +85,7 @@ void bgp_writes_off(struct peer *peer)
void bgp_reads_on(struct peer *peer)
{
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *fpt = bgp_pth_io;
assert(fpt->running);
assert(peer->status != Deleted);
@@ -105,7 +105,7 @@ void bgp_reads_on(struct peer *peer)
void bgp_reads_off(struct peer *peer)
{
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *fpt = bgp_pth_io;
assert(fpt->running);
thread_cancel_async(fpt->master, &peer->t_read, NULL);
@@ -130,7 +130,7 @@ static int bgp_process_writes(struct thread *thread)
if (peer->fd < 0)
return -1;
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *fpt = bgp_pth_io;
pthread_mutex_lock(&peer->io_mtx);
{
@@ -182,7 +182,7 @@ static int bgp_process_reads(struct thread *thread)
if (peer->fd < 0 || bm->terminating)
return -1;
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *fpt = bgp_pth_io;
pthread_mutex_lock(&peer->io_mtx);
{
diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c
index aeb95f91b..91fa8fa37 100644
--- a/bgpd/bgp_keepalives.c
+++ b/bgpd/bgp_keepalives.c
@@ -229,7 +229,7 @@ void bgp_keepalives_on(struct peer *peer)
if (CHECK_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON))
return;
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_KEEPALIVES);
+ struct frr_pthread *fpt = bgp_pth_ka;
assert(fpt->running);
/* placeholder bucket data to use for fast key lookups */
@@ -259,7 +259,7 @@ void bgp_keepalives_off(struct peer *peer)
if (!CHECK_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON))
return;
- struct frr_pthread *fpt = frr_pthread_get(PTHREAD_KEEPALIVES);
+ struct frr_pthread *fpt = bgp_pth_ka;
assert(fpt->running);
/* placeholder bucket data to use for fast key lookups */
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index fd3a6c944..e4dedc242 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7750,35 +7750,36 @@ static const struct cmd_variable_handler bgp_viewvrf_var_handlers[] = {
{.completions = NULL},
};
+struct frr_pthread *bgp_pth_io;
+struct frr_pthread *bgp_pth_ka;
+
static void bgp_pthreads_init()
{
+ assert(!bgp_pth_io);
+ assert(!bgp_pth_ka);
+
frr_pthread_init();
struct frr_pthread_attr io = {
- .id = PTHREAD_IO,
.start = frr_pthread_attr_default.start,
.stop = frr_pthread_attr_default.stop,
};
struct frr_pthread_attr ka = {
- .id = PTHREAD_KEEPALIVES,
.start = bgp_keepalives_start,
.stop = bgp_keepalives_stop,
};
- frr_pthread_new(&io, "BGP I/O thread", "bgpd_io");
- frr_pthread_new(&ka, "BGP Keepalives thread", "bgpd_ka");
+ bgp_pth_io = frr_pthread_new(&io, "BGP I/O thread", "bgpd_io");
+ bgp_pth_ka = frr_pthread_new(&ka, "BGP Keepalives thread", "bgpd_ka");
}
void bgp_pthreads_run()
{
- struct frr_pthread *io = frr_pthread_get(PTHREAD_IO);
- struct frr_pthread *ka = frr_pthread_get(PTHREAD_KEEPALIVES);
-
- frr_pthread_run(io, NULL);
- frr_pthread_run(ka, NULL);
+ frr_pthread_run(bgp_pth_io, NULL);
+ frr_pthread_run(bgp_pth_ka, NULL);
/* Wait until threads are ready. */
- frr_pthread_wait_running(io);
- frr_pthread_wait_running(ka);
+ frr_pthread_wait_running(bgp_pth_io);
+ frr_pthread_wait_running(bgp_pth_ka);
}
void bgp_pthreads_finish()
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index ebcb9b5ea..861435c03 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -24,6 +24,7 @@
#include "qobj.h"
#include <pthread.h>
+#include "frr_pthread.h"
#include "lib/json.h"
#include "vrf.h"
#include "vty.h"
@@ -97,6 +98,9 @@ enum bgp_af_index {
for (afi = AFI_IP; afi < AFI_MAX; afi++) \
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
+extern struct frr_pthread *bgp_pth_io;
+extern struct frr_pthread *bgp_pth_ka;
+
/* BGP master for system wide configurations and variables. */
struct bgp_master {
/* BGP instance list. */
@@ -105,10 +109,6 @@ struct bgp_master {
/* BGP thread master. */
struct thread_master *master;
-/* BGP pthreads. */
-#define PTHREAD_IO (1 << 1)
-#define PTHREAD_KEEPALIVES (1 << 2)
-
/* work queues */
struct work_queue *process_main_queue;