Merge pull request #3154 from donaldsharp/bgp_mem_lem

Bgp mem issue with martian address interface strings
This commit is contained in:
Renato Westphal 2018-10-10 13:08:28 -03:00 committed by GitHub
commit e7fb64387c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,8 @@
#include "zebra/rib.h" #include "zebra/rib.h"
#include "zebra/zserv.h" /* For ZEBRA_SERV_PATH. */ #include "zebra/zserv.h" /* For ZEBRA_SERV_PATH. */
DEFINE_MTYPE_STATIC(BGPD, MARTIAN_STRING, "BGP Martian Address Intf String");
char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size) char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size)
{ {
prefix2str(&(bnc->node->p), buf, size); prefix2str(&(bnc->node->p), buf, size);
@ -205,7 +207,7 @@ static void bgp_address_hash_string_del(void *val)
{ {
char *data = val; char *data = val;
XFREE(MTYPE_TMP, data); XFREE(MTYPE_MARTIAN_STRING, data);
} }
static void *bgp_address_hash_alloc(void *p) static void *bgp_address_hash_alloc(void *p)
@ -278,7 +280,7 @@ static void bgp_address_add(struct bgp *bgp, struct connected *ifc,
break; break;
} }
if (!node) { if (!node) {
name = XSTRDUP(MTYPE_TMP, ifc->ifp->name); name = XSTRDUP(MTYPE_MARTIAN_STRING, ifc->ifp->name);
listnode_add(addr->ifp_name_list, name); listnode_add(addr->ifp_name_list, name);
} }
} }
@ -303,8 +305,10 @@ static void bgp_address_del(struct bgp *bgp, struct connected *ifc,
break; break;
} }
if (node) if (node) {
list_delete_node(addr->ifp_name_list, node); list_delete_node(addr->ifp_name_list, node);
XFREE(MTYPE_MARTIAN_STRING, name);
}
if (addr->ifp_name_list->count == 0) { if (addr->ifp_name_list->count == 0) {
hash_release(bgp->address_hash, addr); hash_release(bgp->address_hash, addr);