@Test public void testComputeNullRoutedIps() { String c1 = "c1"; String v1 = "v1"; String i1 = "i1"; AbstractRoute nullRoute = StaticRoute.builder() .setNextHopInterface(Interface.NULL_INTERFACE_NAME) .setNetwork(P1) .setAdministrativeCost(1) .build(); AbstractRoute otherRoute = new ConnectedRoute(P2, i1); Map<String, Map<String, Fib>> fibs = ImmutableSortedMap.of( c1, ImmutableSortedMap.of( v1, MockFib.builder() .setMatchingIps( ImmutableMap.of( P1, AclIpSpace.permitting(P1.toIpSpace()).build(), P2, AclIpSpace.permitting(P2.toIpSpace()).build())) .setFibEntries( ImmutableMap.of( Ip.ZERO, ImmutableSet.of( new FibEntry(FibNullRoute.INSTANCE, ImmutableList.of(nullRoute)), new FibEntry( new FibForward( Route.UNSET_ROUTE_NEXT_HOP_IP, otherRoute.getNextHopInterface()), ImmutableList.of(otherRoute))))) .build())); Map<String, Map<String, IpSpace>> result = computeNullRoutedIps(computeMatchingIps(fibs), fibs); assertThat(result, hasEntry(equalTo(c1), hasEntry(equalTo(v1), containsIp(P1.getStartIp())))); assertThat(result, hasEntry(equalTo(c1), hasEntry(equalTo(v1), containsIp(P1.getEndIp())))); assertThat( result, hasEntry(equalTo(c1), hasEntry(equalTo(v1), not(containsIp(P2.getStartIp()))))); assertThat( result, hasEntry(equalTo(c1), hasEntry(equalTo(v1), not(containsIp(P2.getEndIp()))))); }
@VisibleForTesting static Map<String, Map<String, IpSpace>> computeNullRoutedIps( Map<String, Map<String, Map<Prefix, IpSpace>>> matchingIps, Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeNullRoutedIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return fibs.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByHostnameEntry -> { String hostname = fibsByHostnameEntry.getKey(); return fibsByHostnameEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByVrfEntry -> { String vrf = fibsByVrfEntry.getKey(); Fib fib = fibsByVrfEntry.getValue(); Map<Prefix, IpSpace> vrfMatchingIps = matchingIps.get(hostname).get(vrf); Set<AbstractRoute> nullRoutes = fib.allEntries().stream() .filter( fibEntry -> fibEntry.getAction() instanceof FibNullRoute) .map(FibEntry::getTopLevelRoute) .collect(ImmutableSet.toImmutableSet()); return computeRouteMatchConditions(nullRoutes, vrfMatchingIps); })); })); } finally { span.finish(); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeNullRoutedIps( Map<String, Map<String, Map<Prefix, IpSpace>>> matchingIps, Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeNullRoutedIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return fibs.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByHostnameEntry -> { String hostname = fibsByHostnameEntry.getKey(); return fibsByHostnameEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByVrfEntry -> { String vrf = fibsByVrfEntry.getKey(); Fib fib = fibsByVrfEntry.getValue(); Map<Prefix, IpSpace> vrfMatchingIps = matchingIps.get(hostname).get(vrf); Set<AbstractRoute> nullRoutes = fib.allEntries().stream() .filter( fibEntry -> fibEntry.getAction() instanceof FibNullRoute) .map(FibEntry::getTopLevelRoute) .collect(ImmutableSet.toImmutableSet()); return computeRouteMatchConditions(nullRoutes, vrfMatchingIps); })); })); } finally { span.finish(); } } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeNullRoutedIps( Map<String, Map<String, Map<Prefix, IpSpace>>> matchingIps, Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeNullRoutedIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return fibs.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByHostnameEntry -> { String hostname = fibsByHostnameEntry.getKey(); return fibsByHostnameEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByVrfEntry -> { String vrf = fibsByVrfEntry.getKey(); Fib fib = fibsByVrfEntry.getValue(); Map<Prefix, IpSpace> vrfMatchingIps = matchingIps.get(hostname).get(vrf); Set<AbstractRoute> nullRoutes = fib.allEntries().stream() .filter( fibEntry -> fibEntry.getAction() instanceof FibNullRoute) .map(FibEntry::getTopLevelRoute) .collect(ImmutableSet.toImmutableSet()); return computeRouteMatchConditions(nullRoutes, vrfMatchingIps); })); })); } finally { span.finish(); } } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeNullRoutedIps( Map<String, Map<String, Map<Prefix, IpSpace>>> matchingIps, Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeNullRoutedIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return fibs.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByHostnameEntry -> { String hostname = fibsByHostnameEntry.getKey(); return fibsByHostnameEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByVrfEntry -> { String vrf = fibsByVrfEntry.getKey(); Fib fib = fibsByVrfEntry.getValue(); Map<Prefix, IpSpace> vrfMatchingIps = matchingIps.get(hostname).get(vrf); Set<AbstractRoute> nullRoutes = fib.allEntries().stream() .filter( fibEntry -> fibEntry.getAction() instanceof FibNullRoute) .map(FibEntry::getTopLevelRoute) .collect(ImmutableSet.toImmutableSet()); return computeRouteMatchConditions(nullRoutes, vrfMatchingIps); })); })); } finally { span.finish(); } } 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 Map<String, Map<String, IpSpace>> computeNullRoutedIps( Map<String, Map<String, Map<Prefix, IpSpace>>> matchingIps, Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeNullRoutedIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return fibs.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByHostnameEntry -> { String hostname = fibsByHostnameEntry.getKey(); return fibsByHostnameEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , fibsByVrfEntry -> { String vrf = fibsByVrfEntry.getKey(); Fib fib = fibsByVrfEntry.getValue(); Map<Prefix, IpSpace> vrfMatchingIps = matchingIps.get(hostname).get(vrf); Set<AbstractRoute> nullRoutes = fib.allEntries().stream() .filter( fibEntry -> fibEntry.getAction() instanceof FibNullRoute) .map(FibEntry::getTopLevelRoute) .collect(ImmutableSet.toImmutableSet()); return computeRouteMatchConditions(nullRoutes, vrfMatchingIps); })); })); } finally { span.finish(); } } 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();  }