Search in sources :

Example 1 with EthTypeCriterion

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

the class TsLoopPacket method copyPacketMatch.

/**
 * Creates and returns a new packet instance with the copied match fields.
 *
 * With hard-copied match fields, references to path flows and path links.
 *
 * @return new loop packet instance with the copied match fields
 */
public TsLoopPacket copyPacketMatch() {
    TsLoopPacket newOne = new TsLoopPacket();
    newOne.pathFlow = this.pathFlow;
    newOne.pathLink = this.pathLink;
    Map<Criterion.Type, Criterion> m = newOne.match;
    for (Map.Entry<Criterion.Type, Criterion> entry : this.match.entrySet()) {
        Criterion.Type k = entry.getKey();
        Criterion v = entry.getValue();
        switch(k) {
            case IN_PORT:
                m.put(k, matchInPort(((PortCriterion) v).port()));
                break;
            case // At present, not support Ethernet mask (ONOS?)
            ETH_SRC:
                m.put(k, matchEthSrc(((EthCriterion) v).mac()));
                break;
            case // At present, not support Ethernet mask (ONOS?)
            ETH_DST:
                m.put(k, matchEthDst(((EthCriterion) v).mac()));
                break;
            case ETH_TYPE:
                m.put(k, matchEthType(((EthTypeCriterion) v).ethType()));
                break;
            case // At present, not support VLAN mask (ONOS?)
            VLAN_VID:
                m.put(k, matchVlanId(((VlanIdCriterion) v).vlanId()));
                break;
            case VLAN_PCP:
                m.put(k, matchVlanPcp(((VlanPcpCriterion) v).priority()));
                break;
            case IPV4_SRC:
                m.put(k, matchIPSrc(((IPCriterion) v).ip()));
                break;
            case IPV4_DST:
                m.put(k, matchIPDst(((IPCriterion) v).ip()));
                break;
            case IP_PROTO:
                m.put(k, matchIPProtocol(((IPProtocolCriterion) v).protocol()));
                break;
            case // can't be supported by now
            IP_DSCP:
                m.put(k, matchIPDscp(((IPDscpCriterion) v).ipDscp()));
                break;
            case // can't be supported by now
            IP_ECN:
                m.put(k, matchIPEcn(((IPEcnCriterion) v).ipEcn()));
                break;
            case TCP_SRC:
                m.put(k, matchTcpSrc(((TcpPortCriterion) v).tcpPort()));
                break;
            case TCP_DST:
                m.put(k, matchTcpDst(((TcpPortCriterion) v).tcpPort()));
                break;
            case UDP_SRC:
                m.put(k, matchUdpSrc(((UdpPortCriterion) v).udpPort()));
                break;
            case UDP_DST:
                m.put(k, matchUdpDst(((UdpPortCriterion) v).udpPort()));
                break;
            default:
                // can't be supported by OF1.0
                log.debug("{} can't be supported by OF1.0", k);
                break;
        }
    }
    return newOne;
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) HashMap(java.util.HashMap) Map(java.util.Map) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 2 with EthTypeCriterion

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

the class DefaultCheckLoop method matchAndAddFlowEntry.

private boolean matchAndAddFlowEntry(FlowEntry flowEntry, TsLoopPacket pkt, TsReturn<Boolean> isBigger) {
    isBigger.setValue(false);
    List<Criterion> criterionArray = sortCriteria(flowEntry.selector().criteria());
    for (Criterion criterion : criterionArray) {
        // TODO - advance
        switch(criterion.type()) {
            case IN_PORT:
            case ETH_SRC:
            // At present, not support Ethernet mask (ONOS?)
            case ETH_DST:
            // At present, not support Ethernet mask (ONOS?)
            case ETH_TYPE:
                if (!matchAddExactly(pkt, criterion, isBigger)) {
                    return false;
                }
                break;
            case VLAN_VID:
            // At present, not support VLAN mask (ONOS?)
            case VLAN_PCP:
                if (!pkt.headerExists(ETH_TYPE) || !((EthTypeCriterion) pkt.getHeader(ETH_TYPE)).ethType().equals(VLAN.ethType())) {
                    return false;
                }
                if (!matchAddExactly(pkt, criterion, isBigger)) {
                    return false;
                }
                break;
            case IPV4_SRC:
            case IPV4_DST:
                if (!pkt.headerExists(ETH_TYPE) || !((EthTypeCriterion) pkt.getHeader(ETH_TYPE)).ethType().equals(IPV4.ethType())) {
                    return false;
                }
                if (!matchAddIPV4(pkt, criterion, isBigger)) {
                    return false;
                }
                break;
            case IP_PROTO:
                if (!pkt.headerExists(ETH_TYPE) || !((EthTypeCriterion) pkt.getHeader(ETH_TYPE)).ethType().equals(IPV4.ethType())) {
                    return false;
                }
                if (!matchAddExactly(pkt, criterion, isBigger)) {
                    return false;
                }
                break;
            case IP_DSCP:
                // TODO: 10/28/16 support IP_DSCP match field
                break;
            case IP_ECN:
                // TODO: 10/28/16 support IP_DSCP match field
                break;
            case TCP_SRC:
            case TCP_DST:
                if (!pkt.headerExists(IP_PROTO) || IP_PROTO_TCP_TS != ((IPProtocolCriterion) pkt.getHeader(IP_PROTO)).protocol()) {
                    // has TCP match requirement, but can't afford TCP
                    return false;
                }
                // avoid IP_PROTO locates after TCP_*
                if (!matchAddExactly(pkt, criterion, isBigger)) {
                    return false;
                }
                break;
            case UDP_SRC:
            case UDP_DST:
                if (!pkt.headerExists(IP_PROTO) || IP_PROTO_UDP_TS != ((IPProtocolCriterion) pkt.getHeader(IP_PROTO)).protocol()) {
                    // has UDP match requirement, but can't afford UDP
                    return false;
                }
                // avoid IP_PROTO locates after UDP_*
                if (!matchAddExactly(pkt, criterion, isBigger)) {
                    return false;
                }
                break;
            default:
                log.debug("{} can't be supported by OF1.0", criterion.type());
                return false;
        }
    }
    return true;
}
Also used : IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion)

Example 3 with EthTypeCriterion

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

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

the class CentecV350Pipeline method processSpecific.

private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
    log.debug("Processing specific forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
        fail(fwd, ObjectiveError.UNSUPPORTED);
        return Collections.emptySet();
    }
    // Must have metadata as key.
    TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchMetadata(DEFAULT_METADATA).matchIPDst(((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip()).build();
    TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
    if (fwd.nextId() != null) {
        NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
        GroupKey key = appKryo.deserialize(next.data());
        Group group = groupService.getGroup(deviceId, key);
        if (group == null) {
            log.warn("The group left!");
            fail(fwd, ObjectiveError.GROUPMISSING);
            return Collections.emptySet();
        }
        tb.group(group.id());
    }
    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(ROUTE_TABLE_PRIORITY).forDevice(deviceId).withSelector(filteredSelector).withTreatment(tb.build());
    if (fwd.permanent()) {
        ruleBuilder.makePermanent();
    } else {
        ruleBuilder.makeTemporary(fwd.timeout());
    }
    ruleBuilder.forTable(ROUTE_TABLE);
    return Collections.singletonList(ruleBuilder.build());
}
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) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) 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 5 with EthTypeCriterion

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

the class CiscoN9kPipeliner method forward.

@Override
public void forward(ForwardingObjective forwardObjective) {
    ForwardingObjective newFwd = forwardObjective;
    Device device = deviceService.getDevice(deviceId);
    if (forwardObjective.treatment() != null && forwardObjective.treatment().clearedDeferred()) {
        log.warn("Using 'clear actions' instruction which is not supported by {} {} {} Switch" + " removing the clear deferred from the forwarding objective", device.id(), device.manufacturer(), device.hwVersion());
        newFwd = forwardingObjectiveWithoutCleardDef(forwardObjective).orElse(forwardObjective);
    }
    EthTypeCriterion ethType = (EthTypeCriterion) newFwd.selector().getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType != null && ethType.ethType() == EthType.EtherType.IPV6.ethType()) {
        log.error("IPv6 type not supported for {} {} {} Switch, " + "The FlowRule associated with IPv6 is dropped.", device.id(), device.manufacturer(), device.hwVersion());
        return;
    }
    super.forward(newFwd);
}
Also used : Device(org.onosproject.net.Device) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective)

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