private void convertPrefixLists() { for (Entry<String, PrefixList> e : _prefixLists.entrySet()) { String name = e.getKey(); PrefixList prefixList = e.getValue(); RouteFilterList routeFilterList = toRouteFilterList(prefixList); _c.getRouteFilterLists().put(name, routeFilterList); } }
@Override protected NavigableMap<String, RouteFilterList> featureValueOf(Configuration actual) { return actual.getRouteFilterLists(); } }
@Override protected RouteFilterList featureValueOf(Configuration actual) { return actual.getRouteFilterLists().get(_name); } }
@Override public boolean matches(Prefix prefix, Environment environment) { RouteFilterList list = environment.getConfiguration().getRouteFilterLists().get(_name); if (list != null) { return list.permits(prefix); } else { environment.setError(true); return false; } } }
private void computeSuppressedAggregates() { _encoderSlice .getGraph() .getConfigurations() .forEach( (router, conf) -> { Set<Prefix> prefixes = new HashSet<>(); _suppressedAggregates.put(router, prefixes); conf.getRouteFilterLists() .forEach( (name, filter) -> { if (name.contains(AGGREGATION_SUPPRESS_NAME)) { for (RouteFilterLine line : filter.getLines()) { if (!line.getIpWildcard().isPrefix()) { throw new BatfishException("non-prefix IpWildcards are unsupported"); } prefixes.add(line.getIpWildcard().toPrefix()); } } }); }); }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_name); if (pl != null) { if (pl.getIpv6()) { return; } RouteFilterList prefixList = c.getRouteFilterLists().get(_name); // if referenced prefix list is empty, it should not match anything if (prefixList.getLines().isEmpty()) { headerSpaceBuilder.addSrcOrDstIp(EmptyIpSpace.INSTANCE); return; } headerSpaceBuilder.addSrcOrDstIp( AclIpSpace.union( prefixList.getMatchingIps().stream() .map(IpWildcard::toIpSpace) .collect(ImmutableList.toImmutableList()))); } else { w.redFlag("Reference to undefined prefix-list: \"" + _name + "\""); } } }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_name); if (pl != null) { if (pl.getIpv6()) { return; } RouteFilterList destinationPrefixList = c.getRouteFilterLists().get(_name); // if referenced prefix list is empty, it should not match anything if (destinationPrefixList.getLines().isEmpty()) { headerSpaceBuilder.addNotDstIp(EmptyIpSpace.INSTANCE); return; } headerSpaceBuilder.addNotDstIp( AclIpSpace.union( destinationPrefixList.getMatchingIps().stream() .map(IpWildcard::toIpSpace) .collect(ImmutableList.toImmutableList()))); } else { w.redFlag("Reference to undefined destination prefix-list: \"" + _name + "\""); } } }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_name); if (pl != null) { if (pl.getIpv6()) { return; } RouteFilterList destinationPrefixList = c.getRouteFilterLists().get(_name); // if referenced prefix list is empty, it should not match anything if (destinationPrefixList.getLines().isEmpty()) { headerSpaceBuilder.addDstIp(EmptyIpSpace.INSTANCE); return; } headerSpaceBuilder.addDstIp( AclIpSpace.union( destinationPrefixList.getMatchingIps().stream() .map(IpWildcard::toIpSpace) .collect(ImmutableList.toImmutableList()))); } else { w.redFlag("Reference to undefined destination prefix-list: \"" + _name + "\""); } } }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_name); if (pl != null) { if (pl.getIpv6()) { return; } RouteFilterList sourcePrefixList = c.getRouteFilterLists().get(_name); // if referenced prefix list is empty, it should not match anything if (sourcePrefixList.getLines().isEmpty()) { headerSpaceBuilder.addSrcIp(EmptyIpSpace.INSTANCE); return; } headerSpaceBuilder.addSrcIp( AclIpSpace.union( sourcePrefixList.getMatchingIps().stream() .map(IpWildcard::toIpSpace) .collect(ImmutableList.toImmutableList()))); } else { w.redFlag("Reference to undefined source prefix-list: \"" + _name + "\""); } } }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_name); if (pl != null) { if (pl.getIpv6()) { return; } RouteFilterList sourcePrefixList = c.getRouteFilterLists().get(_name); // if referenced prefix list is empty, it should not match anything if (sourcePrefixList.getLines().isEmpty()) { headerSpaceBuilder.addNotSrcIp(EmptyIpSpace.INSTANCE); return; } headerSpaceBuilder.addNotSrcIp( AclIpSpace.union( sourcePrefixList.getMatchingIps().stream() .map(IpWildcard::toIpSpace) .collect(ImmutableList.toImmutableList()))); } else { w.redFlag("Reference to undefined source prefix-list: \"" + _name + "\""); } } }
@Override public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) { Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = d.getDisjuncts(); for (String listName : _listNames) { Object list; IpAccessList ipAccessList = null; RouteFilterList routeFilterList = null; if (_routing) { routeFilterList = c.getRouteFilterLists().get(listName); list = routeFilterList; } else { ipAccessList = c.getIpAccessLists().get(listName); list = ipAccessList; } if (list != null) { if (_routing) { disjuncts.add( new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(listName))); } else { disjuncts.add(new MatchIpAccessList(listName)); } } } return d.simplify(); } }
new RouteFilterLine(LineAction.PERMIT, PrefixRange.moreSpecificThan(p)))); c.getRouteFilterLists().put(matchLonger.getName(), matchLonger);
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_prefixList); if (pl != null) { if (pl.getIpv6()) { return BooleanExprs.FALSE; } RouteFilterList rf = c.getRouteFilterLists().get(_prefixList); String orLongerListName = "~" + _prefixList + "~ORLONGER~"; RouteFilterList orLongerList = c.getRouteFilterLists().get(orLongerListName); if (orLongerList == null) { orLongerList = new RouteFilterList(orLongerListName); for (RouteFilterLine line : rf.getLines()) { Prefix prefix = line.getIpWildcard().toPrefix(); LineAction action = line.getAction(); SubRange orLongerLineRange = new SubRange(line.getLengthRange().getStart(), Prefix.MAX_PREFIX_LENGTH); RouteFilterLine orLongerLine = new RouteFilterLine(action, prefix, orLongerLineRange); orLongerList.addLine(orLongerLine); c.getRouteFilterLists().put(orLongerListName, orLongerList); } } return new MatchPrefixSet( DestinationNetwork.instance(), new NamedPrefixSet(orLongerListName)); } else { warnings.redFlag("Reference to undefined prefix-list: \"" + _prefixList + "\""); return BooleanExprs.FALSE; } } }
return BooleanExprs.FALSE; RouteFilterList rf = c.getRouteFilterLists().get(_prefixList); String longerListName = "~" + _prefixList + "~LONGER~"; RouteFilterList longerList = c.getRouteFilterLists().get(longerListName); if (longerList == null) { longerList = new RouteFilterList(longerListName); c.getRouteFilterLists().put(longerListName, longerList);
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { RouteFilterList rfl = c.getRouteFilterLists().get(_routeFilterName); Route6FilterList rfl6 = c.getRoute6FilterLists().get(_routeFilterName); BooleanExpr match4 = null; BooleanExpr match6 = null; if (rfl != null) { match4 = new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(_routeFilterName)); } if (rfl6 != null) { match6 = new MatchPrefix6Set(new DestinationNetwork6(), new NamedPrefix6Set(_routeFilterName)); } if (match4 != null && match6 == null) { return match4; } else if (rfl == null && rfl6 != null) { return match6; } else if (rfl != null && rfl6 != null) { Disjunction d = new Disjunction(); d.getDisjuncts().add(match4); d.getDisjuncts().add(match6); return d; } else { throw new VendorConversionException( "missing route filter list: \"" + _routeFilterName + "\""); } } }
line.applyTo(lineSpecificList); actionLineCounter++; _c.getRouteFilterLists().put(lineListName, lineSpecificList); If lineSpecificIfStatement = new If(); String lineSpecificClauseName = routeFilterName + "_ACTION_LINE_" + actionLineCounter;
newRoute.setGenerationPolicy(policyName); _c.getRoutingPolicies().put(policyName, routingPolicy); _c.getRouteFilterLists().put(rflName, rfList); return newRoute.build();
private BDD matchPrefixSet( TransferParam<BDDRoute> p, Configuration conf, PrefixSetExpr e, BDDRoute other) { if (e instanceof ExplicitPrefixSet) { ExplicitPrefixSet x = (ExplicitPrefixSet) e; Set<PrefixRange> ranges = x.getPrefixSpace().getPrefixRanges(); if (ranges.isEmpty()) { p.debug("empty"); return factory.one(); } BDD acc = factory.zero(); for (PrefixRange range : ranges) { p.debug("Prefix Range: " + range); if (!PrefixUtils.isContainedBy(range.getPrefix(), _ignoredNetworks)) { acc = acc.or(isRelevantFor(other, range)); } } return acc; } else if (e instanceof NamedPrefixSet) { NamedPrefixSet x = (NamedPrefixSet) e; p.debug("Named: " + x.getName()); String name = x.getName(); RouteFilterList fl = conf.getRouteFilterLists().get(name); return matchFilterList(p, fl, other); } else { throw new BatfishException("TODO: match prefix set: " + e); } }
neighbor.getRouteFilterLists().get(neighborSummaryFilterName); allowed = neighborSummaryFilter.permits(neighborRouteNetwork);
new RouteFilterListsDiff(before.getRouteFilterLists(), after.getRouteFilterLists()); if (_routeFilterListsDiff.isEmpty()) { _routeFilterListsDiff = null;