Search in sources :

Example 11 with PipelineTraceableHitChain

use of org.onosproject.net.PipelineTraceableHitChain 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 12 with PipelineTraceableHitChain

use of org.onosproject.net.PipelineTraceableHitChain 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 13 with PipelineTraceableHitChain

use of org.onosproject.net.PipelineTraceableHitChain 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 14 with PipelineTraceableHitChain

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

the class OfdpaPipelineTraceable method handleOutputFlows.

// Handles output flows
private List<FlowEntry> handleOutputFlows(TrafficSelector currentPacket, List<FlowEntry> outputFlows, TrafficSelector.Builder egressPacket, List<PortNumber> outputPorts, PipelineTraceableHitChain currentHitChain, PipelineTraceableOutput.Builder outputBuilder, TrafficSelector initialPacket) {
    // TODO optimization
    // outputFlows contains also last rule of device, so we need filtering for OUTPUT instructions.
    List<FlowEntry> outputFlowEntries = outputFlows.stream().filter(flow -> flow.treatment().allInstructions().stream().filter(instruction -> instruction.type().equals(Instruction.Type.OUTPUT)).count() > 0).collect(Collectors.toList());
    if (outputFlowEntries.size() > 1) {
        outputBuilder.appendToLog("More than one flow rule with OUTPUT instruction");
        log.warn("There cannot be more than one flow entry with OUTPUT instruction for {}", currentPacket);
    }
    if (outputFlowEntries.size() == 1) {
        OutputInstruction outputInstruction = (OutputInstruction) outputFlowEntries.get(0).treatment().allInstructions().stream().filter(instruction -> instruction.type().equals(Instruction.Type.OUTPUT)).findFirst().get();
        buildOutputFromDevice(egressPacket, outputPorts, outputInstruction, currentHitChain, outputBuilder, initialPacket, false);
    }
    return outputFlowEntries;
}
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) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) FlowEntry(org.onosproject.net.flow.FlowEntry)

Example 15 with PipelineTraceableHitChain

use of org.onosproject.net.PipelineTraceableHitChain 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

PipelineTraceableHitChain (org.onosproject.net.PipelineTraceableHitChain)24 PipelineTraceablePacket (org.onosproject.net.PipelineTraceablePacket)24 PipelineTraceableOutput (org.onosproject.net.PipelineTraceableOutput)22 List (java.util.List)21 PipelineTraceableInput (org.onosproject.net.PipelineTraceableInput)21 PipelineTraceable (org.onosproject.net.behaviour.PipelineTraceable)21 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)3 DataPlaneEntity (org.onosproject.net.DataPlaneEntity)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)3 Instruction (org.onosproject.net.flow.instructions.Instruction)3 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)3 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)3 ModVlanIdInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction)3 ConnectPoint (org.onosproject.net.ConnectPoint)2 Instructions (org.onosproject.net.flow.instructions.Instructions)2 Group (org.onosproject.net.group.Group)2 GroupBucket (org.onosproject.net.group.GroupBucket)2 ImmutableList (com.google.common.collect.ImmutableList)1