Skip to content

Commit

Permalink
[vnetorch] [vxlanorch] fix a set of memory usage issues (sonic-net#2352)
Browse files Browse the repository at this point in the history
* [vnetorch] fix use-after-free in removeBfdSession()
* using a copy of monitor ip instead of a reference since the reference gets invalidated after the endpoint is erased

Signed-off-by: Yakiv Huryk <[email protected]>
  • Loading branch information
Yakiv-Huryk authored Jun 29, 2022
1 parent 1aaccd6 commit a8e238a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion orchagent/vnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,8 @@ void VNetRouteOrch::delEndpointMonitor(const string& vnet, NextHopGroupKey& next
if (nexthop_info_[vnet].find(ip) != nexthop_info_[vnet].end()) {
if (--nexthop_info_[vnet][ip].ref_count == 0)
{
removeBfdSession(vnet, nhk, nexthop_info_[vnet][ip].monitor_addr);
IpAddress monitor_addr = nexthop_info_[vnet][ip].monitor_addr;
removeBfdSession(vnet, nhk, monitor_addr);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,13 +1110,14 @@ void VxlanTunnel::updateRemoteEndPointIpRef(const std::string remote_vtep, bool
it->second.ip_refcnt++;
}
SWSS_LOG_DEBUG("Incrementing remote end point %s reference to %d", remote_vtep.c_str(),
it->second.ip_refcnt);
tnl_users_[remote_vtep].ip_refcnt);
}
else
{
if (it == tnl_users_.end())
{
SWSS_LOG_ERROR("Cannot decrement ref. End point not referenced %s", remote_vtep.c_str());
return;
}
it->second.ip_refcnt--;

Expand Down

0 comments on commit a8e238a

Please sign in to comment.