Search in sources :

Example 21 with PipelineTraceablePacket

use of org.onosproject.net.PipelineTraceablePacket in project onos by opennetworkinglab.

the class OfdpaPipelineTraceableTest method testOfdpaL2BridingNotOrdered.

/**
 * Test l2 bridging with l2 interface group that has actions not in order for ofdpa.
 */
@Test
public void testOfdpaL2BridingNotOrdered() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_L2_BRIDG_UNTAG_PACKET), OFDPA_CP, getDataPlaneEntities(OFDPA_DRIVER, L2_BRIDG_NOT_ORDERED_OFDPA));
    PipelineTraceable pipelineTraceable = setUpOfdpa();
    PipelineTraceableOutput pipelineOutput = pipelineTraceable.apply(pipelineInput);
    assertNotNull(pipelineOutput);
    assertThat(pipelineOutput.hitChains().size(), is(1));
    assertThat(pipelineOutput.result(), is(PipelineTraceableResult.SUCCESS));
    PipelineTraceableHitChain hitChain = pipelineOutput.hitChains().get(0);
    assertNotNull(hitChain);
    List<List<DataPlaneEntity>> chains = getHitChains(L2_BRIDG_NOT_ORDERED_OFDPA);
    assertThat(chains.size(), is(1));
    assertNotNull(hitChain.outputPort());
    assertThat(hitChain.outputPort().port(), is(OUT_PORT));
    assertThat(hitChain.hitChain().size(), is(4));
    assertEquals(IN_L2_BRIDG_UNTAG_PACKET, hitChain.egressPacket().packet());
    assertFalse(hitChain.isDropped());
    assertEquals(chains.get(0), hitChain.hitChain());
}
Also used : PipelineTraceable(org.onosproject.net.behaviour.PipelineTraceable) List(java.util.List) PipelineTraceableOutput(org.onosproject.net.PipelineTraceableOutput) PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) PipelineTraceableInput(org.onosproject.net.PipelineTraceableInput) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket) Test(org.junit.Test)

Example 22 with PipelineTraceablePacket

use of org.onosproject.net.PipelineTraceablePacket in project onos by opennetworkinglab.

the class OfdpaPipelineTraceable method getGroupsFromInstructions.

// Gets group information from instructions.
private void getGroupsFromInstructions(Map<GroupId, Group> groups, List<Instruction> instructions, TrafficSelector.Builder egressPacket, List<PortNumber> outputPorts, PipelineTraceableHitChain currentHitChain, PipelineTraceableOutput.Builder outputBuilder, PipelineTraceableInput input, boolean dropped) {
    List<Instruction> groupInstructionlist = new ArrayList<>();
    // sort instructions according to priority (larger Instruction.Type ENUM constant first)
    // which enables to treat other actions before the OUTPUT action
    // TODO improve the priority scheme according to the OpenFlow ActionSet spec
    List<Instruction> instructionsSorted = new ArrayList<>();
    instructionsSorted.addAll(instructions);
    instructionsSorted.sort((instr1, instr2) -> Integer.compare(instr2.type().ordinal(), instr1.type().ordinal()));
    // Handles first all non-group instructions
    for (Instruction instruction : instructionsSorted) {
        log.debug("Considering Instruction {}", instruction);
        // to the possible outputs for this packet
        if (!instruction.type().equals(Instruction.Type.GROUP)) {
            // or add the output to the possible outputs for this packet
            if (instruction.type().equals(Instruction.Type.OUTPUT)) {
                buildOutputFromDevice(egressPacket, outputPorts, (OutputInstruction) instruction, currentHitChain, outputBuilder, input.ingressPacket().packet(), dropped);
            } else {
                egressPacket = translateInstruction(egressPacket, instruction);
            }
        } else {
            // Store for later if the instruction is pointing to a group
            groupInstructionlist.add(instruction);
        }
    }
    // handle all the internal instructions pointing to a group.
    for (Instruction instr : groupInstructionlist) {
        Instructions.GroupInstruction groupInstruction = (Instructions.GroupInstruction) instr;
        Group group = groups.get(groupInstruction.groupId());
        // group does not exist in the dataplane
        if (group == null) {
            currentHitChain.setEgressPacket(new PipelineTraceablePacket(egressPacket.build()));
            currentHitChain.dropped();
            outputBuilder.appendToLog("Null group for Instruction " + instr).noGroups().addHitChain(currentHitChain);
            break;
        }
        log.debug("Analyzing group {}", group.id());
        // group is there but there are no members/buckets
        if (group.buckets().buckets().size() == 0) {
            // add the group to the traversed groups
            currentHitChain.addDataPlaneEntity(new DataPlaneEntity(group));
            currentHitChain.setEgressPacket(new PipelineTraceablePacket(egressPacket.build()));
            currentHitChain.dropped();
            outputBuilder.appendToLog("Group " + group.id() + " has no buckets").noMembers().addHitChain(currentHitChain);
            break;
        }
        PipelineTraceableHitChain newHitChain;
        TrafficSelector.Builder newEgressPacket;
        // Cycle in each of the group's buckets and add them to the groups for this Device.
        for (GroupBucket bucket : group.buckets().buckets()) {
            // add the group to the traversed groups
            currentHitChain.addDataPlaneEntity(new DataPlaneEntity(group));
            // Go to the next step - using a copy of the egress packet and of the hit chain
            newHitChain = PipelineTraceableHitChain.emptyHitChain();
            currentHitChain.hitChain().forEach(newHitChain::addDataPlaneEntity);
            newEgressPacket = DefaultTrafficSelector.builder(egressPacket.build());
            getGroupsFromInstructions(groups, bucket.treatment().allInstructions(), newEgressPacket, outputPorts, newHitChain, outputBuilder, input, dropped | isDropped(group.id(), bucket, input.ingressPort()));
        }
    }
}
Also used : Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) Instructions(org.onosproject.net.flow.instructions.Instructions) 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) DataPlaneEntity(org.onosproject.net.DataPlaneEntity) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) GroupBucket(org.onosproject.net.group.GroupBucket) PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket)

Example 23 with PipelineTraceablePacket

use of org.onosproject.net.PipelineTraceablePacket in project onos by opennetworkinglab.

the class OfdpaPipelineTraceableTest method testOvsOfdpaL2BroadEmpty.

/**
 * Test failure due l2 flood group with no buckets for ovs-ofdpa.
 */
@Test
public void testOvsOfdpaL2BroadEmpty() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_L2_BROAD_UNTAG_PACKET), OFDPA_CP, getDataPlaneEntities(OVS_OFDPA_DRIVER, L2_BROAD_EMPTY_OVS_OFDPA));
    PipelineTraceable pipelineTraceable = setUpOvsOfdpa();
    PipelineTraceableOutput pipelineOutput = pipelineTraceable.apply(pipelineInput);
    assertNotNull(pipelineOutput);
    assertThat(pipelineOutput.hitChains().size(), is(1));
    assertThat(pipelineOutput.result(), is(PipelineTraceableResult.NO_GROUP_MEMBERS));
    PipelineTraceableHitChain hitChain = pipelineOutput.hitChains().get(0);
    assertNotNull(hitChain);
    List<List<DataPlaneEntity>> chains = getHitChains(L2_BROAD_EMPTY_OVS_OFDPA);
    assertThat(chains.size(), is(1));
    assertNull(hitChain.outputPort());
    assertThat(hitChain.hitChain().size(), is(6));
    assertEquals(OUT_L2_BROAD_EMPTY, hitChain.egressPacket().packet());
    assertTrue(hitChain.isDropped());
    assertEquals(chains.get(0), hitChain.hitChain());
}
Also used : PipelineTraceable(org.onosproject.net.behaviour.PipelineTraceable) List(java.util.List) PipelineTraceableOutput(org.onosproject.net.PipelineTraceableOutput) PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) PipelineTraceableInput(org.onosproject.net.PipelineTraceableInput) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket) Test(org.junit.Test)

Example 24 with PipelineTraceablePacket

use of org.onosproject.net.PipelineTraceablePacket in project onos by opennetworkinglab.

the class OfdpaPipelineTraceableTest method testOfdpaPuntLldp.

/**
 * Test punt lldp for ovs-ofdpa.
 */
@Test
public void testOfdpaPuntLldp() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_PUNT_LLDP_PACKET), OFDPA_CP, getDataPlaneEntities(OFDPA_DRIVER, PUNT_LLDP_OFDPA));
    PipelineTraceable pipelineTraceable = setUpOfdpa();
    PipelineTraceableOutput pipelineOutput = pipelineTraceable.apply(pipelineInput);
    assertNotNull(pipelineOutput);
    assertThat(pipelineOutput.hitChains().size(), is(1));
    assertThat(pipelineOutput.result(), is(PipelineTraceableResult.SUCCESS));
    PipelineTraceableHitChain hitChain = pipelineOutput.hitChains().get(0);
    assertNotNull(hitChain);
    List<List<DataPlaneEntity>> chains = getHitChains(PUNT_LLDP_OFDPA);
    assertThat(chains.size(), is(1));
    assertNotNull(hitChain.outputPort());
    assertThat(hitChain.outputPort().port(), is(PortNumber.CONTROLLER));
    assertThat(hitChain.hitChain().size(), is(4));
    assertEquals(IN_PUNT_LLDP_PACKET, hitChain.egressPacket().packet());
    assertFalse(hitChain.isDropped());
    assertEquals(chains.get(0), hitChain.hitChain());
}
Also used : PipelineTraceable(org.onosproject.net.behaviour.PipelineTraceable) List(java.util.List) PipelineTraceableOutput(org.onosproject.net.PipelineTraceableOutput) PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) PipelineTraceableInput(org.onosproject.net.PipelineTraceableInput) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket) Test(org.junit.Test)

Aggregations

PipelineTraceablePacket (org.onosproject.net.PipelineTraceablePacket)24 PipelineTraceableHitChain (org.onosproject.net.PipelineTraceableHitChain)23 PipelineTraceableOutput (org.onosproject.net.PipelineTraceableOutput)21 List (java.util.List)20 Test (org.junit.Test)20 PipelineTraceableInput (org.onosproject.net.PipelineTraceableInput)20 PipelineTraceable (org.onosproject.net.behaviour.PipelineTraceable)20 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)3 ArrayList (java.util.ArrayList)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 DataPlaneEntity (org.onosproject.net.DataPlaneEntity)2 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)2 Instruction (org.onosproject.net.flow.instructions.Instruction)2 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)2 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)2 ModVlanIdInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction)2 HashSet (java.util.HashSet)1 PortNumber (org.onosproject.net.PortNumber)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1