summaryrefslogtreecommitdiff
path: root/nhrpd/nhrp_interface.c
diff options
context:
space:
mode:
authorReuben Dowle <reuben.dowle@4rf.com>2020-12-07 16:35:13 +1300
committerReuben Dowle <reuben.dowle@4rf.com>2020-12-17 10:17:13 +1300
commitee72f0a0eb93038ef6dfd01fed9f32e24c5de2a1 (patch)
tree6d5313869a1bfa59546eec1470e7f3ab9ff12762 /nhrpd/nhrp_interface.c
parent6c9ca5876623d3b1e36a3e5684523d9d57845038 (diff)
nhrpd: Cleanup resources when interface is deleted
Currently when an interface is deleted from configuration, associated resources are not freed. This causes memory leaks and crashes. To reproduce this issue: * Connect to a DMVPN hub * Outside of frr, delete the underlying GRE interface * Use 'no interface xxx' to delete the interface containing nhrp configurations Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
Diffstat (limited to 'nhrpd/nhrp_interface.c')
-rwxr-xr-x[-rw-r--r--]nhrpd/nhrp_interface.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 7768383e6b..269499cc59 100644..100755
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -49,6 +49,21 @@ static int nhrp_if_new_hook(struct interface *ifp)
static int nhrp_if_delete_hook(struct interface *ifp)
{
+ struct nhrp_interface *nifp = ifp->info;
+
+ debugf(NHRP_DEBUG_IF, "Deleted interface (%s)", ifp->name);
+
+ nhrp_cache_interface_del(ifp);
+ nhrp_nhs_interface_del(ifp);
+ nhrp_peer_interface_del(ifp);
+
+ if (nifp->ipsec_profile)
+ free(nifp->ipsec_profile);
+ if (nifp->ipsec_fallback_profile)
+ free(nifp->ipsec_fallback_profile);
+ if (nifp->source)
+ free(nifp->source);
+
XFREE(MTYPE_NHRP_IF, ifp->info);
return 0;
}