Search in sources :

Example 11 with EthCriterion

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

the class SoftRouterPipeline 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 p;
    EthCriterion e = null;
    VlanIdCriterion v = null;
    if (!filt.key().equals(Criteria.dummy()) && filt.key().type() == Criterion.Type.IN_PORT) {
        p = (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 || c.type() == Criterion.Type.ETH_DST_MASKED) {
            e = (EthCriterion) c;
        } else if (c.type() == Criterion.Type.VLAN_VID) {
            v = (VlanIdCriterion) c;
        } else {
            log.error("Unsupported filter {}", c);
            fail(filt, ObjectiveError.UNSUPPORTED);
            return;
        }
    }
    if (v == null || e == null) {
        log.warn("Soft Router Pipeline ETH_DST and/or VLAN_ID not specified");
        fail(filt, ObjectiveError.BADPARAMS);
        return;
    }
    log.debug("Modifying Port/VLAN/MAC filtering rules in filter table: {}/{}/{}", p.port(), v.vlanId(), e.mac());
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    selector.matchInPort(p.port());
    // Multicast MAC
    if (e.mask() != null) {
        selector.matchEthDstMasked(e.mac(), e.mask());
    } else {
        selector.matchEthDst(e.mac());
    }
    selector.matchVlanId(v.vlanId());
    if (!v.vlanId().equals(VlanId.NONE)) {
        treatment.popVlan();
    }
    treatment.transition(FIB_TABLE);
    FlowRule rule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(FILTER_TABLE).build();
    ops = install ? ops.add(rule) : ops.remove(rule);
    // apply filtering flow rules
    flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {

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

        @Override
        public void onError(FlowRuleOperations ops) {
            log.info("Failed to apply filtering rules");
            fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
        }
    }));
}
Also used : FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) 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) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 12 with EthCriterion

use of org.onosproject.net.flow.criteria.EthCriterion 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 13 with EthCriterion

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

the class KubevirtPrometheusAssuranceManager method isSnatUpstreamFlorEntryForRouter.

private boolean isSnatUpstreamFlorEntryForRouter(KubevirtRouter router, FlowEntry flowEntry) {
    TrafficSelector selector = flowEntry.selector();
    EthCriterion ethCriterion = (EthCriterion) selector.getCriterion(ETH_DST);
    if (ethCriterion == null) {
        return false;
    }
    MacAddress macAddress = ethCriterion.mac();
    if (router.mac().equals(macAddress)) {
        return true;
    }
    return false;
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) MacAddress(org.onlab.packet.MacAddress)

Example 14 with EthCriterion

use of org.onosproject.net.flow.criteria.EthCriterion 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 15 with EthCriterion

use of org.onosproject.net.flow.criteria.EthCriterion 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

EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)33 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)24 Criterion (org.onosproject.net.flow.criteria.Criterion)18 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 FlowRule (org.onosproject.net.flow.FlowRule)14 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)14 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)13 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)13 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)12 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)11 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)10 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)9 FlowRuleOperations (org.onosproject.net.flow.FlowRuleOperations)9 FlowRuleOperationsContext (org.onosproject.net.flow.FlowRuleOperationsContext)9 ArrayList (java.util.ArrayList)8 MacAddress (org.onlab.packet.MacAddress)8 Instruction (org.onosproject.net.flow.instructions.Instruction)7 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)7 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)6 ImmutableList (com.google.common.collect.ImmutableList)4