Search in sources :

Example 6 with XconnectKey

use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.

the class XconnectManager method revokeFilter.

/**
 * Revokes filtering objectives for given XConnect.
 *
 * @param key       XConnect store key
 * @param endpoints XConnect endpoints
 */
private void revokeFilter(XconnectKey key, Set<XconnectEndpoint> endpoints) {
    // FIXME Improve the logic
    // If port load balancer is not involved, use filtered port. Otherwise, use unfiltered port.
    // The purpose is to make sure existing XConnect logic can still work on a configured port.
    boolean filtered = endpoints.stream().map(ep -> getNextTreatment(key.deviceId(), ep, false)).allMatch(t -> t.type().equals(NextTreatment.Type.TREATMENT));
    endpoints.stream().map(ep -> getPhysicalPorts(key.deviceId(), ep)).flatMap(Set::stream).forEach(port -> {
        FilteringObjective.Builder filtObjBuilder = filterObjBuilder(key, port, filtered);
        ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("XConnect FilterObj for {} on port {} revoked", key, port), (objective, error) -> log.warn("Failed to revoke XConnect FilterObj for {} on port {}: {}", key, port, error));
        flowObjectiveService.filter(key.deviceId(), filtObjBuilder.remove(context));
    });
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) HostLocation(org.onosproject.net.HostLocation) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) XconnectKey(org.onosproject.segmentrouting.xconnect.api.XconnectKey) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) StorageService(org.onosproject.store.service.StorageService) Executors.newScheduledThreadPool(java.util.concurrent.Executors.newScheduledThreadPool) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) Serializer(org.onosproject.store.service.Serializer) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) XconnectDesc(org.onosproject.segmentrouting.xconnect.api.XconnectDesc) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Executors(java.util.concurrent.Executors) Serializable(java.io.Serializable) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) XconnectLoadBalancerEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectLoadBalancerEndpoint) Versioned(org.onosproject.store.service.Versioned) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DeviceEvent(org.onosproject.net.device.DeviceEvent) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) DeviceId(org.onosproject.net.DeviceId) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) Host(org.onosproject.net.Host) DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) PortLoadBalancerService(org.onosproject.portloadbalancer.api.PortLoadBalancerService) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) CompletableFuture(java.util.concurrent.CompletableFuture) KryoNamespace(org.onlab.util.KryoNamespace) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) MapEventListener(org.onosproject.store.service.MapEventListener) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BiConsumer(java.util.function.BiConsumer) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ExecutorService(java.util.concurrent.ExecutorService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) RemovalNotification(com.google.common.cache.RemovalNotification) DeviceListener(org.onosproject.net.device.DeviceListener) XconnectEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PortLoadBalancerEvent(org.onosproject.portloadbalancer.api.PortLoadBalancerEvent) XconnectCodec(org.onosproject.segmentrouting.xconnect.api.XconnectCodec) VlanId(org.onlab.packet.VlanId) CodecService(org.onosproject.codec.CodecService) IdNextTreatment(org.onosproject.net.flowobjective.IdNextTreatment) XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) PortLoadBalancerListener(org.onosproject.portloadbalancer.api.PortLoadBalancerListener) MapEvent(org.onosproject.store.service.MapEvent) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Cache(com.google.common.cache.Cache) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective)

Example 7 with XconnectKey

use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.

the class XconnectManager method updateL2Flooding.

/**
 * Updates L2 flooding groups; add pair link into L2 flooding group of given xconnect vlan.
 *
 * @param deviceId Device ID
 * @param port     Port details
 * @param vlanId   VLAN ID
 * @param install  Whether to add or revoke pair link addition to flooding group
 */
private void updateL2Flooding(DeviceId deviceId, PortNumber port, VlanId vlanId, boolean install) {
    XconnectKey key = new XconnectKey(deviceId, vlanId);
    // Ensure leadership on device
    if (!srService.shouldProgram(deviceId)) {
        log.debug("Abort updating L2Flood {}: {}", key, ERROR_NOT_LEADER);
        return;
    }
    // Locate L2 flooding group details for given xconnect vlan
    int nextId = Versioned.valueOrElse(xconnectNextObjStore.get(key), -1);
    if (nextId == -1) {
        log.debug("XConnect vlan {} broadcast group for device {} doesn't exists. " + "Aborting pair group linking.", vlanId, deviceId);
        return;
    }
    // Add pairing-port group to flooding group
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    // treatment.popVlan();
    treatment.setOutput(port);
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("Pair port added/removed to vlan {} next objective {} on {}", vlanId, nextId, deviceId), (objective, error) -> log.warn("Failed adding/removing pair port to vlan {} next objective {} on {}." + "Error : {}", vlanId, nextId, deviceId, error));
    NextObjective.Builder vlanNextObjectiveBuilder = DefaultNextObjective.builder().withId(nextId).withType(NextObjective.Type.BROADCAST).fromApp(srService.appId()).withMeta(DefaultTrafficSelector.builder().matchVlanId(vlanId).build()).addTreatment(treatment.build());
    if (install) {
        flowObjectiveService.next(deviceId, vlanNextObjectiveBuilder.addToExisting(context));
    } else {
        flowObjectiveService.next(deviceId, vlanNextObjectiveBuilder.removeFromExisting(context));
    }
    log.debug("Submitted next objective {} for vlan: {} in device {}", nextId, vlanId, deviceId);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) XconnectKey(org.onosproject.segmentrouting.xconnect.api.XconnectKey) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) XconnectLoadBalancerEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectLoadBalancerEndpoint) XconnectEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint) XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint)

Example 8 with XconnectKey

use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.

the class XconnectManager method addOrUpdateXconnect.

@Override
public void addOrUpdateXconnect(DeviceId deviceId, VlanId vlanId, Set<XconnectEndpoint> endpoints) {
    log.info("Adding or updating xconnect. deviceId={}, vlanId={}, endpoints={}", deviceId, vlanId, endpoints);
    SegmentRoutingDeviceConfig config = cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
    List<PortNumber> devicePorts = deviceService.getPorts(deviceId).stream().map(Port::number).collect(Collectors.toList());
    if (!config.isEdgeRouter()) {
        throw new IllegalArgumentException(ERROR_NOT_EDGE_ROUTER);
    } else {
        Iterator<XconnectEndpoint> itr = endpoints.iterator();
        while (itr.hasNext()) {
            XconnectEndpoint ep = itr.next();
            // Note: we don't validate an endpoint with LOAD_BALANCER type
            if (ep.type() != XconnectEndpoint.Type.PORT) {
                continue;
            }
            if (!devicePorts.contains(((XconnectPortEndpoint) ep).port())) {
                throw new IllegalArgumentException(ERROR_PORT_NOT_RANGE);
            }
        }
    }
    final XconnectKey key = new XconnectKey(deviceId, vlanId);
    xconnectStore.put(key, endpoints);
}
Also used : SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) XconnectEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint) PortNumber(org.onosproject.net.PortNumber) XconnectKey(org.onosproject.segmentrouting.xconnect.api.XconnectKey)

Example 9 with XconnectKey

use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.

the class XconnectManager method dequeue.

// Invalidate the cache and re-start the xconnect installation
private void dequeue(PortLoadBalancerId portLoadBalancerId) {
    XconnectKey xconnectKey = portLoadBalancerCache.getIfPresent(portLoadBalancerId);
    if (xconnectKey == null) {
        log.trace("{} not present in the cache", portLoadBalancerId);
        return;
    }
    log.debug("Dequeue {}", portLoadBalancerId);
    portLoadBalancerCache.invalidate(portLoadBalancerId);
    Set<XconnectEndpoint> endpoints = Versioned.valueOrNull(xconnectStore.get(xconnectKey));
    if (endpoints == null || endpoints.isEmpty()) {
        log.warn("Endpoints not found for XConnect {}", xconnectKey);
        return;
    }
    populateXConnect(xconnectKey, endpoints);
    log.trace("PortLoadBalancer cache size {}", portLoadBalancerCache.size());
}
Also used : XconnectEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint) XconnectKey(org.onosproject.segmentrouting.xconnect.api.XconnectKey)

Aggregations

XconnectKey (org.onosproject.segmentrouting.xconnect.api.XconnectKey)9 ConnectPoint (org.onosproject.net.ConnectPoint)6 PortNumber (org.onosproject.net.PortNumber)6 Cache (com.google.common.cache.Cache)5 CacheBuilder (com.google.common.cache.CacheBuilder)5 RemovalNotification (com.google.common.cache.RemovalNotification)5 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 ImmutableSet (com.google.common.collect.ImmutableSet)5 Lists (com.google.common.collect.Lists)5 Sets (com.google.common.collect.Sets)5 Serializable (java.io.Serializable)5 Collections (java.util.Collections)5 Iterator (java.util.Iterator)5 List (java.util.List)5 Optional (java.util.Optional)5 Set (java.util.Set)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 ExecutorService (java.util.concurrent.ExecutorService)5 Executors (java.util.concurrent.Executors)5