Skip to content

Commit ea4cba6

Browse files
baiwei0427prsunny
authored andcommitted
[fpmsyncd] Fix memory leak bug (sonic-net#864)
* Fix netlink memory leak of fpmsyncd * Refill netlink cache instead of reallocation * Allocate netlink socket and cache on the constructor function
1 parent 713dee2 commit ea4cba6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fpmsyncd/routesync.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ RouteSync::RouteSync(RedisPipeline *pipeline) :
2121
m_routeTable(pipeline, APP_ROUTE_TABLE_NAME, true),
2222
m_vnet_routeTable(pipeline, APP_VNET_RT_TABLE_NAME, true),
2323
m_vnet_tunnelTable(pipeline, APP_VNET_RT_TUNNEL_TABLE_NAME, true),
24-
m_warmStartHelper(pipeline, &m_routeTable, APP_ROUTE_TABLE_NAME, "bgp", "bgp")
24+
m_warmStartHelper(pipeline, &m_routeTable, APP_ROUTE_TABLE_NAME, "bgp", "bgp"),
25+
m_nl_sock(NULL), m_link_cache(NULL)
2526
{
2627
m_nl_sock = nl_socket_alloc();
2728
nl_connect(m_nl_sock, NETLINK_ROUTE);
@@ -291,7 +292,8 @@ bool RouteSync::getIfName(int if_index, char *if_name, size_t name_len)
291292
/* Cannot get interface name. Possibly the interface gets re-created. */
292293
if (!rtnl_link_i2name(m_link_cache, if_index, if_name, name_len))
293294
{
294-
rtnl_link_alloc_cache(m_nl_sock, AF_UNSPEC, &m_link_cache);
295+
/* Trying to refill cache */
296+
nl_cache_refill(m_nl_sock, m_link_cache);
295297
if (!rtnl_link_i2name(m_link_cache, if_index, if_name, name_len))
296298
{
297299
return false;

0 commit comments

Comments
 (0)