@Test public void testComputeArpRepliesByInterface() { Configuration config = _cb.build(); _ib.setOwner(config); _vb.setOwner(config); Vrf vrf1 = _vb.build(); Vrf vrf2 = _vb.build(); Interface i1 = _ib.setVrf(vrf1) .setAddress(ConcreteInterfaceAddress.create(P1.getStartIp(), P1.getPrefixLength())) .setProxyArp(true) .build(); Interface i2 = _ib.setVrf(vrf2) .setAddress(ConcreteInterfaceAddress.create(P2.getStartIp(), P2.getPrefixLength())) .setProxyArp(false) .build(); Interface i3 = _ib.setAddress(null).setProxyArp(true).build(); Interface i4 = _ib.setAddress(LinkLocalAddress.of(Ip.parse("169.254.0.1"))).setProxyArp(false).build(); IpSpace ipsRoutedOutI1 = IpWildcardSetIpSpace.builder() .including(IpWildcard.create(P1), IpWildcard.create(P3)) .build(); IpSpace ipsRoutedOutI2 = IpWildcardSetIpSpace.builder().including(IpWildcard.create(P2)).build(); IpSpace ipsRoutedOutI3 = EmptyIpSpace.INSTANCE; Map<String, Interface> interfaces = ImmutableMap.of(i1.getName(), i1, i2.getName(), i2, i3.getName(), i3, i4.getName(), i4); Map<String, IpSpace> routableIpsByVrf = ImmutableMap.of( vrf1.getName(), UniverseIpSpace.INSTANCE, vrf2.getName(), UniverseIpSpace.INSTANCE); Map<String, Map<String, IpSpace>> ipsRoutedOutInterfaces = ImmutableMap.of( vrf1.getName(), ImmutableMap.of(i1.getName(), ipsRoutedOutI1), vrf2.getName(), ImmutableMap.of(i2.getName(), ipsRoutedOutI2, i3.getName(), ipsRoutedOutI3)); i1.setAdditionalArpIps(IpIpSpace.create(Ip.parse("10.10.10.1"))); i2.setAdditionalArpIps(IpIpSpace.create(Ip.parse("10.10.10.2"))); i3.setAdditionalArpIps(IpIpSpace.create(Ip.parse("10.10.10.3"))); i4.setAdditionalArpIps(IpIpSpace.create(Ip.parse("10.10.10.4"))); Map<String, Configuration> configs = ImmutableMap.of(config.getHostname(), config); Map<String, Map<String, Set<Ip>>> interfaceOwnedIps = IpOwners.computeInterfaceOwnedIps(configs, false); Map<String, IpSpace> result = ForwardingAnalysisImpl.computeArpRepliesByInterface( interfaces, routableIpsByVrf, ipsRoutedOutInterfaces, interfaceOwnedIps); assertThat(result, hasEntry(equalTo(i1.getName()), containsIp(P1.getStartIp()))); assertThat(result, hasEntry(equalTo(i1.getName()), not(containsIp(P1.getEndIp())))); assertThat(result, hasEntry(equalTo(i1.getName()), not(containsIp(P3.getStartIp())))); assertThat(result, hasEntry(equalTo(i1.getName()), containsIp(P2.getStartIp()))); assertThat(result, hasEntry(equalTo(i1.getName()), containsIp(Ip.parse("10.10.10.1")))); assertThat(result, hasEntry(equalTo(i2.getName()), containsIp(P2.getStartIp()))); assertThat(result, hasEntry(equalTo(i2.getName()), not(containsIp(P2.getEndIp())))); assertThat(result, hasEntry(equalTo(i2.getName()), not(containsIp(P3.getStartIp())))); assertThat(result, hasEntry(equalTo(i2.getName()), not(containsIp(P1.getStartIp())))); assertThat(result, hasEntry(equalTo(i2.getName()), containsIp(Ip.parse("10.10.10.2")))); assertThat(result, hasEntry(equalTo(i3.getName()), equalTo(EmptyIpSpace.INSTANCE))); assertThat(result, hasEntry(equalTo(i4.getName()), containsIp(Ip.parse("10.10.10.4")))); }
@VisibleForTesting static Map<String, IpSpace> computeArpRepliesByInterface( Map<String, Interface> interfaces, Map<String, IpSpace> routableIpsByVrf, Map<String, Map<String, IpSpace>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { return toImmutableMap( interfaces, Entry::getKey, ifaceEntry -> computeInterfaceArpReplies( ifaceEntry.getValue(), routableIpsByVrf.get(ifaceEntry.getValue().getVrfName()), ipsRoutedOutInterfaces .get(ifaceEntry.getValue().getVrfName()) .getOrDefault(ifaceEntry.getKey(), EmptyIpSpace.INSTANCE), interfaceOwnedIps)); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, IpSpace> computeArpRepliesByInterface( Map<String, Interface> interfaces, Map<String, IpSpace> routableIpsByVrf, Map<String, Map<String, IpSpace>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { return toImmutableMap( interfaces, Entry::getKey, ifaceEntry -> computeInterfaceArpReplies( ifaceEntry.getValue(), routableIpsByVrf.get(ifaceEntry.getValue().getVrfName()), ipsRoutedOutInterfaces .get(ifaceEntry.getValue().getVrfName()) .getOrDefault(ifaceEntry.getKey(), EmptyIpSpace.INSTANCE), interfaceOwnedIps)); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, IpSpace> computeArpRepliesByInterface( Map<String, Interface> interfaces, Map<String, IpSpace> routableIpsByVrf, Map<String, Map<String, IpSpace>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { return toImmutableMap( interfaces, Entry::getKey, ifaceEntry -> computeInterfaceArpReplies( ifaceEntry.getValue(), routableIpsByVrf.get(ifaceEntry.getValue().getVrfName()), ipsRoutedOutInterfaces .get(ifaceEntry.getValue().getVrfName()) .getOrDefault(ifaceEntry.getKey(), EmptyIpSpace.INSTANCE), interfaceOwnedIps)); } 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, IpSpace> computeArpRepliesByInterface( Map<String, Interface> interfaces, Map<String, IpSpace> routableIpsByVrf, Map<String, Map<String, IpSpace>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { return toImmutableMap( interfaces, Entry::getKey, ifaceEntry -> computeInterfaceArpReplies( ifaceEntry.getValue(), routableIpsByVrf.get(ifaceEntry.getValue().getVrfName()), ipsRoutedOutInterfaces .get(ifaceEntry.getValue().getVrfName()) .getOrDefault(ifaceEntry.getKey(), EmptyIpSpace.INSTANCE), interfaceOwnedIps)); } 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, IpSpace> computeArpRepliesByInterface( Map<String, Interface> interfaces, Map<String, IpSpace> routableIpsByVrf, Map<String, Map<String, IpSpace>> ipsRoutedOutInterfaces, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { return toImmutableMap( interfaces, Entry::getKey, ifaceEntry -> computeInterfaceArpReplies( ifaceEntry.getValue(), routableIpsByVrf.get(ifaceEntry.getValue().getVrfName()), ipsRoutedOutInterfaces .get(ifaceEntry.getValue().getVrfName()) .getOrDefault(ifaceEntry.getKey(), EmptyIpSpace.INSTANCE), interfaceOwnedIps)); } 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();  }