Search in sources :

Example 1 with NodeDropNoRoute

use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitNodeDropNoRoute.

@Test
public void testVisitNodeDropNoRoute() {
    SynthesizerInput input = MockSynthesizerInput.builder().setRoutableIps(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, B1, VRF2, B2), NODE2, ImmutableMap.of(VRF1, B1, VRF2, B2))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDropNoRoute.State.INSTANCE)));
    // DestinationRouting
    assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeDropNoRoute(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B2), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeDropNoRoute(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B1), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeDropNoRoute(NODE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B2), ImmutableSet.of(new PostInVrf(NODE2, VRF2), new PreOut(NODE2)), new NodeDropNoRoute(NODE2))));
}
Also used : PreOut(org.batfish.z3.state.PreOut) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NotExpr(org.batfish.z3.expr.NotExpr) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 2 with NodeDropNoRoute

use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitNodeDrop.

@Test
public void testVisitNodeDrop() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDrop.State.INSTANCE)));
    // CopyNodeDropAcl
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropAcl(NODE1), new NodeDrop(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropAcl(NODE2), new NodeDrop(NODE2))));
    // CopyNodeDropNoRoute
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE1), new NodeDrop(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE2), new NodeDrop(NODE2))));
    // CopyNodeDropNullRoute
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNullRoute(NODE1), new NodeDrop(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNullRoute(NODE2), new NodeDrop(NODE2))));
}
Also used : NodeDropAcl(org.batfish.z3.state.NodeDropAcl) NodeDrop(org.batfish.z3.state.NodeDrop) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 3 with NodeDropNoRoute

use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitDropNoRoute.

@Test
public void testVisitDropNoRoute() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(DropNoRoute.State.INSTANCE)));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE1), DropNoRoute.INSTANCE)));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE2), DropNoRoute.INSTANCE)));
}
Also used : NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 4 with NodeDropNoRoute

use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.

the class DefaultTransitionGenerator method visitNodeDrop.

@Override
public void visitNodeDrop(NodeDrop.State nodeDrop) {
    // CopyNodeDropAcl
    _input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropAcl(hostname), new NodeDrop(hostname))).forEach(_rules::add);
    // CopyNodeDropNoRoute
    _input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropNoRoute(hostname), new NodeDrop(hostname))).forEach(_rules::add);
    // CopyNodeDropNullRoute
    _input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropNullRoute(hostname), new NodeDrop(hostname))).forEach(_rules::add);
}
Also used : DropAclIn(org.batfish.z3.state.DropAclIn) NodeDropAclOut(org.batfish.z3.state.NodeDropAclOut) AclLineMatch(org.batfish.z3.state.AclLineMatch) Drop(org.batfish.z3.state.Drop) NodeDropAcl(org.batfish.z3.state.NodeDropAcl) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NumberedQuery(org.batfish.z3.state.NumberedQuery) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PostIn(org.batfish.z3.state.PostIn) AclLineNoMatch(org.batfish.z3.state.AclLineNoMatch) HeaderSpaceMatchExpr(org.batfish.z3.expr.HeaderSpaceMatchExpr) State(org.batfish.z3.expr.StateExpr.State) Originate(org.batfish.z3.state.Originate) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) Query(org.batfish.z3.state.Query) PostOutEdge(org.batfish.z3.state.PostOutEdge) List(java.util.List) PreOutEdgePostNat(org.batfish.z3.state.PreOutEdgePostNat) OriginateVrf(org.batfish.z3.state.OriginateVrf) PreOutEdge(org.batfish.z3.state.PreOutEdge) Entry(java.util.Map.Entry) NodeDrop(org.batfish.z3.state.NodeDrop) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) IpWildcard(org.batfish.datamodel.IpWildcard) TransformationHeaderField(org.batfish.z3.TransformationHeaderField) TrueExpr(org.batfish.z3.expr.TrueExpr) DropAcl(org.batfish.z3.state.DropAcl) DropNullRoute(org.batfish.z3.state.DropNullRoute) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) NodeAccept(org.batfish.z3.state.NodeAccept) ImmutableList(com.google.common.collect.ImmutableList) StateExpr(org.batfish.z3.expr.StateExpr) LineAction(org.batfish.datamodel.LineAction) RuleStatement(org.batfish.z3.expr.RuleStatement) DropAclOut(org.batfish.z3.state.DropAclOut) Debug(org.batfish.z3.state.Debug) DropNoRoute(org.batfish.z3.state.DropNoRoute) BooleanExpr(org.batfish.z3.expr.BooleanExpr) Accept(org.batfish.z3.state.Accept) NodeDropAclIn(org.batfish.z3.state.NodeDropAclIn) PreOut(org.batfish.z3.state.PreOut) AclDeny(org.batfish.z3.state.AclDeny) NotExpr(org.batfish.z3.expr.NotExpr) AclPermit(org.batfish.z3.state.AclPermit) VarIntExpr(org.batfish.z3.expr.VarIntExpr) PreInInterface(org.batfish.z3.state.PreInInterface) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NeighborUnreachable(org.batfish.z3.state.NeighborUnreachable) EqExpr(org.batfish.z3.expr.EqExpr) PostInInterface(org.batfish.z3.state.PostInInterface) NodeDropAcl(org.batfish.z3.state.NodeDropAcl) NodeDrop(org.batfish.z3.state.NodeDrop) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement)

Example 5 with NodeDropNoRoute

use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.

the class StandardReachabilityQuerySynthesizer method computeFinalActions.

/**
 * Create query condition for action at final node(s)
 */
private List<StateExpr> computeFinalActions() {
    ImmutableList.Builder<StateExpr> finalActionsBuilder = ImmutableList.builder();
    for (ForwardingAction action : _actions) {
        switch(action) {
            case ACCEPT:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr accept = new NodeAccept(finalNode);
                        finalActionsBuilder.add(accept);
                    }
                } else {
                    finalActionsBuilder.add(Accept.INSTANCE);
                }
                break;
            case DEBUG:
                finalActionsBuilder.add(Debug.INSTANCE);
                break;
            case DROP:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeDrop(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(Drop.INSTANCE);
                }
                break;
            case DROP_ACL:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeDropAcl(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(DropAcl.INSTANCE);
                }
                break;
            case DROP_ACL_IN:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeDropAclIn(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(DropAclIn.INSTANCE);
                }
                break;
            case DROP_ACL_OUT:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeDropAclOut(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(DropAclOut.INSTANCE);
                }
                break;
            case DROP_NO_ROUTE:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeDropNoRoute(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(DropNoRoute.INSTANCE);
                }
                break;
            case DROP_NULL_ROUTE:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeDropNullRoute(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(DropNullRoute.INSTANCE);
                }
                break;
            case NEIGHBOR_UNREACHABLE_OR_EXITS_NETWORK:
                if (_finalNodes.size() > 0) {
                    for (String finalNode : _finalNodes) {
                        StateExpr drop = new NodeNeighborUnreachable(finalNode);
                        finalActionsBuilder.add(drop);
                    }
                } else {
                    finalActionsBuilder.add(NeighborUnreachable.INSTANCE);
                }
                break;
            case FORWARD:
            default:
                throw new BatfishException("unsupported action");
        }
    }
    return finalActionsBuilder.build();
}
Also used : ForwardingAction(org.batfish.datamodel.ForwardingAction) NodeDropAcl(org.batfish.z3.state.NodeDropAcl) BatfishException(org.batfish.common.BatfishException) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) ImmutableList(com.google.common.collect.ImmutableList) NodeAccept(org.batfish.z3.state.NodeAccept) StateExpr(org.batfish.z3.expr.StateExpr) NodeDrop(org.batfish.z3.state.NodeDrop) NodeDropAclIn(org.batfish.z3.state.NodeDropAclIn) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) NodeDropAclOut(org.batfish.z3.state.NodeDropAclOut)

Aggregations

NodeDropNoRoute (org.batfish.z3.state.NodeDropNoRoute)5 SynthesizerInput (org.batfish.z3.SynthesizerInput)4 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)4 RuleStatement (org.batfish.z3.expr.RuleStatement)4 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)4 MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)3 NodeDrop (org.batfish.z3.state.NodeDrop)3 NodeDropAcl (org.batfish.z3.state.NodeDropAcl)3 NodeDropNullRoute (org.batfish.z3.state.NodeDropNullRoute)3 ImmutableList (com.google.common.collect.ImmutableList)2 NotExpr (org.batfish.z3.expr.NotExpr)2 StateExpr (org.batfish.z3.expr.StateExpr)2 NodeAccept (org.batfish.z3.state.NodeAccept)2 NodeDropAclIn (org.batfish.z3.state.NodeDropAclIn)2 NodeDropAclOut (org.batfish.z3.state.NodeDropAclOut)2 NodeNeighborUnreachable (org.batfish.z3.state.NodeNeighborUnreachable)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 List (java.util.List)1