diff options
author | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-10-29 17:04:35 +0200 |
---|---|---|
committer | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-10-29 17:04:35 +0200 |
commit | 6946731314fd04c499e576d0e133879f3e9c2edd (patch) | |
tree | 42d1cd47714e42cca90ef6fabb768d17ac3a0ec6 /bgpd/bgp_vty.c | |
parent | Merge pull request #11673 from cscarpitta/srv6-per-vrf-sid (diff) | |
download | frr-6946731314fd04c499e576d0e133879f3e9c2edd.tar.xz frr-6946731314fd04c499e576d0e133879f3e9c2edd.zip |
lib, bgpd: Enhance `srv6_locator_chunk_free()` API
A programmer can use the `srv6_locator_chunk_free()` function to free
the memory allocated for a `struct srv6_locator_chunk`.
The programmer invokes `srv6_locator_chunk_free()` by passing a single
pointer to the `struct srv6_locator_chunk` to be freed.
`srv6_locator_chunk_free()` uses `XFREE()` to free the memory.
It is the responsibility of the programmer to set the
`struct srv6_locator_chunk` pointer to NULL after freeing memory with
`srv6_locator_chunk_free()`.
This commit modifies the `srv6_locator_chunk_free()` function to take a
double pointer instead of a single pointer. In this way, setting the
`struct srv6_locator_chunk` pointer to NULL is no longer the
programmer's responsibility but is the responsibility of
`srv6_locator_chunk_free()`. This prevents programmers from making
mistakes such as forgetting to set the pointer to NULL after invoking
`srv6_locator_chunk_free()`.
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'bgpd/bgp_vty.c')
-rw-r--r-- | bgpd/bgp_vty.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f380460a9..09f4fada8 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -310,7 +310,7 @@ static int bgp_srv6_locator_unset(struct bgp *bgp) /* refresh chunks */ for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) { listnode_delete(bgp->srv6_locator_chunks, chunk); - srv6_locator_chunk_free(chunk); + srv6_locator_chunk_free(&chunk); } /* refresh functions */ @@ -348,7 +348,8 @@ static int bgp_srv6_locator_unset(struct bgp *bgp) tovpn_sid_locator = bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator; if (tovpn_sid_locator) { - srv6_locator_chunk_free(tovpn_sid_locator); + srv6_locator_chunk_free( + &bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator); bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator = NULL; } @@ -356,12 +357,13 @@ static int bgp_srv6_locator_unset(struct bgp *bgp) tovpn_sid_locator = bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid_locator; if (tovpn_sid_locator) { - srv6_locator_chunk_free(tovpn_sid_locator); + srv6_locator_chunk_free(&bgp_vrf->vpn_policy[AFI_IP6] + .tovpn_sid_locator); bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid_locator = NULL; } /* refresh per-vrf tovpn_sid_locator */ - srv6_locator_chunk_free(bgp_vrf->tovpn_sid_locator); + srv6_locator_chunk_free(&bgp_vrf->tovpn_sid_locator); } /* clear locator name */ |