@Test public void testComputeArpReplies() { Configuration c1 = _cb.build(); Configuration c2 = _cb.build(); Map<String, Configuration> configs = ImmutableMap.of(c1.getHostname(), c1, c2.getHostname(), c2); Vrf vrf1 = _vb.setOwner(c1).build(); Vrf vrf2 = _vb.setOwner(c2).build(); Interface i1 = _ib.setOwner(c1) .setVrf(vrf1) .setAddress(ConcreteInterfaceAddress.create(P1.getStartIp(), P1.getPrefixLength())) .setProxyArp(true) .build(); Interface i2 = _ib.setOwner(c2) .setVrf(vrf2) .setAddress(ConcreteInterfaceAddress.create(P2.getStartIp(), P2.getPrefixLength())) .setProxyArp(false) .build(); Ip additionalIp = Ip.parse("10.10.10.1"); i1.setAdditionalArpIps(additionalIp.toIpSpace()); i2.setAdditionalArpIps(additionalIp.toIpSpace()); IpSpace ipsRoutedOutI1 = IpWildcardSetIpSpace.builder() .including(IpWildcard.create(P1), IpWildcard.create(P3)) .build(); IpSpace ipsRoutedOutI2 = IpWildcardSetIpSpace.builder().including(IpWildcard.create(P2)).build(); Map<String, Configuration> configurations = ImmutableMap.of(c1.getHostname(), c1, c2.getHostname(), c2); Map<String, Map<String, IpSpace>> routableIps = ImmutableMap.of( c1.getHostname(), ImmutableMap.of(vrf1.getName(), UniverseIpSpace.INSTANCE), c2.getHostname(), ImmutableMap.of(vrf2.getName(), UniverseIpSpace.INSTANCE)); Map<String, Map<String, Map<String, IpSpace>>> ipsRoutedOutInterfaces = ImmutableMap.of( c1.getHostname(), ImmutableMap.of(vrf1.getName(), ImmutableMap.of(i1.getName(), ipsRoutedOutI1)), c2.getHostname(), ImmutableMap.of(vrf2.getName(), ImmutableMap.of(i2.getName(), ipsRoutedOutI2))); Map<String, Map<String, Set<Ip>>> interfaceOwnedIps = IpOwners.computeInterfaceOwnedIps(configs, false); Map<String, Map<String, IpSpace>> result = computeArpReplies(configurations, ipsRoutedOutInterfaces, interfaceOwnedIps, routableIps); assertThat( result, hasEntry( equalTo(c1.getHostname()), hasEntry(equalTo(i1.getName()), containsIp(P1.getStartIp())))); assertThat( result, hasEntry( equalTo(c1.getHostname()), hasEntry(equalTo(i1.getName()), not(containsIp(P1.getEndIp()))))); assertThat( result, hasEntry( equalTo(c1.getHostname()), hasEntry(equalTo(i1.getName()), not(containsIp(P3.getStartIp()))))); assertThat( result, hasEntry( equalTo(c1.getHostname()), hasEntry(equalTo(i1.getName()), containsIp(P2.getStartIp())))); assertThat( result, hasEntry( equalTo(c1.getHostname()), hasEntry(equalTo(i1.getName()), containsIp(additionalIp)))); assertThat( result, hasEntry( equalTo(c2.getHostname()), hasEntry(equalTo(i2.getName()), containsIp(P2.getStartIp())))); assertThat( result, hasEntry( equalTo(c2.getHostname()), hasEntry(equalTo(i2.getName()), not(containsIp(P2.getEndIp()))))); assertThat( result, hasEntry( equalTo(c2.getHostname()), hasEntry(equalTo(i2.getName()), not(containsIp(P3.getStartIp()))))); assertThat( result, hasEntry( equalTo(c2.getHostname()), hasEntry(equalTo(i2.getName()), not(containsIp(P1.getStartIp()))))); assertThat( result, hasEntry( equalTo(c2.getHostname()), hasEntry(equalTo(i2.getName()), containsIp(additionalIp)))); }
@VisibleForTesting static Map<String, Map<String, IpSpace>> computeArpReplies( Map<String, Configuration> configurations, Map<String, Map<String, Map<String, IpSpace>>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps, Map<String, Map<String, IpSpace>> routableIps) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeArpReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configurations, Entry::getKey, nodeEntry -> { String hostname = nodeEntry.getKey(); return computeArpRepliesByInterface( nodeEntry.getValue().getActiveInterfaces(), routableIps.get(hostname), ipsRoutedOutInterfaces.get(hostname), interfaceOwnedIps); }); } finally { span.finish(); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeArpReplies( Map<String, Configuration> configurations, Map<String, Map<String, Map<String, IpSpace>>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps, Map<String, Map<String, IpSpace>> routableIps) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeArpReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configurations, Entry::getKey, nodeEntry -> { String hostname = nodeEntry.getKey(); return computeArpRepliesByInterface( nodeEntry.getValue().getActiveInterfaces(), routableIps.get(hostname), ipsRoutedOutInterfaces.get(hostname), interfaceOwnedIps); }); } finally { span.finish(); } } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeArpReplies( Map<String, Configuration> configurations, Map<String, Map<String, Map<String, IpSpace>>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps, Map<String, Map<String, IpSpace>> routableIps) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeArpReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configurations, Entry::getKey, nodeEntry -> { String hostname = nodeEntry.getKey(); return computeArpRepliesByInterface( nodeEntry.getValue().getActiveInterfaces(), routableIps.get(hostname), ipsRoutedOutInterfaces.get(hostname), interfaceOwnedIps); }); } 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>> computeArpReplies( Map<String, Configuration> configurations, Map<String, Map<String, Map<String, IpSpace>>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps, Map<String, Map<String, IpSpace>> routableIps) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeArpReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configurations, Entry::getKey, nodeEntry -> { String hostname = nodeEntry.getKey(); return computeArpRepliesByInterface( nodeEntry.getValue().getActiveInterfaces(), routableIps.get(hostname), ipsRoutedOutInterfaces.get(hostname), interfaceOwnedIps); }); } 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>> computeArpReplies( Map<String, Configuration> configurations, Map<String, Map<String, Map<String, IpSpace>>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps, Map<String, Map<String, IpSpace>> routableIps) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeArpReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configurations, Entry::getKey, nodeEntry -> { String hostname = nodeEntry.getKey(); return computeArpRepliesByInterface( nodeEntry.getValue().getActiveInterfaces(), routableIps.get(hostname), ipsRoutedOutInterfaces.get(hostname), interfaceOwnedIps); }); } 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();  }