diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2018-07-25 18:39:58 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2018-08-08 23:25:08 +0200 |
commit | 788378fefac03d0a51be8409b4d0d20b723ca234 (patch) | |
tree | a38f7328f838e35ebb4e7ab818fbe918e33517d9 /bfdd/ptm_adapter.c | |
parent | bfdd: improve logging messages (diff) | |
download | frr-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 'bfdd/ptm_adapter.c')
-rw-r--r-- | bfdd/ptm_adapter.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index b2c6b8e2d..ca44be654 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -64,6 +64,7 @@ static int _ptm_msg_read(struct stream *msg, int command, static struct ptm_client *pc_lookup(uint32_t pid); static struct ptm_client *pc_new(uint32_t pid); static void pc_free(struct ptm_client *pc); +static void pc_free_all(void); static struct ptm_client_notification *pcn_new(struct ptm_client *pc, struct bfd_session *bs); static struct ptm_client_notification *pcn_lookup(struct ptm_client *pc, @@ -553,6 +554,9 @@ static void bfdd_zebra_connected(struct zclient *zc) { struct stream *msg = zc->obuf; + /* Clean-up and free ptm clients data memory. */ + pc_free_all(); + /* * The replay is an empty message just to trigger client daemons * configuration replay. @@ -585,6 +589,9 @@ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv) void bfdd_zclient_stop(void) { zclient_stop(zclient); + + /* Clean-up and free ptm clients data memory. */ + pc_free_all(); } @@ -641,6 +648,16 @@ static void pc_free(struct ptm_client *pc) XFREE(MTYPE_BFDD_CONTROL, pc); } +static void pc_free_all(void) +{ + struct ptm_client *pc; + + while (!TAILQ_EMPTY(&pcqueue)) { + pc = TAILQ_FIRST(&pcqueue); + pc_free(pc); + } +} + static struct ptm_client_notification *pcn_new(struct ptm_client *pc, struct bfd_session *bs) { |