pimd: add safety check to OIL add/del

These will corrupt memory if mroute_vif_index is -1 (e.g. interface not
operating.)  That shouldn't happen, but it does while doing development
work, so trip an assert rather than corrupting memory.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2022-03-10 11:22:48 +01:00
parent e576475723
commit d6890c49b2

View File

@ -216,6 +216,10 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
pim_ifp = oif->info;
assertf(pim_ifp->mroute_vif_index >= 0,
"trying to del OIF %s with VIF (%d)", oif->name,
pim_ifp->mroute_vif_index);
/*
* Don't do anything if we've been asked to remove a source
* that is not actually on it.
@ -418,6 +422,10 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
pim_ifp = oif->info;
assertf(pim_ifp->mroute_vif_index >= 0,
"trying to add OIF %s with VIF (%d)", oif->name,
pim_ifp->mroute_vif_index);
/* Prevent single protocol from subscribing same interface to
channel (S,G) multiple times */
if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask) {