use of org.batfish.datamodel.collections.NodeInterfacePair in project batfish by batfish.
the class ElasticsearchDomainTest method testEsSubnetEdge.
@Test
public void testEsSubnetEdge() throws IOException {
Map<String, Configuration> configurations = loadAwsConfigurations();
Topology topology = CommonUtil.synthesizeTopology(configurations);
// check that ES instance is a neighbor of both subnets in which its interfaces are
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-073b8061", "subnet-073b8061"), new NodeInterfacePair("es-domain", "es-domain-subnet-073b8061"))));
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-1f315846", "subnet-1f315846"), new NodeInterfacePair("es-domain", "es-domain-subnet-1f315846"))));
}
use of org.batfish.datamodel.collections.NodeInterfacePair in project batfish by batfish.
the class RdsInstanceTest method testRdsSubnetEdge.
@Test
public void testRdsSubnetEdge() throws IOException {
Map<String, Configuration> configurations = loadAwsConfigurations();
Topology topology = CommonUtil.synthesizeTopology(configurations);
// check that RDS instance is a neighbor of both subnets in which its interfaces are
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-073b8061", "subnet-073b8061"), new NodeInterfacePair("test-rds", "test-rds-subnet-073b8061"))));
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-1f315846", "subnet-1f315846"), new NodeInterfacePair("test-rds", "test-rds-subnet-1f315846"))));
}
use of org.batfish.datamodel.collections.NodeInterfacePair in project batfish by batfish.
the class BdpEngine method neighborUnreachableTrace.
private FlowTrace neighborUnreachableTrace(List<FlowTraceHop> completedHops, NodeInterfacePair srcInterface, SortedSet<String> routes, Flow originalFlow, Flow transformedFlow) {
Edge neighborUnreachbleEdge = new Edge(srcInterface, new NodeInterfacePair(Configuration.NODE_NONE_NAME, Interface.NULL_INTERFACE_NAME));
FlowTraceHop neighborUnreachableHop = new FlowTraceHop(neighborUnreachbleEdge, routes, hopFlow(originalFlow, transformedFlow));
List<FlowTraceHop> newHops = new ArrayList<>(completedHops);
newHops.add(neighborUnreachableHop);
FlowTrace trace = new FlowTrace(FlowDisposition.NEIGHBOR_UNREACHABLE_OR_EXITS_NETWORK, newHops, FlowDisposition.NEIGHBOR_UNREACHABLE_OR_EXITS_NETWORK.toString());
return trace;
}
use of org.batfish.datamodel.collections.NodeInterfacePair in project batfish by batfish.
the class ForwardingAnalysisImpl method computeRoutesWithDestIpEdge.
@VisibleForTesting
Map<Edge, Set<AbstractRoute>> computeRoutesWithDestIpEdge(Map<String, Map<String, Fib>> fibs, Topology topology) {
ImmutableMap.Builder<Edge, Set<AbstractRoute>> routesByEdgeBuilder = ImmutableMap.builder();
_routesWhereDstIpCanBeArpIp.forEach((hostname, routesWhereDstIpCanBeArpIpByVrf) -> routesWhereDstIpCanBeArpIpByVrf.forEach((vrf, routesWhereDstIpCanBeArpIpByOutInterface) -> routesWhereDstIpCanBeArpIpByOutInterface.forEach((outInterface, routes) -> {
NodeInterfacePair out = new NodeInterfacePair(hostname, outInterface);
Set<NodeInterfacePair> receivers = topology.getNeighbors(out);
receivers.forEach(receiver -> routesByEdgeBuilder.put(new Edge(out, receiver), routes));
})));
return routesByEdgeBuilder.build();
}
use of org.batfish.datamodel.collections.NodeInterfacePair in project batfish by batfish.
the class Batfish method reducedReachability.
@Override
public AnswerElement reducedReachability(ReachabilitySettings reachabilitySettings) {
Settings settings = getSettings();
checkDifferentialDataPlaneQuestionDependencies();
String tag = getDifferentialFlowTag();
// load base configurations and generate base data plane
pushBaseEnvironment();
Map<String, Configuration> baseConfigurations = loadConfigurations();
Synthesizer baseDataPlaneSynthesizer = synthesizeDataPlane();
popEnvironment();
// load diff configurations and generate diff data plane
pushDeltaEnvironment();
Map<String, Configuration> diffConfigurations = loadConfigurations();
Synthesizer diffDataPlaneSynthesizer = synthesizeDataPlane();
popEnvironment();
Set<String> ingressNodes;
try {
ingressNodes = ImmutableSet.copyOf(Sets.intersection(reachabilitySettings.computeActiveIngressNodes(baseConfigurations), reachabilitySettings.computeActiveIngressNodes(diffConfigurations)));
} catch (InvalidReachabilitySettingsException e) {
return e.getInvalidSettingsAnswer();
}
pushDeltaEnvironment();
SortedSet<String> blacklistNodes = getNodeBlacklist();
Set<NodeInterfacePair> blacklistInterfaces = getInterfaceBlacklist();
SortedSet<Edge> blacklistEdges = getEdgeBlacklist();
popEnvironment();
BlacklistDstIpQuerySynthesizer blacklistQuery = new BlacklistDstIpQuerySynthesizer(null, blacklistNodes, blacklistInterfaces, blacklistEdges, baseConfigurations);
// compute composite program and flows
List<Synthesizer> synthesizers = ImmutableList.of(baseDataPlaneSynthesizer, diffDataPlaneSynthesizer, baseDataPlaneSynthesizer);
// generate base reachability and diff blackhole and blacklist queries
List<CompositeNodJob> jobs = ingressNodes.stream().flatMap(node -> baseConfigurations.get(node).getVrfs().keySet().stream().map(vrf -> {
Map<String, Set<String>> ingressNodeVrfs = ImmutableMap.of(node, ImmutableSet.of(vrf));
StandardReachabilityQuerySynthesizer acceptQuery = StandardReachabilityQuerySynthesizer.builder().setActions(ImmutableSet.of(ForwardingAction.ACCEPT, ForwardingAction.NEIGHBOR_UNREACHABLE_OR_EXITS_NETWORK)).setHeaderSpace(reachabilitySettings.getHeaderSpace()).setIngressNodeVrfs(ingressNodeVrfs).setFinalNodes(ImmutableSet.of()).setTransitNodes(ImmutableSet.of()).setNonTransitNodes(ImmutableSet.of()).setSrcNatted(reachabilitySettings.getSrcNatted()).build();
StandardReachabilityQuerySynthesizer notAcceptQuery = StandardReachabilityQuerySynthesizer.builder().setActions(ImmutableSet.of(ForwardingAction.ACCEPT, ForwardingAction.NEIGHBOR_UNREACHABLE_OR_EXITS_NETWORK)).setHeaderSpace(new HeaderSpace()).setIngressNodeVrfs(ingressNodeVrfs).setFinalNodes(ImmutableSet.of()).setTransitNodes(ImmutableSet.of()).setNonTransitNodes(ImmutableSet.of()).build();
notAcceptQuery.setNegate(true);
SortedSet<Pair<String, String>> nodes = ImmutableSortedSet.of(new Pair<>(node, vrf));
List<QuerySynthesizer> queries = ImmutableList.of(acceptQuery, notAcceptQuery, blacklistQuery);
return new CompositeNodJob(settings, synthesizers, queries, nodes, tag);
})).collect(Collectors.toList());
// TODO: maybe do something with nod answer element
Set<Flow> flows = computeCompositeNodOutput(jobs, new NodAnswerElement());
pushBaseEnvironment();
getDataPlanePlugin().processFlows(flows, loadDataPlane());
popEnvironment();
pushDeltaEnvironment();
getDataPlanePlugin().processFlows(flows, loadDataPlane());
popEnvironment();
AnswerElement answerElement = getHistory();
return answerElement;
}
Aggregations