mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-25 12:18:43 +00:00
Merge pull request #14907 from Keelan10/bgp_srv6-leak
bgpd: Free Memory for SRv6 Functions and Locator Chunks
This commit is contained in:
commit
3ed1bc81be
@ -596,6 +596,11 @@ static void sid_register(struct bgp *bgp, const struct in6_addr *sid,
|
|||||||
listnode_add(bgp->srv6_functions, func);
|
listnode_add(bgp->srv6_functions, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void srv6_function_free(struct bgp_srv6_function *func)
|
||||||
|
{
|
||||||
|
XFREE(MTYPE_BGP_SRV6_FUNCTION, func);
|
||||||
|
}
|
||||||
|
|
||||||
void sid_unregister(struct bgp *bgp, const struct in6_addr *sid)
|
void sid_unregister(struct bgp *bgp, const struct in6_addr *sid)
|
||||||
{
|
{
|
||||||
struct listnode *node, *nnode;
|
struct listnode *node, *nnode;
|
||||||
@ -604,7 +609,7 @@ void sid_unregister(struct bgp *bgp, const struct in6_addr *sid)
|
|||||||
for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func))
|
for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func))
|
||||||
if (sid_same(&func->sid, sid)) {
|
if (sid_same(&func->sid, sid)) {
|
||||||
listnode_delete(bgp->srv6_functions, func);
|
listnode_delete(bgp->srv6_functions, func);
|
||||||
XFREE(MTYPE_BGP_SRV6_FUNCTION, func);
|
srv6_function_free(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ static int bgp_srv6_locator_unset(struct bgp *bgp)
|
|||||||
/* refresh functions */
|
/* refresh functions */
|
||||||
for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) {
|
for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) {
|
||||||
listnode_delete(bgp->srv6_functions, func);
|
listnode_delete(bgp->srv6_functions, func);
|
||||||
XFREE(MTYPE_BGP_SRV6_FUNCTION, func);
|
srv6_function_free(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* refresh tovpn_sid */
|
/* refresh tovpn_sid */
|
||||||
|
@ -3213,7 +3213,7 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS)
|
|||||||
if (prefix_match((struct prefix *)&loc.prefix,
|
if (prefix_match((struct prefix *)&loc.prefix,
|
||||||
(struct prefix *)&tmp_prefi)) {
|
(struct prefix *)&tmp_prefi)) {
|
||||||
listnode_delete(bgp->srv6_functions, func);
|
listnode_delete(bgp->srv6_functions, func);
|
||||||
XFREE(MTYPE_BGP_SRV6_FUNCTION, func);
|
srv6_function_free(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1427,7 +1427,9 @@ static void bgp_srv6_init(struct bgp *bgp)
|
|||||||
bgp->srv6_enabled = false;
|
bgp->srv6_enabled = false;
|
||||||
memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name));
|
memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name));
|
||||||
bgp->srv6_locator_chunks = list_new();
|
bgp->srv6_locator_chunks = list_new();
|
||||||
|
bgp->srv6_locator_chunks->del = srv6_locator_chunk_list_free;
|
||||||
bgp->srv6_functions = list_new();
|
bgp->srv6_functions = list_new();
|
||||||
|
bgp->srv6_functions->del = (void (*)(void *))srv6_function_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgp_srv6_cleanup(struct bgp *bgp)
|
static void bgp_srv6_cleanup(struct bgp *bgp)
|
||||||
|
@ -2739,6 +2739,9 @@ extern bool bgp_path_attribute_discard(struct peer *peer, char *buf,
|
|||||||
size_t size);
|
size_t size);
|
||||||
extern bool bgp_path_attribute_treat_as_withdraw(struct peer *peer, char *buf,
|
extern bool bgp_path_attribute_treat_as_withdraw(struct peer *peer, char *buf,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
|
extern void srv6_function_free(struct bgp_srv6_function *func);
|
||||||
|
|
||||||
#ifdef _FRR_ATTRIBUTE_PRINTFRR
|
#ifdef _FRR_ATTRIBUTE_PRINTFRR
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
#pragma FRR printfrr_ext "%pBP" (struct peer *)
|
#pragma FRR printfrr_ext "%pBP" (struct peer *)
|
||||||
|
@ -108,7 +108,7 @@ const char *seg6local_context2str(char *str, size_t size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void srv6_locator_chunk_list_free(void *data)
|
void srv6_locator_chunk_list_free(void *data)
|
||||||
{
|
{
|
||||||
struct srv6_locator_chunk *chunk = data;
|
struct srv6_locator_chunk *chunk = data;
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ int snprintf_seg6_segs(char *str,
|
|||||||
extern struct srv6_locator *srv6_locator_alloc(const char *name);
|
extern struct srv6_locator *srv6_locator_alloc(const char *name);
|
||||||
extern struct srv6_locator_chunk *srv6_locator_chunk_alloc(void);
|
extern struct srv6_locator_chunk *srv6_locator_chunk_alloc(void);
|
||||||
extern void srv6_locator_free(struct srv6_locator *locator);
|
extern void srv6_locator_free(struct srv6_locator *locator);
|
||||||
|
extern void srv6_locator_chunk_list_free(void *data);
|
||||||
extern void srv6_locator_chunk_free(struct srv6_locator_chunk **chunk);
|
extern void srv6_locator_chunk_free(struct srv6_locator_chunk **chunk);
|
||||||
json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk);
|
json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk);
|
||||||
json_object *srv6_locator_json(const struct srv6_locator *loc);
|
json_object *srv6_locator_json(const struct srv6_locator *loc);
|
||||||
|
Loading…
Reference in New Issue
Block a user