@Test public void testComputeIpsAssignedToThisInterfaceForArpReplies() { Configuration config = _cb.build(); Map<String, Configuration> configs = ImmutableMap.of(config.getHostname(), config); _ib.setOwner(config); ConcreteInterfaceAddress primary = ConcreteInterfaceAddress.create(P1.getStartIp(), P1.getPrefixLength()); InterfaceAddress secondary = ConcreteInterfaceAddress.create(P2.getStartIp(), P2.getPrefixLength()); Interface i = _ib.setAddresses(primary, secondary).build(); Map<String, Map<String, Set<Ip>>> interfaceOwnedIps = IpOwners.computeInterfaceOwnedIps(configs, false); IpSpace result = computeIpsAssignedToThisInterfaceForArpReplies(i, interfaceOwnedIps); assertThat(result, containsIp(P1.getStartIp())); assertThat(result, containsIp(P2.getStartIp())); assertThat(result, not(containsIp(P2.getEndIp()))); Ip linkLocalIp = Ip.parse("169.254.0.1"); Interface i2 = _ib.setAddresses(LinkLocalAddress.of(linkLocalIp)).build(); IpSpace result2 = computeIpsAssignedToThisInterfaceForArpReplies(i2, interfaceOwnedIps); assertThat(result2, containsIp(linkLocalIp)); }
@VisibleForTesting static IpSpace computeIpsAssignedToThisInterfaceForArpReplies( Interface iface, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { Set<Ip> concreteIps = interfaceOwnedIps .getOrDefault(iface.getOwner().getHostname(), ImmutableMap.of()) .getOrDefault(iface.getName(), ImmutableSet.of()); Set<LinkLocalAddress> linkLocalIps = iface.getAllLinkLocalAddresses(); if (concreteIps.isEmpty() && linkLocalIps.isEmpty()) { return EmptyIpSpace.INSTANCE; } IpWildcardSetIpSpace.Builder ipsAssignedToThisInterfaceBuilder = IpWildcardSetIpSpace.builder(); concreteIps.forEach(ip -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(ip))); linkLocalIps.forEach( addr -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(addr.getIp()))); return ipsAssignedToThisInterfaceBuilder.build(); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static IpSpace computeIpsAssignedToThisInterfaceForArpReplies( Interface iface, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { Set<Ip> concreteIps = interfaceOwnedIps .getOrDefault(iface.getOwner().getHostname(), ImmutableMap.of()) .getOrDefault(iface.getName(), ImmutableSet.of()); Set<LinkLocalAddress> linkLocalIps = iface.getAllLinkLocalAddresses(); if (concreteIps.isEmpty() && linkLocalIps.isEmpty()) { return EmptyIpSpace.INSTANCE; } IpWildcardSetIpSpace.Builder ipsAssignedToThisInterfaceBuilder = IpWildcardSetIpSpace.builder(); concreteIps.forEach(ip -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(ip))); linkLocalIps.forEach( addr -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(addr.getIp()))); return ipsAssignedToThisInterfaceBuilder.build(); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static IpSpace computeIpsAssignedToThisInterfaceForArpReplies( Interface iface, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { Set<Ip> concreteIps = interfaceOwnedIps .getOrDefault(iface.getOwner().getHostname(), ImmutableMap.of()) .getOrDefault(iface.getName(), ImmutableSet.of()); Set<LinkLocalAddress> linkLocalIps = iface.getAllLinkLocalAddresses(); if (concreteIps.isEmpty() && linkLocalIps.isEmpty()) { return EmptyIpSpace.INSTANCE; } IpWildcardSetIpSpace.Builder ipsAssignedToThisInterfaceBuilder = IpWildcardSetIpSpace.builder(); concreteIps.forEach(ip -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(ip))); linkLocalIps.forEach( addr -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(addr.getIp()))); return ipsAssignedToThisInterfaceBuilder.build(); } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static IpSpace computeIpsAssignedToThisInterfaceForArpReplies( Interface iface, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { Set<Ip> concreteIps = interfaceOwnedIps .getOrDefault(iface.getOwner().getHostname(), ImmutableMap.of()) .getOrDefault(iface.getName(), ImmutableSet.of()); Set<LinkLocalAddress> linkLocalIps = iface.getAllLinkLocalAddresses(); if (concreteIps.isEmpty() && linkLocalIps.isEmpty()) { return EmptyIpSpace.INSTANCE; } IpWildcardSetIpSpace.Builder ipsAssignedToThisInterfaceBuilder = IpWildcardSetIpSpace.builder(); concreteIps.forEach(ip -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(ip))); linkLocalIps.forEach( addr -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(addr.getIp()))); return ipsAssignedToThisInterfaceBuilder.build(); } 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 IpSpace computeIpsAssignedToThisInterfaceForArpReplies( Interface iface, Map<String, Map<String, Set<Ip>>> interfaceOwnedIps) { Set<Ip> concreteIps = interfaceOwnedIps .getOrDefault(iface.getOwner().getHostname(), ImmutableMap.of()) .getOrDefault(iface.getName(), ImmutableSet.of()); Set<LinkLocalAddress> linkLocalIps = iface.getAllLinkLocalAddresses(); if (concreteIps.isEmpty() && linkLocalIps.isEmpty()) { return EmptyIpSpace.INSTANCE; } IpWildcardSetIpSpace.Builder ipsAssignedToThisInterfaceBuilder = IpWildcardSetIpSpace.builder(); concreteIps.forEach(ip -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(ip))); linkLocalIps.forEach( addr -> ipsAssignedToThisInterfaceBuilder.including(IpWildcard.create(addr.getIp()))); return ipsAssignedToThisInterfaceBuilder.build(); } 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();  }