pimd: prevent invalid memory access

Signalize termination to functions so they can avoid accessing pointers
that might be no longer available.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2024-09-29 17:31:06 -03:00
parent 2941f579f7
commit 2add05a634
3 changed files with 11 additions and 0 deletions

View file

@ -26,6 +26,8 @@
static void pim_instance_terminate(struct pim_instance *pim)
{
pim->stopping = true;
pim_vxlan_exit(pim);
if (pim->ssm_info) {

View file

@ -192,6 +192,8 @@ struct pim_instance {
uint64_t gm_rx_drop_sys;
bool stopping;
#if PIM_IPV == 6
struct {
/** Embedded RP enable state. */

View file

@ -181,7 +181,14 @@ void tib_sg_gm_prune(struct pim_instance *pim, pim_sgaddr sg,
Making the call to pim_channel_del_oif and ignoring the return code
fixes the issue without ill effect, similar to
pim_forward_stop below.
Also on shutdown when the PIM upstream is removed the channel removal
may have already happened, so just return here instead of trying to
access an invalid pointer.
*/
if (pim->stopping)
return;
result = pim_channel_del_oif(*oilp, oif, PIM_OIF_FLAG_PROTO_GM,
__func__);
if (result) {