Search in sources :

Example 26 with EthTypeCriterion

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

the class Ofdpa2Pipeline method isSupportedEthTypeObjective.

// ////////////////////////////////////
// Helper Methods and Classes
// ////////////////////////////////////
private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) {
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    return !((ethType == null) || ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) && (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST)) && (ethType.ethType().toShort() != Ethernet.TYPE_IPV6));
}
Also used : EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 27 with EthTypeCriterion

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

the class OvsOfdpaPipeline method processDoubleTaggedFwd.

/**
 * Handles forwarding rules to the IP Unicast Routing.
 *
 * @param fwd the forwarding objective
 * @return A collection of flow rules, or an empty set
 */
protected Collection<FlowRule> processDoubleTaggedFwd(ForwardingObjective fwd) {
    // inner for UNICAST_ROUTING_TABLE_1, outer for UNICAST_ROUTING_TABLE
    TrafficSelector selector = fwd.selector();
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
        sBuilder.matchEthType(Ethernet.TYPE_IPV4);
        sBuilder.matchVlanId(VlanId.ANY);
        IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
        if (!ipv4Dst.isMulticast() && ipv4Dst.prefixLength() == 32) {
            sBuilder.matchIPDst(ipv4Dst);
            if (fwd.nextId() != null) {
                NextGroup next = getGroupForNextObjective(fwd.nextId());
                if (next != null) {
                    List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
                    // we only need the top level group's key to point the flow to it
                    Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
                    if (group == null) {
                        log.warn("Group with key:{} for next-id:{} not found in dev:{}", gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
                        fail(fwd, ObjectiveError.GROUPMISSING);
                        return Collections.emptySet();
                    }
                    outerTtb.immediate().setVlanId(extractDummyVlanIdFromGroupId(group.id().id()));
                    // ACTSET_OUTPUT in OVS will match output action in write_action() set.
                    outerTtb.deferred().setOutput(extractOutputPortFromGroupId(group.id().id()));
                    outerTtb.transition(EGRESS_VLAN_FLOW_TABLE_IN_INGRESS);
                    innerTtb.deferred().group(group.id());
                    innerTtb.transition(ACL_TABLE);
                    FlowRule.Builder innerRuleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(sBuilder.build()).withTreatment(innerTtb.build()).forTable(UNICAST_ROUTING_TABLE_1);
                    if (fwd.permanent()) {
                        innerRuleBuilder.makePermanent();
                    } else {
                        innerRuleBuilder.makeTemporary(fwd.timeout());
                    }
                    Collection<FlowRule> flowRuleCollection = new HashSet<>();
                    flowRuleCollection.add(innerRuleBuilder.build());
                    FlowRule.Builder outerRuleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(sBuilder.build()).withTreatment(outerTtb.build()).forTable(UNICAST_ROUTING_TABLE);
                    if (fwd.permanent()) {
                        outerRuleBuilder.makePermanent();
                    } else {
                        outerRuleBuilder.makeTemporary(fwd.timeout());
                    }
                    flowRuleCollection.add(innerRuleBuilder.build());
                    flowRuleCollection.add(outerRuleBuilder.build());
                    return flowRuleCollection;
                } else {
                    log.warn("Cannot find group for nextId:{} in dev:{}. Aborting fwd:{}", fwd.nextId(), deviceId, fwd.id());
                    fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
                    return Collections.emptySet();
                }
            } else {
                log.warn("NextId is not specified in fwd:{}", fwd.id());
                fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
                return Collections.emptySet();
            }
        }
    }
    return Collections.emptySet();
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) NextGroup(org.onosproject.net.behaviour.NextGroup) Group(org.onosproject.net.group.Group) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Deque(java.util.Deque) IpPrefix(org.onlab.packet.IpPrefix) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) HashSet(java.util.HashSet)

Example 28 with EthTypeCriterion

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

the class PicaPipeline method processVersatile.

private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
    log.debug("Processing versatile forwarding objective");
    TrafficSelector selector = fwd.selector();
    TrafficTreatment treatment = fwd.treatment();
    Collection<FlowRule> flowrules = new ArrayList<FlowRule>();
    // first add this rule for basic single-table operation
    // or non-ARP related multi-table operation
    FlowRule rule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector).withTreatment(treatment).withPriority(fwd.priority()).fromApp(fwd.appId()).makePermanent().forTable(ACL_TABLE).build();
    flowrules.add(rule);
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null) {
        log.warn("No ethType in versatile forwarding obj. Not processing further.");
        return flowrules;
    }
    // in multi-table scenarios
    if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
        if (filters.isEmpty()) {
            pendingVersatiles.add(fwd);
            return flowrules;
        }
        for (Filter filter : filters) {
            flowrules.addAll(processVersatilesWithFilters(filter, fwd));
        }
    }
    return flowrules;
}
Also used : EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 29 with EthTypeCriterion

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

the class SoftRouterPipeline method processSpecific.

/**
 * SoftRouter has a single specific table - the FIB Table. It emulates
 * LPM matching of dstIP by using higher priority flows for longer prefixes.
 * Flows are forwarded using flow-actions
 *
 * @param fwd The forwarding objective of type simple
 * @return A collection of flow rules meant to be delivered to the flowrule
 *         subsystem. Typically the returned collection has a single flowrule.
 *         May return empty collection in case of failures.
 */
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
    log.debug("Processing specific forwarding objective to next:{}", fwd.nextId());
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    // XXX currently supporting only the L3 unicast table
    if (ethType == null || (ethType.ethType().toShort() != TYPE_IPV4 && ethType.ethType().toShort() != Ethernet.TYPE_IPV6)) {
        fail(fwd, ObjectiveError.UNSUPPORTED);
        return Collections.emptySet();
    }
    // We build the selector according the eth type.
    IpPrefix ipPrefix;
    TrafficSelector.Builder filteredSelector;
    if (ethType.ethType().toShort() == TYPE_IPV4) {
        ipPrefix = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
        filteredSelector = DefaultTrafficSelector.builder().matchEthType(TYPE_IPV4);
    } else {
        ipPrefix = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip();
        filteredSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV6);
    }
    // If the prefix is different from the default via.
    if (ipPrefix.prefixLength() != 0) {
        if (ethType.ethType().toShort() == TYPE_IPV4) {
            filteredSelector.matchIPDst(ipPrefix);
        } else {
            filteredSelector.matchIPv6Dst(ipPrefix);
        }
    }
    TrafficTreatment tt = null;
    if (fwd.nextId() != null) {
        NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
        if (next == null) {
            log.error("next-id {} does not exist in store", fwd.nextId());
            return Collections.emptySet();
        }
        tt = appKryo.deserialize(next.data());
        if (tt == null) {
            log.error("Error in deserializing next-id {}", fwd.nextId());
            return Collections.emptySet();
        }
    }
    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector.build());
    if (tt != null) {
        ruleBuilder.withTreatment(tt);
    }
    if (fwd.permanent()) {
        ruleBuilder.makePermanent();
    } else {
        ruleBuilder.makeTemporary(fwd.timeout());
    }
    ruleBuilder.forTable(FIB_TABLE);
    return Collections.singletonList(ruleBuilder.build());
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) NextGroup(org.onosproject.net.behaviour.NextGroup) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 30 with EthTypeCriterion

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

the class AbstractCorsaPipeline method processVersatile.

private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
    log.debug("Processing vesatile forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null) {
        log.error("Versatile forwarding objective must include ethType");
        fail(fwd, ObjectiveError.UNKNOWN);
        return ImmutableSet.of();
    }
    Builder rule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(fwd.selector()).withTreatment(fwd.treatment()).withPriority(fwd.priority()).fromApp(fwd.appId()).makePermanent();
    if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
        return processArpTraffic(fwd, rule);
    } else if (ethType.ethType().toShort() == Ethernet.TYPE_LLDP || ethType.ethType().toShort() == Ethernet.TYPE_BSN) {
        return processLinkDiscovery(fwd, rule);
    } else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
        return processIpTraffic(fwd, rule);
    }
    log.warn("Driver does not support given versatile forwarding objective");
    fail(fwd, ObjectiveError.UNSUPPORTED);
    return ImmutableSet.of();
}
Also used : EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) Builder(org.onosproject.net.flow.FlowRule.Builder) CacheBuilder(com.google.common.cache.CacheBuilder) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Aggregations

EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)30 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)20 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)18 TrafficSelector (org.onosproject.net.flow.TrafficSelector)18 FlowRule (org.onosproject.net.flow.FlowRule)16 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)14 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)14 Criterion (org.onosproject.net.flow.criteria.Criterion)13 Instruction (org.onosproject.net.flow.instructions.Instruction)13 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)12 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)12 Group (org.onosproject.net.group.Group)12 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)11 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)8 Instructions (org.onosproject.net.flow.instructions.Instructions)8 L3ModificationInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction)8 ArrayList (java.util.ArrayList)7 NextGroup (org.onosproject.net.behaviour.NextGroup)7