summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2018-07-25 18:39:58 +0200
committerRafael Zalamena <rzalamena@opensourcerouting.org>2018-08-08 23:25:08 +0200
commit788378fefac03d0a51be8409b4d0d20b723ca234 (patch)
treea38f7328f838e35ebb4e7ab818fbe918e33517d9 /zebra
parentbfdd: improve logging messages (diff)
downloadfrr-788378fefac03d0a51be8409b4d0d20b723ca234.tar.xz
frr-788378fefac03d0a51be8409b4d0d20b723ca234.zip
bfdd: clean-up bfd clients data on shutdown
On `zebra` / `bfdd` shutdown we now clean up all client data to avoid memory leaks (ghost clients). This also prevents 'slow' shutdown on `zebra` sparing us from seeing some rare topotests shutdown failures (signal handler getting stopped by signal). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/zebra_ptm.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index 76e427570..cc2d5d411 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -1175,6 +1175,7 @@ DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_PTM_BFD_PROCESS,
static struct ptm_process *pp_new(pid_t pid, struct zserv *zs);
static struct ptm_process *pp_lookup_byzs(struct zserv *zs);
static void pp_free(struct ptm_process *pp);
+static void pp_free_all(void);
static void zebra_ptm_send_bfdd(struct stream *msg);
static void zebra_ptm_send_clients(struct stream *msg);
@@ -1239,6 +1240,16 @@ static void pp_free(struct ptm_process *pp)
XFREE(MTYPE_ZEBRA_PTM_BFD_PROCESS, pp);
}
+static void pp_free_all(void)
+{
+ struct ptm_process *pp;
+
+ while (!TAILQ_EMPTY(&ppqueue)) {
+ pp = TAILQ_FIRST(&ppqueue);
+ pp_free(pp);
+ }
+}
+
/*
* Use the FRR's internal daemon implementation.
@@ -1385,6 +1396,13 @@ void zebra_ptm_init(void)
hook_register(zserv_client_close, _zebra_ptm_bfd_client_deregister);
}
+void zebra_ptm_finish(void)
+{
+ /* Remove the client disconnect hook and free all memory. */
+ hook_unregister(zserv_client_close, _zebra_ptm_bfd_client_deregister);
+ pp_free_all();
+}
+
/*
* Message handling.
@@ -1528,10 +1546,6 @@ void zebra_ptm_bfd_dst_replay(ZAPI_HANDLER_ARGS)
/*
* Unused functions.
*/
-void zebra_ptm_finish(void)
-{
- /* NOTHING */
-}
void zebra_ptm_if_init(struct zebra_if *zifp __attribute__((__unused__)))
{
/* NOTHING */