private void generateAristaDynamicSourceNats( org.batfish.datamodel.Interface newIface, List<AristaDynamicSourceNat> aristaDynamicSourceNats) { Ip interfaceIp = newIface.getAddress().getIp(); Transformation next = null; for (AristaDynamicSourceNat nat : Lists.reverse(aristaDynamicSourceNats)) { next = nat.toTransformation(interfaceIp, _natPools, next).orElse(next); } newIface.setOutgoingTransformation(next); }
@Nonnull public IpEdge toIpEdge(NetworkConfigurations nc) { return new IpEdge( _node1.getHostname(), _node1.getInterface(nc).getAddress().getIp(), _node2.getHostname(), _node2.getInterface(nc).getAddress().getIp()); }
BgpActivePeerConfig n = ns.get(i); Interface iface = ge.getStart(); if (ip != null && iface.getAddress().getPrefix().containsIp(ip)) { _ebgpNeighbors.put(ge, n);
String buildRoute(Prefix pfx, Protocol proto, GraphEdge graphEdge) { String type; String nextHopIP; String nextHopInt; if (proto.isConnected()) { type = "ConnectedRoute"; nextHopIP = "AUTO/NONE(-1l)"; nextHopInt = graphEdge.getStart().getName(); } else { type = StringUtils.capitalize(proto.name().toLowerCase()) + "Route"; nextHopIP = graphEdge.getStart().getAddress().getIp().toString(); nextHopInt = "dynamic"; } return String.format("%s<%s,nhip:%s,nhint:%s>", type, pfx, nextHopIP, nextHopInt); }
&& there.getAddress() != null && there.getAddress().getIp().equals(nhIp);
if (iface.getAddress() == null) { w.redFlag( String.format(
org.batfish.datamodel.Interface iface = e.getValue(); if (iname.startsWith("Loopback")) { InterfaceAddress address = iface.getAddress(); if (address != null) { Ip currentIp = address.getIp(); InterfaceAddress address = currentInterface.getAddress(); if (address != null) { Ip currentIp = address.getIp();
private void placeInterfaceIntoArea( Map<Long, org.batfish.datamodel.ospf.OspfArea.Builder> newAreas, String interfaceName, Interface iface, String vrfName) { Vrf vrf = _c.getVrfs().get(vrfName); org.batfish.datamodel.Interface newIface = vrf.getInterfaces().get(interfaceName); Ip ospfArea = iface.getOspfArea(); if (ospfArea == null) { return; } if (newIface.getAddress() == null) { _w.redFlag( String.format( "Cannot assign interface %s to area %s because it has no IP address.", interfaceName, ospfArea)); return; } long ospfAreaLong = ospfArea.asLong(); org.batfish.datamodel.ospf.OspfArea.Builder newArea = newAreas.get(ospfAreaLong); newArea.addInterface(interfaceName); newIface.setOspfEnabled(true); newIface.setOspfPassive(iface.getOspfPassive()); Integer ospfCost = iface.getOspfCost(); if (ospfCost == null && newIface.isLoopback(ConfigurationFormat.FLAT_JUNIPER)) { ospfCost = 0; } newIface.setOspfCost(ospfCost); }
private boolean propagateOspfInterAreaRouteFromIntraAreaRoute( Configuration neighbor, OspfProcess neighborProc, OspfIntraAreaRoute neighborRoute, long incrementalCost, Interface neighborInterface, int adminCost, long linkAreaNum) { return OspfProtocolHelper.isOspfInterAreaFromIntraAreaPropagationAllowed( linkAreaNum, neighbor, neighborProc, neighborRoute, neighborInterface.getOspfArea()) && stageOspfInterAreaRoute( neighborRoute, neighborInterface.getVrf().getOspfProcess().getMaxMetricSummaryNetworks(), neighborInterface.getAddress().getIp(), incrementalCost, adminCost, linkAreaNum); }
boolean propagateOspfInterAreaRouteFromInterAreaRoute( OspfProcess proc, Configuration neighbor, OspfProcess neighborProc, OspfInterAreaRoute neighborRoute, long incrementalCost, Interface neighborInterface, int adminCost, long linkAreaNum) { return OspfProtocolHelper.isOspfInterAreaFromInterAreaPropagationAllowed( proc, linkAreaNum, neighbor, neighborProc, neighborRoute, neighborInterface.getOspfArea()) && stageOspfInterAreaRoute( neighborRoute, neighborInterface.getVrf().getOspfProcess().getMaxMetricSummaryNetworks(), neighborInterface.getAddress().getIp(), incrementalCost, adminCost, linkAreaNum); }
@Test public void testIpInterfaceOwnersWithVrrp() { Map<String, Configuration> configs = setupVrrpTestCase(true); Map<Ip, Map<String, Set<String>>> interfaceOwners = computeIpInterfaceOwners(computeNodeInterfaces(configs), false); assertThat( interfaceOwners, hasEntry( equalTo(_i1.getAddress().getIp()), hasEntry(equalTo(_i1.getOwner().getHostname()), contains(_i1.getName())))); assertThat( interfaceOwners, hasEntry( equalTo(_i2.getAddress().getIp()), hasEntry(equalTo(_i2.getOwner().getHostname()), contains(_i2.getName())))); assertThat( interfaceOwners, hasEntry( equalTo(_virtInterfaceAddr.getIp()), hasEntry(equalTo(_i2.getOwner().getHostname()), contains(_i2.getName())))); } }
private void addLinkFailureConstraints( Encoder enc, Set<GraphEdge> dstPorts, Set<GraphEdge> failSet) { Graph graph = enc.getMainSlice().getGraph(); for (List<GraphEdge> edges : graph.getEdgeMap().values()) { for (GraphEdge ge : edges) { ArithExpr f = enc.getSymbolicFailures().getFailedVariable(ge); assert f != null; if (!failSet.contains(ge)) { enc.add(enc.mkEq(f, enc.mkInt(0))); } else if (dstPorts.contains(ge)) { // Don't fail an interface if it is for the destination ip we are considering // Otherwise, any failure can trivially make equivalence false Prefix pfx = ge.getStart().getAddress().getPrefix(); BitVecExpr dstIp = enc.getMainSlice().getSymbolicPacket().getDstIp(); BoolExpr relevant = enc.getMainSlice().isRelevantFor(pfx, dstIp); BoolExpr notFailed = enc.mkEq(f, enc.mkInt(0)); enc.add(enc.mkImplies(relevant, notFailed)); } } } }
Prefix pfx = ge.getStart().getAddress().getPrefix(); IpWildcard dst = new IpWildcard(pfx); headerSpace.setDstIps(AclIpSpace.union(headerSpace.getDstIps(), dst.toIpSpace())); Prefix pfx = ge.getStart().getAddress().getPrefix(); IpWildcard dst = new IpWildcard(pfx); headerSpace.setDstIps(AclIpSpace.union(headerSpace.getDstIps(), dst.toIpSpace())); Ip ip = ge.getEnd().getAddress().getIp(); IpWildcard dst2 = new IpWildcard(ip); headerSpace.setNotDstIps(AclIpSpace.union(headerSpace.getNotDstIps(), dst2.toIpSpace())); } else { Ip ip = ge.getStart().getAddress().getIp(); IpWildcard dst = new IpWildcard(ip); headerSpace.setDstIps(AclIpSpace.union(headerSpace.getDstIps(), dst.toIpSpace()));
newGroup.setPreempt(vrrpGroup.getPreempt()); newGroup.setPriority(vrrpGroup.getPriority()); InterfaceAddress ifaceAddress = iface.getAddress(); if (ifaceAddress != null) { int prefixLength = ifaceAddress.getNetworkBits();
@Test public void resolveIpSpaceOfLocationTestDefault() { SpecifiersQuestion question = new SpecifiersQuestion(QueryType.IP_SPACE); assertThat( resolveIpSpaceOfLocation(question, _context).getRows().getData(), equalTo( ImmutableMultiset.of( Row.of( COL_LOCATIONS, ImmutableSet.of(new InterfaceLocation(_c1.getHostname(), _iface1.getName())) .toString(), COL_IP_SPACE, _iface1.getAddress().getIp().toIpSpace().toString()), Row.of( COL_LOCATIONS, ImmutableSet.of(new InterfaceLocation(_c2.getHostname(), _iface2.getName())) .toString(), COL_IP_SPACE, _iface2.getAddress().getIp().toIpSpace().toString())))); }
VirtualRouter neighborVirtualRouter = neighbor.getVirtualRouters().get(neighborVrfName); long asn = neighborInterface.getEigrp().getAsn(); Ip nextHopIp = neighborInterface.getAddress().getIp(); boolean changed = false; Set<EigrpInternalRoute> neighborRoutes =
boolean propagateOspfIntraAreaRoute( OspfIntraAreaRoute neighborRoute, long incrementalCost, Interface neighborInterface, int adminCost, long linkAreaNum) { long newCost = neighborRoute.getMetric() + incrementalCost; Ip nextHopIp = neighborInterface.getAddress().getIp(); OspfIntraAreaRoute newRoute = (OspfIntraAreaRoute) OspfIntraAreaRoute.builder() .setProtocol(RoutingProtocol.OSPF) .setNetwork(neighborRoute.getNetwork()) .setNextHopIp(nextHopIp) .setAdmin(adminCost) .setMetric(newCost) .setArea(linkAreaNum) .build(); return neighborRoute.getArea() == linkAreaNum && (_ospfIntraAreaStagingRib.mergeRoute(newRoute)); }
@Test public void resolveIpSpaceOfLocationTest() { SpecifiersQuestion questionWithLocation = new SpecifiersQuestion(QueryType.IP_SPACE_OF_LOCATION); questionWithLocation.setLocationSpecifierInput(_c1.getHostname()); // only c1:iface1 should be present assertThat( resolveIpSpaceOfLocation(questionWithLocation, _context).getRows().getData(), equalTo( ImmutableMultiset.of( Row.of( COL_LOCATIONS, ImmutableSet.of(new InterfaceLocation(_c1.getHostname(), _iface1.getName())) .toString(), COL_IP_SPACE, _iface1.getAddress().getIp().toIpSpace().toString())))); }
.setProtocol(RoutingProtocol.OSPF_IA) .setNetwork(Prefix.ZERO) .setNextHopIp(neighborInterface.getAddress().getIp()) .setAdmin(adminCost) .setMetric(metric)
ImmutableMap.of( _c1.getHostname(), ImmutableMap.of(_iface1.getName(), _iface1.getAddress().getIp().toIpSpace()), _c2.getHostname(), ImmutableMap.of(_iface2.getName(), _iface2.getAddress().getIp().toIpSpace()))) .build();