@Test public void testIbgpRejectOwnAs() throws IOException { String testrigName = "ibgp-reject-own-as"; List<String> configurationNames = ImmutableList.of("r1", "r2a", "r2b"); Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText( TestrigText.builder() .setConfigurationFiles(TESTRIGS_PREFIX + testrigName, configurationNames) .build(), _folder); batfish.getSettings().setDataplaneEngineName(IncrementalDataPlanePlugin.PLUGIN_NAME); DataPlanePlugin dataPlanePlugin = batfish.getDataPlanePlugin(); ComputeDataPlaneResult dp = dataPlanePlugin.computeDataPlane(batfish.getSnapshot()); SortedMap<String, SortedMap<String, GenericRib<AnnotatedRoute<AbstractRoute>>>> ribs = dp._dataPlane.getRibs(); Set<AbstractRoute> r2aRoutes = ribs.get("r2a").get(DEFAULT_VRF_NAME).getRoutes(); Set<AbstractRoute> r2bRoutes = ribs.get("r2b").get(DEFAULT_VRF_NAME).getRoutes(); Set<Prefix> r2aPrefixes = r2aRoutes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet()); Set<Prefix> r2bPrefixes = r2bRoutes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet()); Prefix r1Loopback0Prefix = Prefix.parse("1.0.0.1/32"); Prefix r1Loopback1Prefix = Prefix.parse("1.0.0.2/32"); assertTrue(r2aPrefixes.contains(r1Loopback0Prefix)); assertTrue(r2aPrefixes.contains(r1Loopback1Prefix)); assertTrue(r2bPrefixes.contains(r1Loopback1Prefix)); assertFalse(r2bPrefixes.contains(r1Loopback0Prefix)); }
@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; }