Search in sources :

Example 1 with OFInstructionWriteMetadata

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

the class OneSwitchFlowInstallFlowModFactory method makeMetadataInstructions.

@Override
protected List<OFInstruction> makeMetadataInstructions() {
    RoutingMetadata metadata = RoutingMetadata.builder().oneSwitchFlowFlag(true).build(switchFeatures);
    OFInstructionWriteMetadata writeMetadata = of.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
    return Lists.newArrayList(writeMetadata);
}
Also used : OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata)

Example 2 with OFInstructionWriteMetadata

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

the class SwitchManager method buildArpInputCustomerFlow.

@Override
public OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port) throws SwitchNotFoundException {
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    Match match = ofFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(port)).setExact(MatchField.ETH_TYPE, EthType.ARP).build();
    RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().arpFlag(true), sw);
    OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
    OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(PRE_INGRESS_TABLE_ID));
    return prepareFlowModBuilder(ofFactory, Cookie.encodeArpInputCustomer(port), ARP_INPUT_CUSTOMER_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable, writeMetadata)).build();
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 3 with OFInstructionWriteMetadata

use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata 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 4 with OFInstructionWriteMetadata

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

the class SwitchManager method buildLldpInputCustomerFlow.

@Override
public OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port) throws SwitchNotFoundException {
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    Match match = ofFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(port)).setExact(MatchField.ETH_TYPE, EthType.LLDP).build();
    RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(true), sw);
    OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
    OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(PRE_INGRESS_TABLE_ID));
    return prepareFlowModBuilder(ofFactory, Cookie.encodeLldpInputCustomer(port), LLDP_INPUT_CUSTOMER_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable, writeMetadata)).build();
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Aggregations

OFInstructionWriteMetadata (org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata)4 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)3 OFInstructionGotoTable (org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable)3 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)2 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)2 Match (org.projectfloodlight.openflow.protocol.match.Match)2 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)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 GroupAction (org.openkilda.rulemanager.action.GroupAction)1 MeterAction (org.openkilda.rulemanager.action.MeterAction)1 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)1 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)1 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)1 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)1