Search in sources :

Example 21 with EthTypeCriterion

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

the class FlowRuleCodecTest method codecSimpleFlowTest.

/**
 * Checks that a simple rule decodes properly.
 *
 * @throws IOException if the resource cannot be processed
 */
@Test
public void codecSimpleFlowTest() throws IOException {
    FlowRule rule = getRule("simple-flow.json");
    checkCommonData(rule);
    assertThat(rule.selector().criteria().size(), is(1));
    Criterion criterion1 = rule.selector().criteria().iterator().next();
    assertThat(criterion1.type(), is(Criterion.Type.ETH_TYPE));
    assertThat(((EthTypeCriterion) criterion1).ethType(), is(new EthType(2054)));
    assertThat(rule.treatment().allInstructions().size(), is(1));
    Instruction instruction1 = rule.treatment().allInstructions().get(0);
    assertThat(instruction1.type(), is(Instruction.Type.OUTPUT));
    assertThat(((Instructions.OutputInstruction) instruction1).port(), is(PortNumber.CONTROLLER));
}
Also used : EthType(org.onlab.packet.EthType) 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) IcmpTypeCriterion(org.onosproject.net.flow.criteria.IcmpTypeCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) IcmpCodeCriterion(org.onosproject.net.flow.criteria.IcmpCodeCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) IPv6NDLinkLayerAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) OduSignalTypeCriterion(org.onosproject.net.flow.criteria.OduSignalTypeCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) OchSignalTypeCriterion(org.onosproject.net.flow.criteria.OchSignalTypeCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) IPv6ExthdrFlagsCriterion(org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) L4ModificationInstruction(org.onosproject.net.flow.instructions.L4ModificationInstruction) L0ModificationInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) Test(org.junit.Test)

Example 22 with EthTypeCriterion

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

the class FlowRuleCodecTest method codecCriteriaFlowTest.

/**
 * Checks that a rule with one of each kind of criterion decodes properly.
 *
 * @throws IOException if the resource cannot be processed
 */
@Test
public void codecCriteriaFlowTest() throws Exception {
    FlowRule rule = getRule("criteria-flow.json");
    checkCommonData(rule);
    assertThat(rule.selector().criteria().size(), is(35));
    rule.selector().criteria().forEach(criterion -> criteria.put(criterion.type().name(), criterion));
    Criterion criterion;
    criterion = getCriterion(Criterion.Type.ETH_TYPE);
    assertThat(((EthTypeCriterion) criterion).ethType(), is(new EthType(2054)));
    criterion = getCriterion(Criterion.Type.ETH_DST);
    assertThat(((EthCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:55")));
    criterion = getCriterion(Criterion.Type.ETH_SRC);
    assertThat(((EthCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:55")));
    criterion = getCriterion(Criterion.Type.IN_PORT);
    assertThat(((PortCriterion) criterion).port(), is(PortNumber.portNumber(23)));
    criterion = getCriterion(Criterion.Type.IN_PHY_PORT);
    assertThat(((PortCriterion) criterion).port(), is(PortNumber.portNumber(44)));
    criterion = getCriterion(Criterion.Type.VLAN_VID);
    assertThat(((VlanIdCriterion) criterion).vlanId(), is(VlanId.vlanId((short) 777)));
    criterion = getCriterion(Criterion.Type.VLAN_PCP);
    assertThat(((VlanPcpCriterion) criterion).priority(), is(((byte) 3)));
    criterion = getCriterion(Criterion.Type.IP_DSCP);
    assertThat(((IPDscpCriterion) criterion).ipDscp(), is(((byte) 2)));
    criterion = getCriterion(Criterion.Type.IP_ECN);
    assertThat(((IPEcnCriterion) criterion).ipEcn(), is(((byte) 1)));
    criterion = getCriterion(Criterion.Type.IP_PROTO);
    assertThat(((IPProtocolCriterion) criterion).protocol(), is(((short) 4)));
    criterion = getCriterion(Criterion.Type.IPV4_SRC);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("1.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.IPV4_DST);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("2.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.IPV6_SRC);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("3.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.IPV6_DST);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("4.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.TCP_SRC);
    assertThat(((TcpPortCriterion) criterion).tcpPort().toInt(), is(80));
    criterion = getCriterion(Criterion.Type.TCP_DST);
    assertThat(((TcpPortCriterion) criterion).tcpPort().toInt(), is(443));
    criterion = getCriterion(Criterion.Type.UDP_SRC);
    assertThat(((UdpPortCriterion) criterion).udpPort().toInt(), is(180));
    criterion = getCriterion(Criterion.Type.UDP_DST);
    assertThat(((UdpPortCriterion) criterion).udpPort().toInt(), is(1443));
    criterion = getCriterion(Criterion.Type.SCTP_SRC);
    assertThat(((SctpPortCriterion) criterion).sctpPort().toInt(), is(280));
    criterion = getCriterion(Criterion.Type.SCTP_DST);
    assertThat(((SctpPortCriterion) criterion).sctpPort().toInt(), is(2443));
    criterion = getCriterion(Criterion.Type.ICMPV4_TYPE);
    assertThat(((IcmpTypeCriterion) criterion).icmpType(), is((short) 24));
    criterion = getCriterion(Criterion.Type.ICMPV4_CODE);
    assertThat(((IcmpCodeCriterion) criterion).icmpCode(), is((short) 16));
    criterion = getCriterion(Criterion.Type.ICMPV6_TYPE);
    assertThat(((Icmpv6TypeCriterion) criterion).icmpv6Type(), is((short) 14));
    criterion = getCriterion(Criterion.Type.ICMPV6_CODE);
    assertThat(((Icmpv6CodeCriterion) criterion).icmpv6Code(), is((short) 6));
    criterion = getCriterion(Criterion.Type.IPV6_FLABEL);
    assertThat(((IPv6FlowLabelCriterion) criterion).flowLabel(), is(8));
    criterion = getCriterion(Criterion.Type.IPV6_ND_TARGET);
    assertThat(((IPv6NDTargetAddressCriterion) criterion).targetAddress().toString(), is("1111:2222:3333:4444:5555:6666:7777:8888"));
    criterion = getCriterion(Criterion.Type.IPV6_ND_SLL);
    assertThat(((IPv6NDLinkLayerAddressCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:56")));
    criterion = getCriterion(Criterion.Type.IPV6_ND_TLL);
    assertThat(((IPv6NDLinkLayerAddressCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:57")));
    criterion = getCriterion(Criterion.Type.MPLS_LABEL);
    assertThat(((MplsCriterion) criterion).label(), is(MplsLabel.mplsLabel(123)));
    criterion = getCriterion(Criterion.Type.IPV6_EXTHDR);
    assertThat(((IPv6ExthdrFlagsCriterion) criterion).exthdrFlags(), is(99));
    criterion = getCriterion(Criterion.Type.TUNNEL_ID);
    assertThat(((TunnelIdCriterion) criterion).tunnelId(), is(100L));
    criterion = getCriterion(Criterion.Type.OCH_SIGTYPE);
    assertThat(((OchSignalTypeCriterion) criterion).signalType(), is(OchSignalType.FIXED_GRID));
    criterion = getCriterion(Criterion.Type.ODU_SIGTYPE);
    assertThat(((OduSignalTypeCriterion) criterion).signalType(), is(OduSignalType.ODU4));
    criterion = getCriterion(Criterion.Type.ODU_SIGID);
    assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributaryPortNumber(), is(1));
    assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributarySlotLength(), is(80));
    assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributarySlotBitmap(), is(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }));
}
Also used : EthType(org.onlab.packet.EthType) 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) IcmpTypeCriterion(org.onosproject.net.flow.criteria.IcmpTypeCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) IcmpCodeCriterion(org.onosproject.net.flow.criteria.IcmpCodeCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) IPv6NDLinkLayerAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) OduSignalTypeCriterion(org.onosproject.net.flow.criteria.OduSignalTypeCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) OchSignalTypeCriterion(org.onosproject.net.flow.criteria.OchSignalTypeCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) IPv6ExthdrFlagsCriterion(org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) Test(org.junit.Test)

Example 23 with EthTypeCriterion

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

the class OfdpaPipelineTraceable method translateInstruction.

// Applies an instruction to the packet in the form of a selector
private TrafficSelector.Builder translateInstruction(TrafficSelector.Builder newSelector, Instruction instruction) {
    log.debug("Translating instruction {}", instruction);
    log.debug("New Selector {}", newSelector.build());
    // TODO add as required
    Criterion criterion = null;
    if (instruction.type() == Instruction.Type.L2MODIFICATION) {
        L2ModificationInstruction l2Instruction = (L2ModificationInstruction) instruction;
        switch(l2Instruction.subtype()) {
            case VLAN_ID:
                ModVlanIdInstruction vlanIdInstruction = (ModVlanIdInstruction) instruction;
                VlanId id = vlanIdInstruction.vlanId();
                criterion = Criteria.matchVlanId(id);
                break;
            case VLAN_POP:
                criterion = Criteria.matchVlanId(VlanId.NONE);
                break;
            case MPLS_PUSH:
                L2ModificationInstruction.ModMplsHeaderInstruction mplsEthInstruction = (L2ModificationInstruction.ModMplsHeaderInstruction) instruction;
                criterion = Criteria.matchEthType(mplsEthInstruction.ethernetType().toShort());
                // When pushing MPLS adding metadata to remember the original ethtype
                if (isHardwareSwitch()) {
                    TrafficSelector temporaryPacket = newSelector.build();
                    Criterion ethCriterion = temporaryPacket.getCriterion(Criterion.Type.ETH_TYPE);
                    if (ethCriterion != null) {
                        TrafficSelector.Builder tempSelector = DefaultTrafficSelector.builder(temporaryPacket);
                        // Store the old ether type for the
                        tempSelector.matchMetadata(((EthTypeCriterion) ethCriterion).ethType().toShort());
                        newSelector = tempSelector;
                    }
                }
                break;
            case MPLS_POP:
                L2ModificationInstruction.ModMplsHeaderInstruction mplsPopInstruction = (L2ModificationInstruction.ModMplsHeaderInstruction) instruction;
                criterion = Criteria.matchEthType(mplsPopInstruction.ethernetType().toShort());
                // When popping MPLS we remove label and BOS
                TrafficSelector temporaryPacket = newSelector.build();
                if (temporaryPacket.getCriterion(Criterion.Type.MPLS_LABEL) != null) {
                    TrafficSelector.Builder noMplsSelector = DefaultTrafficSelector.builder();
                    temporaryPacket.criteria().stream().filter(c -> !c.type().equals(Criterion.Type.MPLS_LABEL) && !c.type().equals(Criterion.Type.MPLS_BOS)).forEach(noMplsSelector::add);
                    newSelector = noMplsSelector;
                }
                break;
            case MPLS_LABEL:
                L2ModificationInstruction.ModMplsLabelInstruction mplsLabelInstruction = (L2ModificationInstruction.ModMplsLabelInstruction) instruction;
                criterion = Criteria.matchMplsLabel(mplsLabelInstruction.label());
                newSelector.matchMplsBos(true);
                break;
            case ETH_DST:
                L2ModificationInstruction.ModEtherInstruction modEtherDstInstruction = (L2ModificationInstruction.ModEtherInstruction) instruction;
                criterion = Criteria.matchEthDst(modEtherDstInstruction.mac());
                break;
            case ETH_SRC:
                L2ModificationInstruction.ModEtherInstruction modEtherSrcInstruction = (L2ModificationInstruction.ModEtherInstruction) instruction;
                criterion = Criteria.matchEthSrc(modEtherSrcInstruction.mac());
                break;
            default:
                log.debug("Unsupported L2 Instruction");
                break;
        }
    } else {
        log.debug("Unsupported Instruction");
    }
    if (criterion != null) {
        log.debug("Adding criterion {}", criterion);
        newSelector.add(criterion);
    }
    return newSelector;
}
Also used : PortNumber(org.onosproject.net.PortNumber) FlowEntry(org.onosproject.net.flow.FlowEntry) ConnectPoint(org.onosproject.net.ConnectPoint) DataPlaneEntity(org.onosproject.net.DataPlaneEntity) PipelineTraceable(org.onosproject.net.behaviour.PipelineTraceable) L2_INTERFACE_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L2_INTERFACE_TYPE) TMAC_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.TMAC_TABLE) Map(java.util.Map) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) IndexTableId(org.onosproject.net.flow.IndexTableId) VLAN_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.VLAN_TABLE) Set(java.util.Set) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) Collectors(java.util.stream.Collectors) L3_MULTICAST_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L3_MULTICAST_TYPE) L2_MULTICAST_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L2_MULTICAST_TYPE) EthType(org.onlab.packet.EthType) PipelineTraceableOutput(org.onosproject.net.PipelineTraceableOutput) List(java.util.List) PipelineTraceableInput(org.onosproject.net.PipelineTraceableInput) FlowRule(org.onosproject.net.flow.FlowRule) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) Ofdpa2Pipeline(org.onosproject.driver.pipeline.ofdpa.Ofdpa2Pipeline) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) Pipeliner(org.onosproject.net.behaviour.Pipeliner) PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) BRIDGING_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.BRIDGING_TABLE) TableId(org.onosproject.net.flow.TableId) ACL_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.ACL_TABLE) GroupBucket(org.onosproject.net.group.GroupBucket) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) OvsOfdpaPipeline(org.onosproject.driver.pipeline.ofdpa.OvsOfdpaPipeline) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket) L2_FLOOD_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L2_FLOOD_TYPE) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) MPLS_L3_TYPE_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.MPLS_L3_TYPE_TABLE) Instruction(org.onosproject.net.flow.instructions.Instruction) VlanId(org.onlab.packet.VlanId) GroupId(org.onosproject.core.GroupId) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) MULTICAST_ROUTING_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.MULTICAST_ROUTING_TABLE) Comparator(java.util.Comparator) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) 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) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) VlanId(org.onlab.packet.VlanId)

Example 24 with EthTypeCriterion

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

the class OfdpaPipelineTraceable method handleOfdpa27FixedTable.

// Handles table 27 in Ofpda which is a fixed table not visible to any controller that handles Mpls Labels.
private TrafficSelector handleOfdpa27FixedTable(TrafficSelector initialPacket, TrafficSelector packet) {
    log.debug("Handling table 27 on OFDPA, removing mpls ETH Type and change mpls label");
    Criterion mplsCriterion = packet.getCriterion(Criterion.Type.ETH_TYPE);
    // T3 was using the initial packet of the trace - using the metadata in the packet to carry this info
    Criterion metadataCriterion = initialPacket.getCriterion(Criterion.Type.METADATA);
    ImmutableList.Builder<Instruction> builder = ImmutableList.builder();
    // If the packet comes in with the expected elements we update it as per OFDPA spec.
    if (mplsCriterion != null && ((EthTypeCriterion) mplsCriterion).ethType().equals(EthType.EtherType.MPLS_UNICAST.ethType()) && metadataCriterion != null) {
        // Get the metadata to restore the original ethertype
        long ethType = ((MetadataCriterion) metadataCriterion).metadata();
        // TODO update with parsing with eth MPLS pop Instruction for treating label an bos
        Instruction ethInstruction = Instructions.popMpls(EthType.EtherType.lookup((short) ethType).ethType());
        // FIXME what do we use as L3_Unicast mpls Label ?
        // translateInstruction(builder, ethInstruction);
        builder.add(ethInstruction);
        // Filtering out metadata
        TrafficSelector.Builder currentPacketBuilder = DefaultTrafficSelector.builder();
        packet.criteria().stream().filter(criterion -> criterion.type() != Criterion.Type.METADATA).forEach(currentPacketBuilder::add);
        packet = currentPacketBuilder.build();
    }
    packet = updatePacket(packet, builder.build()).build();
    return packet;
}
Also used : PortNumber(org.onosproject.net.PortNumber) FlowEntry(org.onosproject.net.flow.FlowEntry) ConnectPoint(org.onosproject.net.ConnectPoint) DataPlaneEntity(org.onosproject.net.DataPlaneEntity) PipelineTraceable(org.onosproject.net.behaviour.PipelineTraceable) L2_INTERFACE_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L2_INTERFACE_TYPE) TMAC_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.TMAC_TABLE) Map(java.util.Map) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) IndexTableId(org.onosproject.net.flow.IndexTableId) VLAN_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.VLAN_TABLE) Set(java.util.Set) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) Collectors(java.util.stream.Collectors) L3_MULTICAST_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L3_MULTICAST_TYPE) L2_MULTICAST_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L2_MULTICAST_TYPE) EthType(org.onlab.packet.EthType) PipelineTraceableOutput(org.onosproject.net.PipelineTraceableOutput) List(java.util.List) PipelineTraceableInput(org.onosproject.net.PipelineTraceableInput) FlowRule(org.onosproject.net.flow.FlowRule) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) Ofdpa2Pipeline(org.onosproject.driver.pipeline.ofdpa.Ofdpa2Pipeline) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) Pipeliner(org.onosproject.net.behaviour.Pipeliner) PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) BRIDGING_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.BRIDGING_TABLE) TableId(org.onosproject.net.flow.TableId) ACL_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.ACL_TABLE) GroupBucket(org.onosproject.net.group.GroupBucket) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) OvsOfdpaPipeline(org.onosproject.driver.pipeline.ofdpa.OvsOfdpaPipeline) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket) L2_FLOOD_TYPE(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.L2_FLOOD_TYPE) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) MPLS_L3_TYPE_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.MPLS_L3_TYPE_TABLE) Instruction(org.onosproject.net.flow.instructions.Instruction) VlanId(org.onlab.packet.VlanId) GroupId(org.onosproject.core.GroupId) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) MULTICAST_ROUTING_TABLE(org.onosproject.driver.pipeline.ofdpa.OfdpaPipelineUtility.MULTICAST_ROUTING_TABLE) Comparator(java.util.Comparator) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) 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) ImmutableList(com.google.common.collect.ImmutableList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction)

Example 25 with EthTypeCriterion

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

the class Ofdpa2Pipeline method buildTmacRuleForMcastFromUnicast.

private FlowRule buildTmacRuleForMcastFromUnicast(FlowRule tmacRuleForUnicast, ApplicationId applicationId) {
    final TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    final TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    FlowRule rule;
    // Build the selector
    for (Criterion criterion : tmacRuleForUnicast.selector().criteria()) {
        if (criterion instanceof VlanIdCriterion) {
            if (requireVlanExtensions()) {
                OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(((VlanIdCriterion) criterion).vlanId());
                selector.extension(ofdpaMatchVlanVid, deviceId);
            } else {
                selector.add(criterion);
            }
        } else if (criterion instanceof EthTypeCriterion) {
            selector.add(criterion);
            if (Objects.equals(((EthTypeCriterion) criterion).ethType(), EtherType.IPV4.ethType())) {
                selector.matchEthDstMasked(IPV4_MULTICAST, IPV4_MULTICAST_MASK);
            } else if (Objects.equals(((EthTypeCriterion) criterion).ethType(), EtherType.IPV6.ethType())) {
                selector.matchEthDstMasked(IPV6_MULTICAST, IPV6_MULTICAST_MASK);
            } else {
                // We don't need for mpls rules
                return null;
            }
        }
    }
    // Build the treatment
    treatment.transition(MULTICAST_ROUTING_TABLE);
    // Build the flowrule
    rule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(TMAC_TABLE).build();
    log.debug("Building TMac Mcast flowRule {}", rule);
    return rule;
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) MplsBosCriterion(org.onosproject.net.flow.criteria.MplsBosCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) 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) OfdpaMatchVlanVid(org.onosproject.driver.extensions.OfdpaMatchVlanVid) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

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