@Test public void testBgpNeighborReachability() throws IOException { SortedMap<String, Configuration> configs = generateNetworkWithDuplicates(); Batfish batfish = BatfishTestUtils.getBatfish(configs, _folder); batfish.getSettings().setDataplaneEngineName(IncrementalDataPlanePlugin.PLUGIN_NAME); DataPlanePlugin dataPlanePlugin = batfish.getDataPlanePlugin(); ComputeDataPlaneResult result = dataPlanePlugin.computeDataPlane(batfish.getSnapshot()); ValueGraph<BgpPeerConfigId, BgpSessionProperties> bgpTopology = result._topologies.getBgpTopology().getGraph(); Set<Entry<Prefix, BgpActivePeerConfig>> n2Neighbors = configs .get("n2") .getVrfs() .get(DEFAULT_VRF_NAME) .getBgpProcess() .getActiveNeighbors() .entrySet(); Entry<Prefix, BgpActivePeerConfig> e = n2Neighbors.iterator().next(); assertThat(n2Neighbors, hasSize(1)); assertThat( bgpTopology.degree(new BgpPeerConfigId("n2", DEFAULT_VRF_NAME, e.getKey(), false)), equalTo(2)); Collection<BgpActivePeerConfig> n1Neighbors = configs .get("n1") .getVrfs() .get(DEFAULT_VRF_NAME) .getBgpProcess() .getActiveNeighbors() .values(); e = n2Neighbors.iterator().next(); assertThat(n1Neighbors, hasSize(1)); assertThat( bgpTopology.degree(new BgpPeerConfigId("n1", DEFAULT_VRF_NAME, e.getKey(), false)), equalTo(0)); }
@Override public ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot) { Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot); Set<BgpAdvertisement> externalAdverts = _batfish.loadExternalBgpAnnouncements(snapshot, configurations); TopologyProvider topologyProvider = _batfish.getTopologyProvider(); TopologyContext topologyContext = TopologyContext.builder() .setIpsecTopology(topologyProvider.getInitialIpsecTopology(snapshot)) .setLayer1LogicalTopology(topologyProvider.getLayer1LogicalTopology(snapshot)) .setLayer2Topology(topologyProvider.getInitialLayer2Topology(snapshot)) .setLayer3Topology(topologyProvider.getInitialLayer3Topology(snapshot)) .setOspfTopology(topologyProvider.getInitialOspfTopology(snapshot)) .setRawLayer1PhysicalTopology(topologyProvider.getRawLayer1PhysicalTopology(snapshot)) .build(); ComputeDataPlaneResult answer = _engine.computeDataPlane(configurations, topologyContext, externalAdverts); _logger.infof( "Generated data-plane for snapshot:%s; iterations:%s", snapshot.getSnapshot(), ((IncrementalBdpAnswerElement) answer._answerElement).getDependentRoutesIterations()); return answer; }
IncrementalDataPlanePlugin extends DataPlanePlugin { @Override public ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot) { Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot); Set<BgpAdvertisement> externalAdverts = _batfish.loadExternalBgpAnnouncements(snapshot, configurations); TopologyProvider topologyProvider = _batfish.getTopologyProvider(); TopologyContext topologyContext = TopologyContext.builder() .setIpsecTopology(topologyProvider.getInitialIpsecTopology(snapshot)) .setLayer1LogicalTopology(topologyProvider.getLayer1LogicalTopology(snapshot)) .setLayer2Topology(topologyProvider.getInitialLayer2Topology(snapshot)) .setLayer3Topology(topologyProvider.getInitialLayer3Topology(snapshot)) .setOspfTopology(topologyProvider.getInitialOspfTopology(snapshot)) .setRawLayer1PhysicalTopology(topologyProvider.getRawLayer1PhysicalTopology(snapshot)) .build(); ComputeDataPlaneResult answer = _engine.computeDataPlane(configurations, topologyContext, externalAdverts); _logger.infof( "Generated data-plane for snapshot:%s; iterations:%s", snapshot.getSnapshot(), ((IncrementalBdpAnswerElement) answer._answerElement).getDependentRoutesIterations()); return answer; } }
IncrementalDataPlanePlugin extends DataPlanePlugin { @Override public ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot) { Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot); Set<BgpAdvertisement> externalAdverts = _batfish.loadExternalBgpAnnouncements(snapshot, configurations); TopologyProvider topologyProvider = _batfish.getTopologyProvider(); TopologyContext topologyContext = TopologyContext.builder() .setIpsecTopology(topologyProvider.getInitialIpsecTopology(snapshot)) .setLayer1LogicalTopology(topologyProvider.getLayer1LogicalTopology(snapshot)) .setLayer2Topology(topologyProvider.getInitialLayer2Topology(snapshot)) .setLayer3Topology(topologyProvider.getInitialLayer3Topology(snapshot)) .setOspfTopology(topologyProvider.getInitialOspfTopology(snapshot)) .setRawLayer1PhysicalTopology(topologyProvider.getRawLayer1PhysicalTopology(snapshot)) .build(); ComputeDataPlaneResult answer = _engine.computeDataPlane(configurations, topologyContext, externalAdverts); _logger.infof( "Generated data-plane for snapshot:%s; iterations:%s", snapshot.getSnapshot(), ((IncrementalBdpAnswerElement) answer._answerElement).getDependentRoutesIterations()); return answer; } IncrementalDataPlanePlugin(); }
IncrementalDataPlanePlugin extends DataPlanePlugin { @Override public ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot) { Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot); Set<BgpAdvertisement> externalAdverts = _batfish.loadExternalBgpAnnouncements(snapshot, configurations); TopologyProvider topologyProvider = _batfish.getTopologyProvider(); TopologyContext topologyContext = TopologyContext.builder() .setIpsecTopology(topologyProvider.getInitialIpsecTopology(snapshot)) .setLayer1LogicalTopology(topologyProvider.getLayer1LogicalTopology(snapshot)) .setLayer2Topology(topologyProvider.getInitialLayer2Topology(snapshot)) .setLayer3Topology(topologyProvider.getInitialLayer3Topology(snapshot)) .setOspfTopology(topologyProvider.getInitialOspfTopology(snapshot)) .setRawLayer1PhysicalTopology(topologyProvider.getRawLayer1PhysicalTopology(snapshot)) .build(); ComputeDataPlaneResult answer = _engine.computeDataPlane(configurations, topologyContext, externalAdverts); _logger.infof( "Generated data-plane for snapshot:%s; iterations:%s", snapshot.getSnapshot(), ((IncrementalBdpAnswerElement) answer._answerElement).getDependentRoutesIterations()); return answer; } IncrementalDataPlanePlugin(); @Override ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot); @Override String getName(); }
IncrementalDataPlanePlugin extends DataPlanePlugin { @Override public ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot) { Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot); Set<BgpAdvertisement> externalAdverts = _batfish.loadExternalBgpAnnouncements(snapshot, configurations); TopologyProvider topologyProvider = _batfish.getTopologyProvider(); TopologyContext topologyContext = TopologyContext.builder() .setIpsecTopology(topologyProvider.getInitialIpsecTopology(snapshot)) .setLayer1LogicalTopology(topologyProvider.getLayer1LogicalTopology(snapshot)) .setLayer2Topology(topologyProvider.getInitialLayer2Topology(snapshot)) .setLayer3Topology(topologyProvider.getInitialLayer3Topology(snapshot)) .setOspfTopology(topologyProvider.getInitialOspfTopology(snapshot)) .setRawLayer1PhysicalTopology(topologyProvider.getRawLayer1PhysicalTopology(snapshot)) .build(); ComputeDataPlaneResult answer = _engine.computeDataPlane(configurations, topologyContext, externalAdverts); _logger.infof( "Generated data-plane for snapshot:%s; iterations:%s", snapshot.getSnapshot(), ((IncrementalBdpAnswerElement) answer._answerElement).getDependentRoutesIterations()); return answer; } IncrementalDataPlanePlugin(); @Override ComputeDataPlaneResult computeDataPlane(NetworkSnapshot snapshot); @Override String getName(); static final String PLUGIN_NAME; }