Search in sources :

Example 31 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class SpringOpenTTP method isSupportedEthDstObjective.

private boolean isSupportedEthDstObjective(ForwardingObjective fwd) {
    TrafficSelector selector = fwd.selector();
    EthCriterion ethDst = (EthCriterion) selector.getCriterion(Criterion.Type.ETH_DST);
    VlanIdCriterion vlanId = (VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID);
    if (ethDst == null && vlanId == null) {
        return false;
    }
    return true;
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 32 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class AbstractCorsaPipeline method processFilter.

private void processFilter(FilteringObjective filt, boolean install, ApplicationId applicationId) {
    // This driver only processes filtering criteria defined with switch
    // ports as the key
    PortCriterion port;
    if (!filt.key().equals(Criteria.dummy()) && filt.key().type() == Criterion.Type.IN_PORT) {
        port = (PortCriterion) filt.key();
    } else {
        log.warn("No key defined in filtering objective from app: {}. Not" + "processing filtering objective", applicationId);
        fail(filt, ObjectiveError.UNKNOWN);
        return;
    }
    // convert filtering conditions for switch-intfs into flowrules
    FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
    for (Criterion c : filt.conditions()) {
        if (c.type() == Criterion.Type.ETH_DST) {
            EthCriterion eth = (EthCriterion) c;
            FlowRule.Builder rule = processEthFiler(filt, eth, port);
            rule.forDevice(deviceId).fromApp(applicationId);
            ops = install ? ops.add(rule.build()) : ops.remove(rule.build());
        } else if (c.type() == Criterion.Type.VLAN_VID) {
            VlanIdCriterion vlan = (VlanIdCriterion) c;
            FlowRule.Builder rule = processVlanFiler(filt, vlan, port);
            rule.forDevice(deviceId).fromApp(applicationId);
            ops = install ? ops.add(rule.build()) : ops.remove(rule.build());
        } else if (c.type() == Criterion.Type.IPV4_DST) {
            IPCriterion ip = (IPCriterion) c;
            FlowRule.Builder rule = processIpFilter(filt, ip, port);
            rule.forDevice(deviceId).fromApp(applicationId);
            ops = install ? ops.add(rule.build()) : ops.remove(rule.build());
        } else {
            log.warn("Driver does not currently process filtering condition" + " of type: {}", c.type());
            fail(filt, ObjectiveError.UNSUPPORTED);
        }
    }
    // apply filtering flow rules
    flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {

        @Override
        public void onSuccess(FlowRuleOperations ops) {
            pass(filt);
            log.info("Applied filtering rules");
        }

        @Override
        public void onError(FlowRuleOperations ops) {
            fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
            log.info("Failed to apply filtering rules");
        }
    }));
}
Also used : FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) Builder(org.onosproject.net.flow.FlowRule.Builder) Builder(org.onosproject.net.flow.FlowRule.Builder) CacheBuilder(com.google.common.cache.CacheBuilder) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 33 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class AbstractCorsaPipeline method processSpecific.

private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
    log.debug("Processing specific forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethTypeCriterion = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID);
    if (ethTypeCriterion != null) {
        short et = ethTypeCriterion.ethType().toShort();
        if (et == Ethernet.TYPE_IPV4) {
            return processSpecificRoute(fwd);
        } else if (et == Ethernet.TYPE_VLAN) {
            /* The ForwardingObjective must specify VLAN ethtype in order to use the Transit Circuit */
            return processSpecificSwitch(fwd);
        }
    } else if (vlanIdCriterion != null) {
        return processSpecificSwitch(fwd);
    }
    fail(fwd, ObjectiveError.UNSUPPORTED);
    return ImmutableSet.of();
}
Also used : EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 34 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class CorsaPipelineV3 method processSpecificSwitch.

@Override
protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) {
    TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchInPort(((PortCriterion) fwd.selector().getCriterion(Criterion.Type.IN_PORT)).port()).matchVlanId(((VlanIdCriterion) fwd.selector().getCriterion(Criterion.Type.VLAN_VID)).vlanId()).build();
    Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).forTable(VLAN_CIRCUIT_TABLE);
    if (fwd.treatment() != null) {
        ruleBuilder.withTreatment(fwd.treatment());
    } else {
        if (fwd.nextId() != null) {
            NextObjective nextObjective = pendingNext.getIfPresent(fwd.nextId());
            if (nextObjective != null) {
                pendingNext.invalidate(fwd.nextId());
                TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setVlanPcp((byte) 0).setQueue(0).meter(defaultMeterId);
                nextObjective.next().forEach(trafficTreatment -> {
                    trafficTreatment.allInstructions().forEach(instruction -> {
                        treatment.add(instruction);
                    });
                });
                ruleBuilder.withTreatment(treatment.build());
            } else {
                log.warn("The group left!");
                fwd.context().ifPresent(c -> c.onError(fwd, ObjectiveError.GROUPMISSING));
                return ImmutableSet.of();
            }
        } else {
            log.warn("Missing NextObjective ID for ForwardingObjective {}", fwd.id());
            fail(fwd, ObjectiveError.BADPARAMS);
            return ImmutableSet.of();
        }
    }
    if (fwd.permanent()) {
        ruleBuilder.makePermanent();
    } else {
        ruleBuilder.makeTemporary(fwd.timeout());
    }
    return Collections.singletonList(ruleBuilder.build());
}
Also used : NextObjective(org.onosproject.net.flowobjective.NextObjective) Builder(org.onosproject.net.flow.FlowRule.Builder) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 35 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class FilteringObjectiveTranslator method doTranslate.

@Override
public ObjectiveTranslation doTranslate(FilteringObjective obj) throws FabricPipelinerException {
    final ObjectiveTranslation.Builder resultBuilder = ObjectiveTranslation.builder();
    if (obj.key() == null || obj.key().type() != Criterion.Type.IN_PORT) {
        throw new FabricPipelinerException(format("Unsupported or missing filtering key: key=%s", obj.key()), ObjectiveError.BADPARAMS);
    }
    if (!isValidSrMetadata(obj)) {
        throw new FabricPipelinerException(format("Unsupported metadata configuration: metadata=%s", obj.meta()), ObjectiveError.BADPARAMS);
    }
    final PortCriterion inPort = (PortCriterion) obj.key();
    final VlanIdCriterion outerVlan = (VlanIdCriterion) criterion(obj.conditions(), Criterion.Type.VLAN_VID);
    final VlanIdCriterion innerVlan = (VlanIdCriterion) criterion(obj.conditions(), Criterion.Type.INNER_VLAN_VID);
    final EthCriterion ethDst = (EthCriterion) criterion(obj.conditions(), Criterion.Type.ETH_DST);
    final EthCriterion ethDstMasked = (EthCriterion) criterion(obj.conditions(), Criterion.Type.ETH_DST_MASKED);
    ingressPortVlanRule(obj, inPort, outerVlan, innerVlan, resultBuilder);
    if (shouldModifyFwdClassifierTable(obj)) {
        fwdClassifierRules(obj, inPort, ethDst, ethDstMasked, resultBuilder);
    } else {
        log.debug("Skipping fwd classifier rules for device {}.", deviceId);
    }
    return resultBuilder.build();
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Aggregations

VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)65 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)48 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)45 FlowRule (org.onosproject.net.flow.FlowRule)41 VlanId (org.onlab.packet.VlanId)37 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)35 List (java.util.List)32 DeviceId (org.onosproject.net.DeviceId)30 TrafficSelector (org.onosproject.net.flow.TrafficSelector)30 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)30 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)28 Collection (java.util.Collection)27 Collections (java.util.Collections)27 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)27 Collectors (java.util.stream.Collectors)26 Criterion (org.onosproject.net.flow.criteria.Criterion)26 Test (org.junit.Test)25 ImmutableSet (com.google.common.collect.ImmutableSet)24 CoreService (org.onosproject.core.CoreService)24 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)24