@Override public Boolean visitInterfaceLinkLocation(InterfaceLinkLocation interfaceLinkLocation) { return interfaceLinkLocation.getNodeName().equals(node); }
@Override public Optional<StateExpr> visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { return Optional.of( new OriginateInterfaceLink( interfaceLinkLocation.getNodeName(), interfaceLinkLocation.getInterfaceName())); }
@Override public IngressLocation visitInterfaceLinkLocation(InterfaceLinkLocation interfaceLinkLocation) { return IngressLocation.interfaceLink( interfaceLinkLocation.getNodeName(), interfaceLinkLocation.getInterfaceName()); }
@Override public Void visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { flowBuilder .setIngressInterface(interfaceLinkLocation.getInterfaceName()) .setIngressNode(interfaceLinkLocation.getNodeName()) .setIngressVrf(null); return null; }
@Override public Void visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { flowBuilder .setIngressInterface(interfaceLinkLocation.getInterfaceName()) .setIngressNode(interfaceLinkLocation.getNodeName()) .setIngressVrf(null); return null; }
@Override public IpSpace visitInterfaceLinkLocation(InterfaceLinkLocation interfaceLinkLocation) { String node = interfaceLinkLocation.getNodeName(); String iface = interfaceLinkLocation.getInterfaceName(); @Nullable IpSpace linkIpSpace = AclIpSpace.union( interfaceAddresses(node, iface).stream() /* * Only include addresses on networks that might have hosts. */ .filter(address -> address.getNetworkBits() <= HOST_SUBNET_MAX_PREFIX_LENGTH) .map(address -> address.getPrefix().toHostIpSpace()) .collect(Collectors.toList())); return linkIpSpace == null ? EmptyIpSpace.INSTANCE : AclIpSpace.difference(linkIpSpace, _specifierContext.getSnapshotDeviceOwnedIps()); }
/** Returns {@code true} iff the given {@link Location} is active (aka, interface is up). */ @VisibleForTesting static boolean isActive(Location l, Map<String, Configuration> configs) { NodeInterfacePair iface; if (l instanceof InterfaceLocation) { iface = new NodeInterfacePair( ((InterfaceLocation) l).getNodeName(), ((InterfaceLocation) l).getInterfaceName()); } else { assert l instanceof InterfaceLinkLocation; iface = new NodeInterfacePair( ((InterfaceLinkLocation) l).getNodeName(), ((InterfaceLinkLocation) l).getInterfaceName()); } return configs .get(iface.getHostname()) .getAllInterfaces() .get(iface.getInterface()) .getActive(); }