Search in sources :

Example 56 with Objective

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

the class XconnectManager method populateL2Multicast.

/**
 * Populate L2 multicast rule on given deviceId that matches given mac, given vlan and
 * output to given port's L2 mulitcast group.
 *
 * @param deviceId    Device ID
 * @param pairPort    Pair port number
 * @param vlanId      VLAN ID
 * @param accessPorts List of access ports to be added into L2 multicast group
 */
private void populateL2Multicast(DeviceId deviceId, PortNumber pairPort, VlanId vlanId, List<PortNumber> accessPorts) {
    // Ensure enough rights to program pair device
    if (!srService.shouldProgram(deviceId)) {
        log.debug("Abort populate L2Multicast {}-{}: {}", deviceId, vlanId, ERROR_NOT_LEADER);
        return;
    }
    boolean multicastGroupExists = true;
    int vlanMulticastNextId;
    VlanNextObjectiveStoreKey key = new VlanNextObjectiveStoreKey(deviceId, vlanId);
    // Step 1 : Populate single homed access ports into vlan's L2 multicast group
    NextObjective.Builder vlanMulticastNextObjBuilder = DefaultNextObjective.builder().withType(NextObjective.Type.BROADCAST).fromApp(srService.appId()).withMeta(DefaultTrafficSelector.builder().matchVlanId(vlanId).matchEthDst(MacAddress.IPV4_MULTICAST).build());
    vlanMulticastNextId = getMulticastGroupNextObjectiveId(key);
    if (vlanMulticastNextId == -1) {
        // Vlan's L2 multicast group doesn't exist; create it, update store and add pair port as sub-group
        multicastGroupExists = false;
        vlanMulticastNextId = flowObjectiveService.allocateNextId();
        addMulticastGroupNextObjectiveId(key, vlanMulticastNextId);
        vlanMulticastNextObjBuilder.addTreatment(DefaultTrafficTreatment.builder().setOutput(pairPort).build());
    }
    vlanMulticastNextObjBuilder.withId(vlanMulticastNextId);
    int nextId = vlanMulticastNextId;
    accessPorts.forEach(p -> {
        TrafficTreatment.Builder egressAction = DefaultTrafficTreatment.builder();
        // Do vlan popup action based on interface configuration
        if (interfaceService.getInterfacesByPort(new ConnectPoint(deviceId, p)).stream().noneMatch(i -> i.vlanTagged().contains(vlanId))) {
            egressAction.popVlan();
        }
        egressAction.setOutput(p);
        vlanMulticastNextObjBuilder.addTreatment(egressAction.build());
        addMulticastGroupPort(key, p);
    });
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("L2 multicast group installed/updated. " + "NextObject Id {} on {} for subnet {} ", nextId, deviceId, vlanId), (objective, error) -> log.warn("L2 multicast group failed to install/update. " + " NextObject Id {} on {} for subnet {} : {}", nextId, deviceId, vlanId, error));
    if (!multicastGroupExists) {
        flowObjectiveService.next(deviceId, vlanMulticastNextObjBuilder.add(context));
        // Step 2 : Populate ACL rule; selector = vlan + pair-port, output = vlan L2 multicast group
        TrafficSelector.Builder multicastSelector = DefaultTrafficSelector.builder();
        multicastSelector.matchEthType(Ethernet.TYPE_VLAN);
        multicastSelector.matchInPort(pairPort);
        multicastSelector.matchVlanId(vlanId);
        ForwardingObjective.Builder vlanMulticastForwardingObj = DefaultForwardingObjective.builder().withFlag(ForwardingObjective.Flag.VERSATILE).nextStep(vlanMulticastNextId).withSelector(multicastSelector.build()).withPriority(100).fromApp(srService.appId()).makePermanent();
        context = new DefaultObjectiveContext((objective) -> log.debug("L2 multicasting versatile rule for device {}, port/vlan {}/{} populated", deviceId, pairPort, vlanId), (objective, error) -> log.warn("Failed to populate L2 multicasting versatile rule for device {}, " + "ports/vlan {}/{}: {}", deviceId, pairPort, vlanId, error));
        flowObjectiveService.forward(deviceId, vlanMulticastForwardingObj.add(context));
    } else {
        // L2_MULTICAST & BROADCAST are similar structure in subgroups; so going with BROADCAST type.
        vlanMulticastNextObjBuilder.withType(NextObjective.Type.BROADCAST);
        flowObjectiveService.next(deviceId, vlanMulticastNextObjBuilder.addToExisting(context));
    }
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) 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) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) 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) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 57 with Objective

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

the class XconnectManager method cleanupL2MulticastRule.

/**
 * Cleans up VLAN L2 multicast group on given deviceId. ACL rules for the group will also be deleted.
 * Normally multicast group is not removed if it contains access ports; which can be forced
 * by "force" flag
 *
 * @param deviceId Device ID
 * @param pairPort Pair port number
 * @param vlanId   VLAN ID
 * @param force    Forceful removal
 */
private void cleanupL2MulticastRule(DeviceId deviceId, PortNumber pairPort, VlanId vlanId, boolean force) {
    // Ensure enough rights to program pair device
    if (!srService.shouldProgram(deviceId)) {
        log.debug("Abort cleanup L2Multicast {}-{}: {}", deviceId, vlanId, ERROR_NOT_LEADER);
        return;
    }
    VlanNextObjectiveStoreKey key = new VlanNextObjectiveStoreKey(deviceId, vlanId);
    // Ensure L2 multicast group doesn't contain access ports
    if (hasAccessPortInMulticastGroup(key, pairPort) && !force) {
        return;
    }
    // Load L2 multicast group details
    int vlanMulticastNextId = getMulticastGroupNextObjectiveId(key);
    if (vlanMulticastNextId == -1) {
        return;
    }
    // Step 1 : Clear ACL rule; selector = vlan + pair-port, output = vlan L2 multicast group
    TrafficSelector.Builder l2MulticastSelector = DefaultTrafficSelector.builder();
    l2MulticastSelector.matchEthType(Ethernet.TYPE_VLAN);
    l2MulticastSelector.matchInPort(pairPort);
    l2MulticastSelector.matchVlanId(vlanId);
    ForwardingObjective.Builder vlanMulticastForwardingObj = DefaultForwardingObjective.builder().withFlag(ForwardingObjective.Flag.VERSATILE).nextStep(vlanMulticastNextId).withSelector(l2MulticastSelector.build()).withPriority(100).fromApp(srService.appId()).makePermanent();
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("L2 multicasting rule for device {}, port/vlan {}/{} deleted", deviceId, pairPort, vlanId), (objective, error) -> log.warn("Failed to delete L2 multicasting rule for device {}, " + "ports/vlan {}/{}: {}", deviceId, pairPort, vlanId, error));
    flowObjectiveService.forward(deviceId, vlanMulticastForwardingObj.remove(context));
    // Step 2 : Clear L2 multicast group associated with vlan
    NextObjective.Builder l2MulticastGroupBuilder = DefaultNextObjective.builder().withId(vlanMulticastNextId).withType(NextObjective.Type.BROADCAST).fromApp(srService.appId()).withMeta(DefaultTrafficSelector.builder().matchVlanId(vlanId).matchEthDst(MacAddress.IPV4_MULTICAST).build()).addTreatment(DefaultTrafficTreatment.builder().popVlan().setOutput(pairPort).build());
    context = new DefaultObjectiveContext((objective) -> log.debug("L2 multicast group with NextObject Id {} deleted on {} for subnet {} ", vlanMulticastNextId, deviceId, vlanId), (objective, error) -> log.warn("L2 multicast group with NextObject Id {} failed to delete on {} for subnet {} : {}", vlanMulticastNextId, deviceId, vlanId, error));
    flowObjectiveService.next(deviceId, l2MulticastGroupBuilder.remove(context));
    // Finally clear store.
    removeMulticastGroup(key);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) 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) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) 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 58 with Objective

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

the class XconnectManager method revokeFwd.

/**
 * Revokes bridging forwarding objectives for given XConnect.
 *
 * @param key       XConnect store key
 * @param nextId    next objective id
 * @param fwdFuture completable future for this forwarding objective operation
 */
private void revokeFwd(XconnectKey key, int nextId, CompletableFuture<ObjectiveError> fwdFuture) {
    ForwardingObjective.Builder fwdObjBuilder = fwdObjBuilder(key, nextId);
    ObjectiveContext context = new ObjectiveContext() {

        @Override
        public void onSuccess(Objective objective) {
            log.debug("Previous FwdObj for {} removed", key);
            if (fwdFuture != null) {
                fwdFuture.complete(null);
            }
        }

        @Override
        public void onError(Objective objective, ObjectiveError error) {
            log.warn("Failed to remove previous FwdObj for {}: {}", key, error);
            if (fwdFuture != null) {
                fwdFuture.complete(error);
            }
        }
    };
    flowObjectiveService.forward(key.deviceId(), fwdObjBuilder.remove(context));
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError)

Example 59 with Objective

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

the class RoutingRulePopulator method processSinglePortFiltersInternal.

private boolean processSinglePortFiltersInternal(DeviceId deviceId, PortNumber portnum, boolean pushVlan, VlanId vlanId, boolean install, boolean update) {
    boolean doTMAC = true;
    if (!pushVlan) {
        // Skip the tagged vlans belonging to an interface without an IP address
        Set<Interface> ifaces = srManager.interfaceService.getInterfacesByPort(new ConnectPoint(deviceId, portnum)).stream().filter(intf -> intf.vlanTagged().contains(vlanId) && intf.ipAddressesList().isEmpty()).collect(Collectors.toSet());
        if (!ifaces.isEmpty()) {
            log.debug("processSinglePortFiltersInternal: skipping TMAC for vlan {} at {}/{} - no IP", vlanId, deviceId, portnum);
            doTMAC = false;
        }
    }
    FilteringObjective.Builder fob = buildFilteringObjective(deviceId, portnum, pushVlan, vlanId, doTMAC, update);
    if (fob == null) {
        // error encountered during build
        return false;
    }
    log.debug("{} filtering objectives for dev/port: {}/{}", install ? "Installing" : "Removing", deviceId, portnum);
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("Filter for {}/{} {}", deviceId, portnum, install ? "installed" : "removed"), (objective, error) -> log.warn("Failed to {} filter for {}/{}: {}", install ? "install" : "remove", deviceId, portnum, error));
    if (install) {
        srManager.flowObjectiveService.filter(deviceId, fob.add(context));
    } else {
        srManager.flowObjectiveService.filter(deviceId, fob.remove(context));
    }
    return true;
}
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) 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) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface)

Example 60 with Objective

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

the class RoutingRulePopulator method processSinglePortFilters.

/**
 * Creates or removes filtering objectives for a single port. Should only be
 * called by the master for a switch.
 *
 * @param deviceId device identifier
 * @param portnum  port identifier for port to be filtered
 * @param install true to install the filtering objective, false to remove
 * @return true if no errors occurred during the build of the filtering objective
 */
boolean processSinglePortFilters(DeviceId deviceId, PortNumber portnum, boolean install) {
    ConnectPoint connectPoint = new ConnectPoint(deviceId, portnum);
    VlanId untaggedVlan = srManager.interfaceService.getUntaggedVlanId(connectPoint);
    Set<VlanId> taggedVlans = srManager.interfaceService.getTaggedVlanId(connectPoint);
    VlanId nativeVlan = srManager.interfaceService.getNativeVlanId(connectPoint);
    // Do not configure filter for edge ports where double-tagged hosts are connected.
    if (taggedVlans.size() != 0) {
        // Filter for tagged vlans
        if (!srManager.interfaceService.getTaggedVlanId(connectPoint).stream().allMatch(taggedVlanId -> processSinglePortFiltersInternal(deviceId, portnum, false, taggedVlanId, install, false))) {
            return false;
        }
        if (nativeVlan != null) {
            // Filter for native vlan
            if (!processSinglePortFiltersInternal(deviceId, portnum, true, nativeVlan, install, false)) {
                return false;
            }
        }
    } else if (untaggedVlan != null) {
        // Filter for untagged vlan
        if (!processSinglePortFiltersInternal(deviceId, portnum, true, untaggedVlan, install, false)) {
            return false;
        }
    } else if (!hasIPConfiguration(connectPoint)) {
        // Filter for unconfigured upstream port, using INTERNAL_VLAN
        if (!processSinglePortFiltersInternal(deviceId, portnum, true, srManager.getDefaultInternalVlan(), install, false)) {
            return false;
        }
        // Filter for receiveing pseudowire traffic
        if (!processSinglePortFiltersInternal(deviceId, portnum, false, srManager.getPwTransportVlan(), install, false)) {
            return false;
        }
    }
    return true;
}
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) ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId)

Aggregations

Objective (org.onosproject.net.flowobjective.Objective)64 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)58 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)42 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)42 NextObjective (org.onosproject.net.flowobjective.NextObjective)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)38 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)37 TrafficSelector (org.onosproject.net.flow.TrafficSelector)37 ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)36 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)34 DeviceId (org.onosproject.net.DeviceId)32 DefaultFilteringObjective (org.onosproject.net.flowobjective.DefaultFilteringObjective)29 ConnectPoint (org.onosproject.net.ConnectPoint)27 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)27 List (java.util.List)26 ObjectiveError (org.onosproject.net.flowobjective.ObjectiveError)26 Set (java.util.Set)25 Lists (com.google.common.collect.Lists)24 CompletableFuture (java.util.concurrent.CompletableFuture)24 Collectors (java.util.stream.Collectors)24