zebra: Only free if rule was found/release in table

We were seeing a double free on shutdown if the
hash release fails here due to the interface state
changing. We probably shouldn't free the data if its
still being handled in the table so adding a check there
and a debug message.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
Stephen Worley 2019-10-15 13:42:15 -04:00
parent bfc2d87696
commit c4097b758e

View File

@ -471,8 +471,12 @@ static void zebra_pbr_cleanup_rules(struct hash_bucket *b, void *data)
if (rule->sock == *sock) {
(void)kernel_del_pbr_rule(rule);
hash_release(zrouter.rules_hash, rule);
XFREE(MTYPE_TMP, rule);
if (hash_release(zrouter.rules_hash, rule))
XFREE(MTYPE_TMP, rule);
else
zlog_debug(
"%s: Rule seq: %u is being cleaned but we can't find it in our tables",
__func__, rule->rule.seq);
}
}