Search in sources :

Example 6 with OFInstructionGotoTable

use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable in project open-kilda by telstra.

the class SwitchManager method buildEgressIslVlanRule.

private OFFlowMod buildEgressIslVlanRule(OFFactory ofFactory, int port) {
    Match match = buildInPortMatch(port, ofFactory);
    OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(EGRESS_TABLE_ID));
    return prepareFlowModBuilder(ofFactory, Cookie.encodeIslVlanEgress(port), ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable)).build();
}
Also used : OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 7 with OFInstructionGotoTable

use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable in project open-kilda by telstra.

the class TablePassThroughDefaultFlowGenerator method generateFlow.

@Override
public SwitchFlowTuple generateFlow(IOFSwitch sw) {
    OFFactory ofFactory = sw.getOFFactory();
    OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(goToTableId));
    OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie, FlowModUtils.PRIORITY_MIN + 1, tableId).setInstructions(ImmutableList.of(goToTable)).build();
    return SwitchFlowTuple.builder().sw(sw).flow(flowMod).build();
}
Also used : OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod)

Example 8 with OFInstructionGotoTable

use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable in project open-kilda by telstra.

the class OfInstructionsConverter method convertToRuleManagerInstructions.

/**
 * Convert instructions.
 */
public Instructions convertToRuleManagerInstructions(List<OFInstruction> ofInstructions) {
    InstructionsBuilder builder = Instructions.builder();
    for (OFInstruction ofInstruction : ofInstructions) {
        if (ofInstruction instanceof OFInstructionApplyActions) {
            List<OFAction> ofActions = ((OFInstructionApplyActions) ofInstruction).getActions();
            List<Action> actions = ofActions.stream().map(this::convertToRuleManagerAction).collect(Collectors.toList());
            builder.applyActions(actions);
        } else if (ofInstruction instanceof OFInstructionWriteActions) {
            List<OFAction> ofActions = ((OFInstructionWriteActions) ofInstruction).getActions();
            Set<Action> actions = ofActions.stream().map(this::convertToRuleManagerAction).collect(Collectors.toSet());
            builder.writeActions(actions);
        } else if (ofInstruction instanceof OFInstructionMeter) {
            final long meterId = ((OFInstructionMeter) ofInstruction).getMeterId();
            builder.goToMeter(new MeterId(meterId));
        } else if (ofInstruction instanceof OFInstructionGotoTable) {
            final short tableId = ((OFInstructionGotoTable) ofInstruction).getTableId().getValue();
            builder.goToTable(OfTable.fromInt(tableId));
        } else if (ofInstruction instanceof OFInstructionWriteMetadata) {
            final long metadata = ((OFInstructionWriteMetadata) ofInstruction).getMetadata().getValue();
            final long metadataMask = ((OFInstructionWriteMetadata) ofInstruction).getMetadataMask().getValue();
            builder.writeMetadata(new OfMetadata(metadata, metadataMask));
        }
    }
    return builder.build();
}
Also used : OFInstructionMeter(org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter) MeterAction(org.openkilda.rulemanager.action.MeterAction) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) Set(java.util.Set) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) InstructionsBuilder(org.openkilda.rulemanager.Instructions.InstructionsBuilder) MeterId(org.openkilda.model.MeterId) OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OfMetadata(org.openkilda.rulemanager.OfMetadata) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) List(java.util.List) ArrayList(java.util.ArrayList) OFInstructionWriteActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions)

Example 9 with OFInstructionGotoTable

use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable in project open-kilda by telstra.

the class OfFlowStatsMapper method toFlowInstructions.

/**
 * Convert list of {@link OFInstruction} to {@link FlowInstructions}.
 * @param instructions list of instructions to be converted.
 * @return result of transformation {@link FlowInstructions}.
 */
public FlowInstructions toFlowInstructions(final List<OFInstruction> instructions) {
    FlowInstructions.FlowInstructionsBuilder flowInstructions = FlowInstructions.builder();
    for (OFInstruction entry : instructions) {
        if (entry instanceof OFInstructionApplyActions) {
            List<OFAction> actions = ((OFInstructionApplyActions) entry).getActions();
            flowInstructions.applyActions(toFlowApplyActions(actions));
        } else if (entry instanceof OFInstructionMeter) {
            flowInstructions.goToMeter(((OFInstructionMeter) entry).getMeterId());
        } else if (entry instanceof OFInstructionGotoTable) {
            flowInstructions.goToTable(((OFInstructionGotoTable) entry).getTableId().getValue());
        }
    // add handling for other instructions here
    }
    return flowInstructions.build();
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFInstructionMeter(org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) FlowInstructions(org.openkilda.messaging.info.rule.FlowInstructions) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction)

Example 10 with OFInstructionGotoTable

use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable in project open-kilda by telstra.

the class SwitchManager method buildIntermediateIngressRule.

@Override
public OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port) throws SwitchNotFoundException {
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    Match match = buildInPortMatch(port, ofFactory);
    OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(PRE_INGRESS_TABLE_ID));
    return prepareFlowModBuilder(ofFactory, Cookie.encodeIngressRulePassThrough(port), INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable)).build();
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Aggregations

OFInstructionGotoTable (org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable)14 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)8 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)7 Match (org.projectfloodlight.openflow.protocol.match.Match)7 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)7 OFFlowDelete (org.projectfloodlight.openflow.protocol.OFFlowDelete)4 OFInstruction (org.projectfloodlight.openflow.protocol.instruction.OFInstruction)3 OFInstructionWriteMetadata (org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata)3 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)2 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)2 OFInstructionApplyActions (org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions)2 OFInstructionMeter (org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 FlowInstructions (org.openkilda.messaging.info.rule.FlowInstructions)1 MeterId (org.openkilda.model.MeterId)1 InstructionsBuilder (org.openkilda.rulemanager.Instructions.InstructionsBuilder)1 OfMetadata (org.openkilda.rulemanager.OfMetadata)1 Action (org.openkilda.rulemanager.action.Action)1