@Test public void testComputeRoutesWithNextHopIpArpFalseForInterface() { String outInterface = "i1"; AbstractRoute nextHopIpRoute1 = StaticRoute.builder() .setNetwork(P1) .setNextHopIp(P2.getStartIp()) .setAdministrativeCost(1) .build(); AbstractRoute nextHopIpRoute2 = StaticRoute.builder() .setNetwork(P1) .setNextHopIp(P2.getEndIp()) .setAdministrativeCost(1) .build(); AbstractRoute ifaceRoute = new ConnectedRoute(P2, outInterface); Set<AbstractRoute> candidateRoutes = ImmutableSet.of(nextHopIpRoute1, nextHopIpRoute2, ifaceRoute); Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfaces = ImmutableMap.of( nextHopIpRoute1, ImmutableMap.of( outInterface, ImmutableMap.of(nextHopIpRoute1.getNextHopIp(), ImmutableSet.of(ifaceRoute))), nextHopIpRoute2, ImmutableMap.of( outInterface, ImmutableMap.of(nextHopIpRoute2.getNextHopIp(), ImmutableSet.of(ifaceRoute))), ifaceRoute, ImmutableMap.of( outInterface, ImmutableMap.of(Route.UNSET_ROUTE_NEXT_HOP_IP, ImmutableSet.of(ifaceRoute)))); Set<AbstractRoute> result = computeRoutesWithNextHopIpArpFalseForInterface( nextHopInterfaces, outInterface, candidateRoutes, ImmutableMap.of(outInterface, P2.getStartIp().toIpSpace())); assertThat(result, contains(nextHopIpRoute2)); }
@VisibleForTesting static Set<AbstractRoute> computeRoutesWithNextHopIpArpFalseForInterface( Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfaces, String outInterface, Set<AbstractRoute> candidateRoutes, Map<String, IpSpace> nodeSomeoneReplies) { IpSpace someoneReplies = nodeSomeoneReplies.getOrDefault(outInterface, EmptyIpSpace.INSTANCE); return candidateRoutes.stream() .filter( candidateRoute -> nextHopInterfaces.get(candidateRoute).get(outInterface).keySet().stream() .filter(ip -> !ip.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) .anyMatch( nextHopIp -> !someoneReplies.containsIp(nextHopIp, ImmutableMap.of()))) .collect(ImmutableSet.toImmutableSet()); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Set<AbstractRoute> computeRoutesWithNextHopIpArpFalseForInterface( Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfaces, String outInterface, Set<AbstractRoute> candidateRoutes, Map<String, IpSpace> nodeSomeoneReplies) { IpSpace someoneReplies = nodeSomeoneReplies.getOrDefault(outInterface, EmptyIpSpace.INSTANCE); return candidateRoutes.stream() .filter( candidateRoute -> nextHopInterfaces.get(candidateRoute).get(outInterface).keySet().stream() .filter(ip -> !ip.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) .anyMatch( nextHopIp -> !someoneReplies.containsIp(nextHopIp, ImmutableMap.of()))) .collect(ImmutableSet.toImmutableSet()); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Set<AbstractRoute> computeRoutesWithNextHopIpArpFalseForInterface( Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfaces, String outInterface, Set<AbstractRoute> candidateRoutes, Map<String, IpSpace> nodeSomeoneReplies) { IpSpace someoneReplies = nodeSomeoneReplies.getOrDefault(outInterface, EmptyIpSpace.INSTANCE); return candidateRoutes.stream() .filter( candidateRoute -> nextHopInterfaces.get(candidateRoute).get(outInterface).keySet().stream() .filter(ip -> !ip.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) .anyMatch( nextHopIp -> !someoneReplies.containsIp(nextHopIp, ImmutableMap.of()))) .collect(ImmutableSet.toImmutableSet()); } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Set<AbstractRoute> computeRoutesWithNextHopIpArpFalseForInterface( Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfaces, String outInterface, Set<AbstractRoute> candidateRoutes, Map<String, IpSpace> nodeSomeoneReplies) { IpSpace someoneReplies = nodeSomeoneReplies.getOrDefault(outInterface, EmptyIpSpace.INSTANCE); return candidateRoutes.stream() .filter( candidateRoute -> nextHopInterfaces.get(candidateRoute).get(outInterface).keySet().stream() .filter(ip -> !ip.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) .anyMatch( nextHopIp -> !someoneReplies.containsIp(nextHopIp, ImmutableMap.of()))) .collect(ImmutableSet.toImmutableSet()); } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); @Nonnull @Override Map<String, Map<String, Map<String, IpSpace>>> getAcceptsIps(); @Override Map<String, Map<String, IpSpace>> getArpReplies(); @Override Map<String, Map<String, Map<Edge, IpSpace>>> getArpTrueEdge(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNextVrfIps(); @Override Map<String, Map<String, IpSpace>> getNullRoutedIps(); @Override Map<String, Map<String, IpSpace>> getRoutableIps(); @Override Map<String, Map<String, Map<String, IpSpace>>> getDeliveredToSubnet(); @Override Map<String, Map<String, Map<String, IpSpace>>> getExitsNetwork(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNeighborUnreachable(); @Override Map<String, Map<String, Map<String, IpSpace>>> getInsufficientInfo(); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Set<AbstractRoute> computeRoutesWithNextHopIpArpFalseForInterface( Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfaces, String outInterface, Set<AbstractRoute> candidateRoutes, Map<String, IpSpace> nodeSomeoneReplies) { IpSpace someoneReplies = nodeSomeoneReplies.getOrDefault(outInterface, EmptyIpSpace.INSTANCE); return candidateRoutes.stream() .filter( candidateRoute -> nextHopInterfaces.get(candidateRoute).get(outInterface).keySet().stream() .filter(ip -> !ip.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) .anyMatch( nextHopIp -> !someoneReplies.containsIp(nextHopIp, ImmutableMap.of()))) .collect(ImmutableSet.toImmutableSet()); } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); @Nonnull @Override Map<String, Map<String, Map<String, IpSpace>>> getAcceptsIps(); @Override Map<String, Map<String, IpSpace>> getArpReplies(); @Override Map<String, Map<String, Map<Edge, IpSpace>>> getArpTrueEdge(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNextVrfIps(); @Override Map<String, Map<String, IpSpace>> getNullRoutedIps(); @Override Map<String, Map<String, IpSpace>> getRoutableIps(); @Override Map<String, Map<String, Map<String, IpSpace>>> getDeliveredToSubnet(); @Override Map<String, Map<String, Map<String, IpSpace>>> getExitsNetwork(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNeighborUnreachable(); @Override Map<String, Map<String, Map<String, IpSpace>>> getInsufficientInfo();  }