Skip to content

Commit

Permalink
Merge pull request #750 from batfish/patch-release-33.3
Browse files Browse the repository at this point in the history
Patch release 33.3
  • Loading branch information
dhalperi committed Dec 13, 2017
2 parents 266b898 + 5e42652 commit b798b77
Show file tree
Hide file tree
Showing 35 changed files with 2,459 additions and 82 deletions.
2 changes: 1 addition & 1 deletion projects/allinone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>allinone</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion projects/batfish-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>batfish-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion projects/batfish-common-protocol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>batfish-common-protocol</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion projects/batfish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>batfish</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import org.batfish.datamodel.routing_policy.expr.Not;
import org.batfish.datamodel.routing_policy.expr.SelfNextHop;
import org.batfish.datamodel.routing_policy.expr.WithEnvironmentExpr;
import org.batfish.datamodel.routing_policy.statement.CallStatement;
import org.batfish.datamodel.routing_policy.statement.If;
import org.batfish.datamodel.routing_policy.statement.SetMetric;
import org.batfish.datamodel.routing_policy.statement.SetNextHop;
Expand Down Expand Up @@ -3280,12 +3281,16 @@ private RouteFilterList toRouteFilterList(PrefixList list) {
}

private RoutingPolicy toRoutingPolicy(final Configuration c, RouteMap map) {
boolean hasContinue =
map.getClauses().values().stream().anyMatch(clause -> clause.getContinueLine() != null);
if (hasContinue) {
return toRoutingPolicies(c, map);
}
RoutingPolicy output = new RoutingPolicy(map.getName(), c);
List<Statement> statements = output.getStatements();
Map<Integer, If> clauses = new HashMap<>();
// descend map so continue targets are available
If followingClause = null;
Integer followingClauseNumber = null;
for (Entry<Integer, RouteMapClause> e : map.getClauses().descendingMap().entrySet()) {
int clauseNumber = e.getKey();
RouteMapClause rmClause = e.getValue();
Expand Down Expand Up @@ -3315,9 +3320,71 @@ private RoutingPolicy toRoutingPolicy(final Configuration c, RouteMap map) {
for (RouteMapSetLine rmSet : rmClause.getSetList()) {
rmSet.applyTo(matchStatements, this, c, _w);
}
switch (rmClause.getAction()) {
case ACCEPT:
matchStatements.add(Statements.ReturnTrue.toStaticStatement());
break;

case REJECT:
matchStatements.add(Statements.ReturnFalse.toStaticStatement());
break;

default:
throw new BatfishException("Invalid action");
}
if (followingClause != null) {
ifExpr.getFalseStatements().add(followingClause);
} else {
ifExpr.getFalseStatements().add(Statements.ReturnLocalDefaultAction.toStaticStatement());
}
followingClause = ifExpr;
}
statements.add(followingClause);
return output;
}

private RoutingPolicy toRoutingPolicies(Configuration c, RouteMap map) {
RoutingPolicy output = new RoutingPolicy(map.getName(), c);
List<Statement> statements = output.getStatements();
Map<Integer, RoutingPolicy> clauses = new HashMap<>();
// descend map so continue targets are available
RoutingPolicy followingClause = null;
Integer followingClauseNumber = null;
for (Entry<Integer, RouteMapClause> e : map.getClauses().descendingMap().entrySet()) {
int clauseNumber = e.getKey();
RouteMapClause rmClause = e.getValue();
String clausePolicyName = getRouteMapClausePolicyName(map, clauseNumber);
Conjunction conj = new Conjunction();
// match ipv4s must be disjoined with match ipv6
Disjunction matchIpOrPrefix = new Disjunction();
for (RouteMapMatchLine rmMatch : rmClause.getMatchList()) {
BooleanExpr matchExpr = rmMatch.toBooleanExpr(c, this, _w);
if (rmMatch instanceof RouteMapMatchIpAccessListLine
|| rmMatch instanceof RouteMapMatchIpPrefixListLine
|| rmMatch instanceof RouteMapMatchIpv6AccessListLine
|| rmMatch instanceof RouteMapMatchIpv6PrefixListLine) {
matchIpOrPrefix.getDisjuncts().add(matchExpr);
} else {
conj.getConjuncts().add(matchExpr);
}
}
if (!matchIpOrPrefix.getDisjuncts().isEmpty()) {
conj.getConjuncts().add(matchIpOrPrefix);
}
RoutingPolicy clausePolicy = new RoutingPolicy(clausePolicyName, c);
c.getRoutingPolicies().put(clausePolicyName, clausePolicy);
If ifStatement = new If();
clausePolicy.getStatements().add(ifStatement);
clauses.put(clauseNumber, clausePolicy);
ifStatement.setComment(clausePolicyName);
ifStatement.setGuard(conj);
List<Statement> onMatchStatements = ifStatement.getTrueStatements();
for (RouteMapSetLine rmSet : rmClause.getSetList()) {
rmSet.applyTo(onMatchStatements, this, c, _w);
}
RouteMapContinue continueStatement = rmClause.getContinueLine();
Integer continueTarget = null;
If continueTargetIf = null;
RoutingPolicy continueTargetPolicy = null;
if (continueStatement != null) {
continueTarget = continueStatement.getTarget();
int statementLine = continueStatement.getStatementLine();
Expand All @@ -3328,8 +3395,8 @@ private RoutingPolicy toRoutingPolicy(final Configuration c, RouteMap map) {
if (continueTarget <= clauseNumber) {
throw new BatfishException("Can only continue to later clause");
}
continueTargetIf = clauses.get(continueTarget);
if (continueTargetIf == null) {
continueTargetPolicy = clauses.get(continueTarget);
if (continueTargetPolicy == null) {
String name = "clause: '" + continueTarget + "' in route-map: '" + map.getName() + "'";
undefined(
CiscoStructureType.ROUTE_MAP_CLAUSE,
Expand All @@ -3345,29 +3412,31 @@ private RoutingPolicy toRoutingPolicy(final Configuration c, RouteMap map) {
switch (rmClause.getAction()) {
case ACCEPT:
if (continueStatement == null) {
matchStatements.add(Statements.ReturnTrue.toStaticStatement());
onMatchStatements.add(Statements.ReturnTrue.toStaticStatement());
} else {
matchStatements.add(Statements.SetLocalDefaultActionAccept.toStaticStatement());
matchStatements.add(continueTargetIf);
onMatchStatements.add(Statements.SetLocalDefaultActionAccept.toStaticStatement());
onMatchStatements.add(new CallStatement(continueTargetPolicy.getName()));
}
break;

case REJECT:
matchStatements.add(Statements.ReturnFalse.toStaticStatement());
onMatchStatements.add(Statements.ReturnFalse.toStaticStatement());
break;

default:
throw new BatfishException("Invalid action");
}
if (followingClause != null) {
ifExpr.getFalseStatements().add(followingClause);
ifStatement.getFalseStatements().add(new CallStatement(followingClause.getName()));
} else {
ifExpr.getFalseStatements().add(Statements.ReturnLocalDefaultAction.toStaticStatement());
ifStatement
.getFalseStatements()
.add(Statements.ReturnLocalDefaultAction.toStaticStatement());
}
followingClause = ifExpr;
followingClause = clausePolicy;
followingClauseNumber = clauseNumber;
}
statements.add(followingClause);
statements.add(new CallStatement(followingClause.getName()));
return output;
}

Expand Down
2 changes: 1 addition & 1 deletion projects/build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>build-tools</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion projects/coordinator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>coordinator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion projects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>

<packaging>pom</packaging>

Expand Down
2 changes: 1 addition & 1 deletion projects/question/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.batfish</groupId>
<artifactId>batfish-parent</artifactId>
<version>0.33.2</version>
<version>0.33.3</version>
</parent>

<artifactId>question</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/dc-as-reuse.ref
Original file line number Diff line number Diff line change
Expand Up @@ -4670,7 +4670,7 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
Expand Down Expand Up @@ -4826,7 +4826,7 @@
}
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/disable-as-suppression.ref
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/example-juniper.ref
Original file line number Diff line number Diff line change
Expand Up @@ -10365,7 +10365,7 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
Expand Down Expand Up @@ -10494,7 +10494,7 @@
}
}
},
"version" : "0.33.2",
"version" : "0.33.3",
"warnings" : {
"as1border1" : {
"Red flags" : {
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/example.ref
Original file line number Diff line number Diff line change
Expand Up @@ -10699,7 +10699,7 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
Expand Down Expand Up @@ -10842,7 +10842,7 @@
}
}
},
"version" : "0.33.2",
"version" : "0.33.3",
"warnings" : {
"as1border1" : {
"Red flags" : {
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/indirection.ref
Original file line number Diff line number Diff line change
Expand Up @@ -944,11 +944,11 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/ios_rt.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2190,11 +2190,11 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
"version" : "0.33.2",
"version" : "0.33.3",
"warnings" : {
"lhr-border-02" : {
"Red flags" : {
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/isis.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2445,11 +2445,11 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/policy-routing.ref
Original file line number Diff line number Diff line change
Expand Up @@ -1904,11 +1904,11 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/snat.ref
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down
4 changes: 2 additions & 2 deletions test_rigs/parsing-tests/srx-testbed.ref
Original file line number Diff line number Diff line change
Expand Up @@ -5912,7 +5912,7 @@
]
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.ConvertConfigurationAnswerElement",
Expand All @@ -5930,7 +5930,7 @@
}
}
},
"version" : "0.33.2"
"version" : "0.33.3"
},
{
"class" : "org.batfish.datamodel.answers.InitInfoAnswerElement",
Expand Down

0 comments on commit b798b77

Please sign in to comment.