diff options
author | Reuben Dowle <reuben.dowle@4rf.com> | 2020-12-07 04:35:13 +0100 |
---|---|---|
committer | Reuben Dowle <reuben.dowle@4rf.com> | 2020-12-16 22:17:13 +0100 |
commit | ee72f0a0eb93038ef6dfd01fed9f32e24c5de2a1 (patch) | |
tree | 6d5313869a1bfa59546eec1470e7f3ab9ff12762 /nhrpd/nhrp_nhs.c | |
parent | nhrpd: Only create one child sa (diff) | |
download | frr-ee72f0a0eb93038ef6dfd01fed9f32e24c5de2a1.tar.xz frr-ee72f0a0eb93038ef6dfd01fed9f32e24c5de2a1.zip |
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_nhs.c')
-rwxr-xr-x | nhrpd/nhrp_nhs.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index 286b0f982..540708f1a 100755 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -382,6 +382,24 @@ int nhrp_nhs_free(struct nhrp_nhs *nhs) return 0; } +void nhrp_nhs_interface_del(struct interface *ifp) +{ + struct nhrp_interface *nifp = ifp->info; + struct nhrp_nhs *nhs, *tmp; + afi_t afi; + + for (afi = 0; afi < AFI_MAX; afi++) { + debugf(NHRP_DEBUG_COMMON, "Cleaning up nhs entries (%d)", + !list_empty(&nifp->afi[afi].nhslist_head)); + + list_for_each_entry_safe(nhs, tmp, &nifp->afi[afi].nhslist_head, + nhslist_entry) + { + nhrp_nhs_free(nhs); + } + } +} + void nhrp_nhs_terminate(void) { struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); |