Search in sources :

Example 6 with Host

use of org.onosproject.net.Host in project trellis-control by opennetworkinglab.

the class HostHandler method processIntfVlanUpdatedEvent.

/**
 * Update forwarding objective for unicast bridging and unicast routing.
 * Also check the validity of updated interface configuration on VLAN.
 *
 * @param deviceId device ID that host attaches to
 * @param portNum port number that host attaches to
 * @param vlanId Vlan ID configured on the switch port
 * @param popVlan true to pop Vlan tag at TrafficTreatment, false otherwise
 * @param install true to populate the objective, false to revoke
 */
// TODO Current implementation does not handle dual-homed hosts with auxiliary locations.
void processIntfVlanUpdatedEvent(DeviceId deviceId, PortNumber portNum, VlanId vlanId, boolean popVlan, boolean install) {
    ConnectPoint connectPoint = new ConnectPoint(deviceId, portNum);
    Set<Host> hosts = hostService.getConnectedHosts(connectPoint);
    if (hosts == null || hosts.size() == 0) {
        log.debug("processIntfVlanUpdatedEvent: No hosts connected to {}", connectPoint);
        return;
    }
    List<CompletableFuture<Void>> hostFutures = Lists.newArrayList();
    hosts.forEach(host -> hostFutures.add(hostWorkers.submit(() -> processIntfVlanUpdatedEventInternal(host, deviceId, portNum, vlanId, popVlan, install), host.id().hashCode())));
    // Let's wait for the completion of all hosts
    try {
        CompletableFuture.allOf(hostFutures.toArray(new CompletableFuture[0])).thenApply(objectives -> hostFutures.stream().map(CompletableFuture::join).collect(Collectors.toList())).get();
    } catch (InterruptedException | ExecutionException e) {
        log.warn("Exception caught when executing processIntfVlanUpdatedEvent futures");
        hostFutures.forEach(future -> future.cancel(false));
    }
}
Also used : HostLocation(org.onosproject.net.HostLocation) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) PredictableExecutor(org.onlab.util.PredictableExecutor) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) CompletableFuture(java.util.concurrent.CompletableFuture) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) IpAddress(org.onlab.packet.IpAddress) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Phase(org.onosproject.segmentrouting.phasedrecovery.api.Phase) ProbeMode(org.onosproject.net.host.ProbeMode) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) EthType(org.onlab.packet.EthType) List(java.util.List) Objective(org.onosproject.net.flowobjective.Objective) Optional(java.util.Optional) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) CompletableFuture(java.util.concurrent.CompletableFuture) Host(org.onosproject.net.Host) ExecutionException(java.util.concurrent.ExecutionException) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 7 with Host

use of org.onosproject.net.Host in project trellis-control by opennetworkinglab.

the class RoutingRulePopulator method anyDoubleTaggedHost.

/**
 * Checks if there is any double tagged host attached to given location.
 * This method will match on the effective location of a host.
 * That is, it will match on auxLocations when auxLocations is not null. Otherwise, it will match on locations.
 *
 * @param deviceId device ID
 * @param portNum port number
 * @return true if there is any host attached to given location.
 */
private boolean anyDoubleTaggedHost(DeviceId deviceId, PortNumber portNum) {
    ConnectPoint cp = new ConnectPoint(deviceId, portNum);
    Set<Host> connectedHosts = srManager.hostService.getConnectedHosts(cp, false);
    Set<Host> auxConnectedHosts = srManager.hostService.getConnectedHosts(cp, true);
    return !auxConnectedHosts.isEmpty() || connectedHosts.stream().anyMatch(host -> host.auxLocations() == null);
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) TYPE_IPV6(org.onlab.packet.Ethernet.TYPE_IPV6) CLEANUP_DOUBLE_TAGGED_HOST_ENTRIES(org.onosproject.segmentrouting.metadata.SRObjectiveMetadata.CLEANUP_DOUBLE_TAGGED_HOST_ENTRIES) Interface(org.onosproject.net.intf.Interface) INTERFACE_CONFIG_UPDATE(org.onosproject.segmentrouting.metadata.SRObjectiveMetadata.INTERFACE_CONFIG_UPDATE) ROUTER_ADVERTISEMENT(org.onlab.packet.ICMP6.ROUTER_ADVERTISEMENT) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) TYPE_ARP(org.onlab.packet.Ethernet.TYPE_ARP) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) NEIGHBOR_SOLICITATION(org.onlab.packet.ICMP6.NEIGHBOR_SOLICITATION) Port(org.onosproject.net.Port) Map(java.util.Map) EDGE_PORT(org.onosproject.segmentrouting.metadata.SRObjectiveMetadata.EDGE_PORT) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Device(org.onosproject.net.Device) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Collection(java.util.Collection) Set(java.util.Set) Builder(org.onosproject.net.flowobjective.ForwardingObjective.Builder) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) EthType(org.onlab.packet.EthType) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) Optional(java.util.Optional) NEIGHBOR_ADVERTISEMENT(org.onlab.packet.ICMP6.NEIGHBOR_ADVERTISEMENT) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) Host(org.onosproject.net.Host) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) INFRA_PORT(org.onosproject.segmentrouting.metadata.SRObjectiveMetadata.INFRA_PORT) Flag(org.onosproject.net.flowobjective.ForwardingObjective.Flag) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) PAIR_PORT(org.onosproject.segmentrouting.metadata.SRObjectiveMetadata.PAIR_PORT) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) MplsLabel(org.onlab.packet.MplsLabel) VlanId(org.onlab.packet.VlanId) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) PROTOCOL_ICMP6(org.onlab.packet.IPv6.PROTOCOL_ICMP6) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) IPv6(org.onlab.packet.IPv6) ExecutionException(java.util.concurrent.ExecutionException) AtomicLong(java.util.concurrent.atomic.AtomicLong) DestinationSet(org.onosproject.segmentrouting.grouphandler.DestinationSet) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) PacketPriority(org.onosproject.net.packet.PacketPriority) Collections(java.util.Collections) ROUTER_SOLICITATION(org.onlab.packet.ICMP6.ROUTER_SOLICITATION) Host(org.onosproject.net.Host) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 8 with Host

use of org.onosproject.net.Host in project trellis-control by opennetworkinglab.

the class SegmentRoutingManager method modified.

@Modified
private void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();
    if (properties == null) {
        return;
    }
    String strActiveProbing = Tools.get(properties, PROP_ACTIVE_PROBING);
    boolean expectActiveProbing = Boolean.parseBoolean(strActiveProbing);
    if (expectActiveProbing != activeProbing) {
        activeProbing = expectActiveProbing;
        log.info("{} active probing", activeProbing ? "Enabling" : "Disabling");
    }
    String strSymmetricProbing = Tools.get(properties, PROP_SYMMETRIC_PROBING);
    boolean expectSymmetricProbing = Boolean.parseBoolean(strSymmetricProbing);
    if (expectSymmetricProbing != symmetricProbing) {
        symmetricProbing = expectSymmetricProbing;
        log.info("{} symmetric probing", symmetricProbing ? "Enabling" : "Disabling");
    }
    String strSingleHomedDown = Tools.get(properties, PROP_SINGLE_HOMED_DOWN);
    boolean expectSingleHomedDown = Boolean.parseBoolean(strSingleHomedDown);
    if (expectSingleHomedDown != singleHomedDown) {
        singleHomedDown = expectSingleHomedDown;
        log.info("{} downing of single homed hosts for lost uplinks", singleHomedDown ? "Enabling" : "Disabling");
        if (singleHomedDown && linkHandler != null) {
            hostService.getHosts().forEach(host -> host.locations().forEach(loc -> {
                if (interfaceService.isConfigured(loc)) {
                    linkHandler.checkUplinksForHost(loc);
                }
            }));
        } else {
            log.warn("Disabling singleHomedDown does not re-enable already " + "downed ports for single-homed hosts");
        }
    }
    String strRespondToUnknownHosts = Tools.get(properties, PROP_RESPOND_TO_UNKNOWN_HOSTS);
    boolean expectRespondToUnknownHosts = Boolean.parseBoolean(strRespondToUnknownHosts);
    if (expectRespondToUnknownHosts != respondToUnknownHosts) {
        respondToUnknownHosts = expectRespondToUnknownHosts;
        log.info("{} responding to ARPs/NDPs from unknown hosts", respondToUnknownHosts ? "Enabling" : "Disabling");
    }
    String strRouteDoubleTaggedHosts = Tools.get(properties, PROP_ROUTE_DOUBLE_TAGGED_HOSTS);
    boolean expectRouteDoubleTaggedHosts = Boolean.parseBoolean(strRouteDoubleTaggedHosts);
    if (expectRouteDoubleTaggedHosts != routeDoubleTaggedHosts) {
        routeDoubleTaggedHosts = expectRouteDoubleTaggedHosts;
        log.info("{} routing for double tagged hosts", routeDoubleTaggedHosts ? "Enabling" : "Disabling");
        if (routeDoubleTaggedHosts) {
            hostHandler.populateAllDoubleTaggedHost();
        } else {
            hostHandler.revokeAllDoubleTaggedHost();
        }
    }
    String strDefaultInternalVlan = Tools.get(properties, PROP_DEFAULT_INTERNAL_VLAN);
    int defIntVlan = Integer.parseInt(strDefaultInternalVlan);
    if (defIntVlan != defaultInternalVlan) {
        if (canUseVlanId(defIntVlan)) {
            log.warn("Default internal vlan value changed from {} to {}.. " + "re-programming filtering rules, but NOT any groups already " + "created with the former value", defaultInternalVlan, defIntVlan);
            VlanId oldDefIntVlan = VlanId.vlanId((short) defaultInternalVlan);
            defaultInternalVlan = defIntVlan;
            routingRulePopulator.updateSpecialVlanFilteringRules(true, oldDefIntVlan, VlanId.vlanId((short) defIntVlan));
        } else {
            log.warn("Cannot change default internal vlan to unusable " + "value {}", defIntVlan);
        }
    }
    String strPwTxpVlan = Tools.get(properties, PROP_PW_TRANSPORT_VLAN);
    int pwTxpVlan = Integer.parseInt(strPwTxpVlan);
    if (pwTxpVlan != pwTransportVlan) {
        if (canUseVlanId(pwTxpVlan)) {
            log.warn("Pseudowire transport vlan value changed from {} to {}.. " + "re-programming filtering rules, but NOT any groups already " + "created with the former value", pwTransportVlan, pwTxpVlan);
            VlanId oldPwTxpVlan = VlanId.vlanId((short) pwTransportVlan);
            pwTransportVlan = pwTxpVlan;
            routingRulePopulator.updateSpecialVlanFilteringRules(false, oldPwTxpVlan, VlanId.vlanId((short) pwTxpVlan));
        } else {
            log.warn("Cannot change pseudowire transport vlan to unusable " + "value {}", pwTxpVlan);
        }
    }
    String strRouteSimplification = Tools.get(properties, PROP_ROUTE_SIMPLIFICATION);
    boolean expectRouteSimplification = Boolean.parseBoolean(strRouteSimplification);
    if (expectRouteSimplification != routeSimplification) {
        routeSimplification = expectRouteSimplification;
        log.info("{} route simplification", routeSimplification ? "Enabling" : "Disabling");
    }
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) ROUTE_SIMPLIFICATION_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_SIMPLIFICATION_DEFAULT) McastStoreKey(org.onosproject.segmentrouting.mcast.McastStoreKey) PROP_ACTIVE_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ACTIVE_PROBING) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) TYPE_ARP(org.onlab.packet.Ethernet.TYPE_ARP) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription) ConnectPoint(org.onosproject.net.ConnectPoint) StorageService(org.onosproject.store.service.StorageService) SubjectFactories(org.onosproject.net.config.basics.SubjectFactories) McastEvent(org.onosproject.mcast.api.McastEvent) Port(org.onosproject.net.Port) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) MulticastRouteService(org.onosproject.mcast.api.MulticastRouteService) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) SYMMETRIC_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SYMMETRIC_PROBING_DEFAULT) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) DEFAULT_INTERNAL_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.DEFAULT_INTERNAL_VLAN_DEFAULT) Executors(java.util.concurrent.Executors) RouteListener(org.onosproject.routeservice.RouteListener) ConfigFactory(org.onosproject.net.config.ConfigFactory) LinkListener(org.onosproject.net.link.LinkListener) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) ConfigException(org.onosproject.net.config.ConfigException) Dictionary(java.util.Dictionary) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) LinkEvent(org.onosproject.net.link.LinkEvent) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) ComponentContext(org.osgi.service.component.ComponentContext) RouteEvent(org.onosproject.routeservice.RouteEvent) KryoNamespace(org.onlab.util.KryoNamespace) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) McastListener(org.onosproject.mcast.api.McastListener) CONFIG_UNREGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UNREGISTERED) RESPOND_TO_UNKNOWN_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.RESPOND_TO_UNKNOWN_HOSTS_DEFAULT) MastershipEvent(org.onosproject.mastership.MastershipEvent) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NextNeighbors(org.onosproject.segmentrouting.grouphandler.NextNeighbors) DefaultL2TunnelHandler(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) DeviceListener(org.onosproject.net.device.DeviceListener) VlanId(org.onlab.packet.VlanId) PW_TRANSPORT_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.PW_TRANSPORT_VLAN_DEFAULT) IPv6(org.onlab.packet.IPv6) ExecutionException(java.util.concurrent.ExecutionException) IPv4(org.onlab.packet.IPv4) CONFIG_REGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REGISTERED) DestinationSetNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey) MacAddress(org.onlab.packet.MacAddress) PROP_PW_TRANSPORT_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_PW_TRANSPORT_VLAN) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) PROP_ROUTE_DOUBLE_TAGGED_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_DOUBLE_TAGGED_HOSTS) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ScheduledFuture(java.util.concurrent.ScheduledFuture) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) McastConfig(org.onosproject.net.config.basics.McastConfig) TopologyService(org.onosproject.net.topology.TopologyService) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Link(org.onosproject.net.Link) Ethernet(org.onlab.packet.Ethernet) HashMultimap(com.google.common.collect.HashMultimap) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) McastFilteringObjStoreKey(org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey) PROP_ROUTE_SIMPLIFICATION(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_SIMPLIFICATION) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) PROP_DEFAULT_INTERNAL_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_DEFAULT_INTERNAL_VLAN) Event(org.onosproject.event.Event) NodeId(org.onosproject.cluster.NodeId) RouteService(org.onosproject.routeservice.RouteService) McastHandler(org.onosproject.segmentrouting.mcast.McastHandler) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ClusterEvent(org.onosproject.cluster.ClusterEvent) ImmutableMap(com.google.common.collect.ImmutableMap) Device(org.onosproject.net.Device) PacketProcessor(org.onosproject.net.packet.PacketProcessor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PROP_RESPOND_TO_UNKNOWN_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_RESPOND_TO_UNKNOWN_HOSTS) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) IpPrefix(org.onlab.packet.IpPrefix) McastRole(org.onosproject.segmentrouting.mcast.McastRole) McastRoleStoreKey(org.onosproject.segmentrouting.mcast.McastRoleStoreKey) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) ICMP6(org.onlab.packet.ICMP6) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) CompletableFuture(java.util.concurrent.CompletableFuture) Multimap(com.google.common.collect.Multimap) XConnectStoreKey(org.onosproject.segmentrouting.storekey.XConnectStoreKey) ACTIVE_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ACTIVE_PROBING_DEFAULT) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) HashSet(java.util.HashSet) L2TunnelHandler(org.onosproject.segmentrouting.pwaas.L2TunnelHandler) DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) PROP_SYMMETRIC_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SYMMETRIC_PROBING) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) HostProbingService(org.onosproject.net.host.HostProbingService) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) HostId(org.onosproject.net.HostId) SINGLE_HOMED_DOWN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SINGLE_HOMED_DOWN_DEFAULT) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ClusterEventListener(org.onosproject.cluster.ClusterEventListener) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) Logger(org.slf4j.Logger) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) DestinationSet(org.onosproject.segmentrouting.grouphandler.DestinationSet) Modified(org.osgi.service.component.annotations.Modified) MastershipListener(org.onosproject.mastership.MastershipListener) PROP_SINGLE_HOMED_DOWN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SINGLE_HOMED_DOWN) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) TopologyListener(org.onosproject.net.topology.TopologyListener) ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId) Modified(org.osgi.service.component.annotations.Modified)

Example 9 with Host

use of org.onosproject.net.Host in project trellis-control by opennetworkinglab.

the class SegmentRoutingManager method removeSubnetConfig.

private void removeSubnetConfig(ConnectPoint cp, Set<InterfaceIpAddress> ipAddressSet) {
    Set<IpPrefix> ipPrefixSet = ipAddressSet.stream().map(InterfaceIpAddress::subnetAddress).collect(Collectors.toSet());
    Set<InterfaceIpAddress> deviceIntfIpAddrs = interfaceService.getInterfaces().stream().filter(intf -> intf.connectPoint().deviceId().equals(cp.deviceId())).filter(intf -> !intf.connectPoint().equals(cp)).flatMap(intf -> intf.ipAddressesList().stream()).collect(Collectors.toSet());
    // 1. Partial subnet population
    // Remove routing rules for removed subnet from previous configuration,
    // which does not also exist in other interfaces in the same device
    Set<IpPrefix> deviceIpPrefixSet = deviceIntfIpAddrs.stream().map(InterfaceIpAddress::subnetAddress).collect(Collectors.toSet());
    Set<IpPrefix> subnetsToBeRevoked = ipPrefixSet.stream().filter(ipPrefix -> !deviceIpPrefixSet.contains(ipPrefix)).collect(Collectors.toSet());
    // Check if any of the subnets to be revoked is configured in the pairDevice.
    // If any, repopulate the subnet with pairDevice connectPoint instead of revoking.
    Optional<DeviceId> pairDevice = getPairDeviceId(cp.deviceId());
    if (pairDevice.isPresent()) {
        Set<IpPrefix> pairDeviceIpPrefix = getDeviceSubnetMap().get(pairDevice.get());
        Set<IpPrefix> subnetsExistingInPairDevice = subnetsToBeRevoked.stream().filter(ipPrefix -> pairDeviceIpPrefix.contains(ipPrefix)).collect(Collectors.toSet());
        // Update the subnets existing in pair device with pair device connect point.
        if (!subnetsExistingInPairDevice.isEmpty()) {
            // PortNumber of connect point is not relevant in populate subnet and hence providing as ANY.
            ConnectPoint pairDeviceCp = new ConnectPoint(pairDevice.get(), PortNumber.ANY);
            log.debug("Updating the subnets: {} with pairDevice connectPoint as it exists in the Pair device: {}", subnetsExistingInPairDevice, pairDeviceCp);
            defaultRoutingHandler.populateSubnet(Collections.singleton(pairDeviceCp), subnetsExistingInPairDevice);
        }
        // Remove only the subnets that are not configured in the pairDevice.
        subnetsToBeRevoked = Sets.difference(subnetsToBeRevoked, subnetsExistingInPairDevice);
    }
    if (!subnetsToBeRevoked.isEmpty()) {
        log.debug("Removing subnets for connectPoint: {}, subnets: {}", cp, subnetsToBeRevoked);
        defaultRoutingHandler.revokeSubnet(subnetsToBeRevoked, cp.deviceId());
    }
    // 2. Interface IP punts
    // Remove IP punts for old Intf address
    Set<IpAddress> deviceIpAddrs = deviceIntfIpAddrs.stream().map(InterfaceIpAddress::ipAddress).collect(Collectors.toSet());
    ipAddressSet.stream().map(InterfaceIpAddress::ipAddress).filter(interfaceIpAddress -> !deviceIpAddrs.contains(interfaceIpAddress)).forEach(interfaceIpAddress -> routingRulePopulator.revokeSingleIpPunts(cp.deviceId(), interfaceIpAddress));
    // 3. Host unicast routing rule
    // Remove unicast routing rule
    hostEventExecutor.execute(() -> hostHandler.processIntfIpUpdatedEvent(cp, ipPrefixSet, false));
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) ROUTE_SIMPLIFICATION_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_SIMPLIFICATION_DEFAULT) McastStoreKey(org.onosproject.segmentrouting.mcast.McastStoreKey) PROP_ACTIVE_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ACTIVE_PROBING) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) TYPE_ARP(org.onlab.packet.Ethernet.TYPE_ARP) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription) ConnectPoint(org.onosproject.net.ConnectPoint) StorageService(org.onosproject.store.service.StorageService) SubjectFactories(org.onosproject.net.config.basics.SubjectFactories) McastEvent(org.onosproject.mcast.api.McastEvent) Port(org.onosproject.net.Port) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) MulticastRouteService(org.onosproject.mcast.api.MulticastRouteService) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) SYMMETRIC_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SYMMETRIC_PROBING_DEFAULT) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) DEFAULT_INTERNAL_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.DEFAULT_INTERNAL_VLAN_DEFAULT) Executors(java.util.concurrent.Executors) RouteListener(org.onosproject.routeservice.RouteListener) ConfigFactory(org.onosproject.net.config.ConfigFactory) LinkListener(org.onosproject.net.link.LinkListener) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) ConfigException(org.onosproject.net.config.ConfigException) Dictionary(java.util.Dictionary) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) LinkEvent(org.onosproject.net.link.LinkEvent) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) ComponentContext(org.osgi.service.component.ComponentContext) RouteEvent(org.onosproject.routeservice.RouteEvent) KryoNamespace(org.onlab.util.KryoNamespace) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) McastListener(org.onosproject.mcast.api.McastListener) CONFIG_UNREGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UNREGISTERED) RESPOND_TO_UNKNOWN_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.RESPOND_TO_UNKNOWN_HOSTS_DEFAULT) MastershipEvent(org.onosproject.mastership.MastershipEvent) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NextNeighbors(org.onosproject.segmentrouting.grouphandler.NextNeighbors) DefaultL2TunnelHandler(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) DeviceListener(org.onosproject.net.device.DeviceListener) VlanId(org.onlab.packet.VlanId) PW_TRANSPORT_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.PW_TRANSPORT_VLAN_DEFAULT) IPv6(org.onlab.packet.IPv6) ExecutionException(java.util.concurrent.ExecutionException) IPv4(org.onlab.packet.IPv4) CONFIG_REGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REGISTERED) DestinationSetNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey) MacAddress(org.onlab.packet.MacAddress) PROP_PW_TRANSPORT_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_PW_TRANSPORT_VLAN) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) PROP_ROUTE_DOUBLE_TAGGED_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_DOUBLE_TAGGED_HOSTS) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ScheduledFuture(java.util.concurrent.ScheduledFuture) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) McastConfig(org.onosproject.net.config.basics.McastConfig) TopologyService(org.onosproject.net.topology.TopologyService) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Link(org.onosproject.net.Link) Ethernet(org.onlab.packet.Ethernet) HashMultimap(com.google.common.collect.HashMultimap) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) McastFilteringObjStoreKey(org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey) PROP_ROUTE_SIMPLIFICATION(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_SIMPLIFICATION) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) PROP_DEFAULT_INTERNAL_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_DEFAULT_INTERNAL_VLAN) Event(org.onosproject.event.Event) NodeId(org.onosproject.cluster.NodeId) RouteService(org.onosproject.routeservice.RouteService) McastHandler(org.onosproject.segmentrouting.mcast.McastHandler) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ClusterEvent(org.onosproject.cluster.ClusterEvent) ImmutableMap(com.google.common.collect.ImmutableMap) Device(org.onosproject.net.Device) PacketProcessor(org.onosproject.net.packet.PacketProcessor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PROP_RESPOND_TO_UNKNOWN_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_RESPOND_TO_UNKNOWN_HOSTS) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) IpPrefix(org.onlab.packet.IpPrefix) McastRole(org.onosproject.segmentrouting.mcast.McastRole) McastRoleStoreKey(org.onosproject.segmentrouting.mcast.McastRoleStoreKey) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) ICMP6(org.onlab.packet.ICMP6) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) CompletableFuture(java.util.concurrent.CompletableFuture) Multimap(com.google.common.collect.Multimap) XConnectStoreKey(org.onosproject.segmentrouting.storekey.XConnectStoreKey) ACTIVE_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ACTIVE_PROBING_DEFAULT) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) HashSet(java.util.HashSet) L2TunnelHandler(org.onosproject.segmentrouting.pwaas.L2TunnelHandler) DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) PROP_SYMMETRIC_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SYMMETRIC_PROBING) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) HostProbingService(org.onosproject.net.host.HostProbingService) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) HostId(org.onosproject.net.HostId) SINGLE_HOMED_DOWN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SINGLE_HOMED_DOWN_DEFAULT) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ClusterEventListener(org.onosproject.cluster.ClusterEventListener) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) Logger(org.slf4j.Logger) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) DestinationSet(org.onosproject.segmentrouting.grouphandler.DestinationSet) Modified(org.osgi.service.component.annotations.Modified) MastershipListener(org.onosproject.mastership.MastershipListener) PROP_SINGLE_HOMED_DOWN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SINGLE_HOMED_DOWN) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) TopologyListener(org.onosproject.net.topology.TopologyListener) DeviceId(org.onosproject.net.DeviceId) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) IpAddress(org.onlab.packet.IpAddress) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 10 with Host

use of org.onosproject.net.Host in project trellis-control by opennetworkinglab.

the class SegmentRoutingNeighbourHandler method sendResponse.

/**
 * Utility to send a ND reply using the supplied information.
 *
 * @param pkt the request
 * @param targetMac the target mac
 * @param hostService the host service
 * @param isRouter true if this reply is sent on behalf of a router
 */
protected void sendResponse(NeighbourMessageContext pkt, MacAddress targetMac, HostService hostService, boolean isRouter) {
    // if this is false, check if host exists in the store
    if (!respondToUnknownHosts()) {
        short vlanId = pkt.packet().getQinQVID();
        HostId dstId = HostId.hostId(pkt.srcMac(), vlanId == Ethernet.VLAN_UNTAGGED ? pkt.vlan() : VlanId.vlanId(vlanId));
        Host dst = hostService.getHost(dstId);
        if (dst == null) {
            log.warn("Cannot send {} response to host {} - does not exist in the store", pkt.protocol(), dstId);
            return;
        }
    }
    pkt.setIsRouter(isRouter);
    pkt.reply(targetMac);
}
Also used : Host(org.onosproject.net.Host) HostId(org.onosproject.net.HostId)

Aggregations

Host (org.onosproject.net.Host)144 MacAddress (org.onlab.packet.MacAddress)55 IpAddress (org.onlab.packet.IpAddress)54 HostEvent (org.onosproject.net.host.HostEvent)50 ConnectPoint (org.onosproject.net.ConnectPoint)47 Test (org.junit.Test)45 DefaultHost (org.onosproject.net.DefaultHost)45 HostService (org.onosproject.net.host.HostService)45 Set (java.util.Set)43 VlanId (org.onlab.packet.VlanId)43 DeviceId (org.onosproject.net.DeviceId)39 Logger (org.slf4j.Logger)39 HostLocation (org.onosproject.net.HostLocation)38 LoggerFactory (org.slf4j.LoggerFactory)37 List (java.util.List)34 HostId (org.onosproject.net.HostId)33 Interface (org.onosproject.net.intf.Interface)32 Sets (com.google.common.collect.Sets)31 Optional (java.util.Optional)30 Lists (com.google.common.collect.Lists)29