Skip to content

Commit

Permalink
fixing [] for the Decision
Browse files Browse the repository at this point in the history
Summary:
in a tricky time, we may use [] to generate a empty loopback address for a node.
Later, when bgp convert this loopback address to a folly::IPAddress, it will crash. Add check here.

Reviewed By: allwync

Differential Revision: D20786262

fbshipit-source-id: afc1e46c897233ca415083fc90873b945a7789cc
  • Loading branch information
Siqiao Chen authored and facebook-github-bot committed Apr 1, 2020
1 parent d6008e8 commit f8651f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openr/decision/PrefixState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ PrefixState::deleteLoopbackPrefix(
auto addrSize = prefix.prefixAddress.addr.size();
if (addrSize == folly::IPAddressV4::byteCount() &&
folly::IPAddressV4::bitCount() == prefix.prefixLength) {
if (prefix.prefixAddress == nodeHostLoopbacksV4_[nodeName]) {
if (nodeHostLoopbacksV4_.find(nodeName) != nodeHostLoopbacksV4_.end() &&
prefix.prefixAddress == nodeHostLoopbacksV4_.at(nodeName)) {
nodeHostLoopbacksV4_.erase(nodeName);
}
}
if (addrSize == folly::IPAddressV6::byteCount() &&
folly::IPAddressV6::bitCount() == prefix.prefixLength) {
if (nodeHostLoopbacksV6_[nodeName] == prefix.prefixAddress) {
if (nodeHostLoopbacksV6_.find(nodeName) != nodeHostLoopbacksV6_.end() &&
nodeHostLoopbacksV6_.at(nodeName) == prefix.prefixAddress) {
nodeHostLoopbacksV6_.erase(nodeName);
}
}
Expand Down

0 comments on commit f8651f2

Please sign in to comment.