New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BgpTopologyUtils: only check valid candidates for BGP peers #6093
Conversation
With a little pre-work and moving the Host/VRF check up, we can reduce from quadratic to linear complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @corinaminer, @dhalperi, and @progwriter)
a discussion (no related file):
Haven't updated any tests yet. Just an fyi.
Codecov Report
@@ Coverage Diff @@
## master #6093 +/- ##
============================================
- Coverage 72.69% 72.68% -0.01%
+ Complexity 34659 34656 -3
============================================
Files 2815 2815
Lines 141422 141434 +12
Branches 16969 16972 +3
============================================
- Hits 102813 102808 -5
- Misses 30440 30452 +12
- Partials 8169 8174 +5
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dhalperi and @progwriter)
projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/bgp/BgpTopologyUtils.java, line 161 at r1 (raw file):
for (BgpPeerConfigId peer : graph.nodes()) { if (peer.getType() == BgpPeerConfigType.UNNUMBERED) { continue;
Please add comment explaining why unnumbered peers are excluded from receivers
projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/bgp/BgpTopologyUtils.java, line 241 at r1 (raw file):
&& (!checkReachability || isReachableBgpNeighbor( neighborId, candidateId, neighbor, tracerouteEngine)))
This means the traceroute will still be run for every peer in any vrf that owns the initiator's remote IP. We could do better: canInitiateBgpSession()
could be tweaked to return a Multimap<String, String>
representing all VRFs that the initiator's peering request can reach successfully. Then we could use that map in place of possibleVrfs
, and we'd no longer need to check reachability per candidate.
But in the great majority of cases there's probably only one VRF that owns a given IP, and only one compatible peer in that VRF, so your approach wouldn't usually end up running traceroute a lot more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @corinaminer, @dhalperi, and @progwriter)
projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/bgp/BgpTopologyUtils.java, line 161 at r1 (raw file):
Previously, corinaminer (Corina Miner) wrote…
Please add comment explaining why unnumbered peers are excluded from
receivers
Preserved the comment from where this logic originally was.
projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/bgp/BgpTopologyUtils.java, line 241 at r1 (raw file):
Previously, corinaminer (Corina Miner) wrote…
This means the traceroute will still be run for every peer in any vrf that owns the initiator's remote IP. We could do better:
canInitiateBgpSession()
could be tweaked to return aMultimap<String, String>
representing all VRFs that the initiator's peering request can reach successfully. Then we could use that map in place ofpossibleVrfs
, and we'd no longer need to check reachability per candidate.But in the great majority of cases there's probably only one VRF that owns a given IP, and only one compatible peer in that VRF, so your approach wouldn't usually end up running traceroute a lot more.
This PR is not a semantic change, only a trivial reordering of checks to do less work.
Refactoring is out of scope - when we take that on, we should probably reimplement as described in internal bug 2451.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @corinaminer and @progwriter)
a discussion (no related file):
Previously, dhalperi (Dan Halperin) wrote…
Haven't updated any tests yet. Just an fyi.
Seems like none are needed - the larger scale refactoring work would, but this just moves checks earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @progwriter)
With a little pre-work and moving the Host/VRF check up, we can
reduce from quadratic to linear complexity.