Search in sources :

Example 11 with PipelineTraceablePacket

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

the class OfdpaPipelineTraceableTest method testOvsOfdpaL2BridingNotOrdered.

/**
 * Test l2 bridging with l2 interface group that has actions not in order for ovs-ofdpa.
 */
@Test
public void testOvsOfdpaL2BridingNotOrdered() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_L2_BRIDG_UNTAG_PACKET), OFDPA_CP, getDataPlaneEntities(OVS_OFDPA_DRIVER, L2_BRIDG_NOT_ORDERED_OVS_OFDPA));
    PipelineTraceable pipelineTraceable = setUpOvsOfdpa();
    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_OVS_OFDPA);
    assertThat(chains.size(), is(1));
    assertNotNull(hitChain.outputPort());
    assertThat(hitChain.outputPort().port(), is(OUT_PORT));
    assertThat(hitChain.hitChain().size(), is(6));
    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 12 with PipelineTraceablePacket

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

the class OfdpaPipelineTraceableTest method testOvsOfdpaArp.

/**
 * Test punt arp for ovs-ofdpa.
 */
@Test
public void testOvsOfdpaArp() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_ARP_PACKET), OFDPA_CP, getDataPlaneEntities(OVS_OFDPA_DRIVER, ARP_OVS_OFDPA));
    PipelineTraceable pipelineTraceable = setUpOvsOfdpa();
    PipelineTraceableOutput pipelineOutput = pipelineTraceable.apply(pipelineInput);
    assertNotNull(pipelineOutput);
    assertThat(pipelineOutput.hitChains().size(), is(3));
    assertThat(pipelineOutput.result(), is(PipelineTraceableResult.SUCCESS));
    PipelineTraceableHitChain hitChain = pipelineOutput.hitChains().get(0);
    assertNotNull(hitChain);
    List<List<DataPlaneEntity>> chains = getHitChains(ARP_OVS_OFDPA);
    assertThat(chains.size(), is(3));
    // This is the copy sent to the controller
    assertNotNull(hitChain.outputPort());
    assertThat(hitChain.outputPort().port(), is(PortNumber.CONTROLLER));
    assertThat(hitChain.hitChain().size(), is(7));
    assertEquals(IN_ARP_PACKET, hitChain.egressPacket().packet());
    assertFalse(hitChain.isDropped());
    assertEquals(chains.get(0), hitChain.hitChain());
    // This is the copy sent to the member port
    hitChain = pipelineOutput.hitChains().get(1);
    assertNotNull(hitChain);
    assertNotNull(hitChain.outputPort());
    assertThat(hitChain.outputPort().port(), is(OUT_PORT));
    assertThat(hitChain.hitChain().size(), is(8));
    assertEquals(IN_ARP_PACKET, hitChain.egressPacket().packet());
    assertFalse(hitChain.isDropped());
    assertEquals(chains.get(1), hitChain.hitChain());
    // This is the copy sent on the input port
    hitChain = pipelineOutput.hitChains().get(2);
    assertNotNull(hitChain);
    assertNotNull(hitChain.outputPort());
    assertThat(hitChain.outputPort().port(), is(PORT));
    assertThat(hitChain.hitChain().size(), is(8));
    assertEquals(IN_ARP_PACKET, hitChain.egressPacket().packet());
    assertTrue(hitChain.isDropped());
    assertEquals(chains.get(2), 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 13 with PipelineTraceablePacket

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

the class OfdpaPipelineTraceableTest method testOfdpaPuntIP.

/**
 * Test punt ip for ofdpa.
 */
@Test
public void testOfdpaPuntIP() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_PUNT_IP_PACKET), OFDPA_CP, getDataPlaneEntities(OFDPA_DRIVER, PUNT_IP_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_IP_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_IP_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 14 with PipelineTraceablePacket

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

the class OfdpaPipelineTraceableTest method testOfdpaL2BridingUntagged.

/**
 * Test l2 bridging with untagged hosts for ofdpa.
 */
@Test
public void testOfdpaL2BridingUntagged() {
    PipelineTraceableInput pipelineInput = new PipelineTraceableInput(new PipelineTraceablePacket(IN_L2_BRIDG_UNTAG_PACKET), OFDPA_CP, getDataPlaneEntities(OFDPA_DRIVER, L2_BRIDG_UNTAG_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_UNTAG_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 15 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)

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