use of org.projectfloodlight.openflow.protocol.instruction.OFInstruction in project open-kilda by telstra.
the class IngressInstallFlowModFactory method makeForwardMessageInstructions.
protected List<OFInstruction> makeForwardMessageInstructions(EffectiveIds effectiveIds, List<Integer> vlanStack) {
List<OFAction> applyActions = new ArrayList<>();
List<OFInstruction> instructions = new ArrayList<>();
MeterId effectiveMeterId = effectiveIds.getMeterId();
if (effectiveMeterId != null) {
OfAdapter.INSTANCE.makeMeterCall(of, effectiveMeterId, applyActions, instructions);
}
GroupId effectiveGroupId = effectiveIds.getGroupId();
boolean groupIsPresent = effectiveGroupId != null;
applyActions.addAll(makeTransformActions(vlanStack, groupIsPresent));
if (groupIsPresent) {
applyActions.add(makeGroupAction(effectiveGroupId));
} else {
applyActions.add(makeOutputAction());
}
instructions.add(of.instructions().applyActions(applyActions));
if (command.getMetadata().isMultiTable() && effectiveGroupId == null) {
instructions.add(of.instructions().gotoTable(TableId.of(SwitchManager.POST_INGRESS_TABLE_ID)));
instructions.addAll(makeMetadataInstructions());
}
return instructions;
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstruction in project open-kilda by telstra.
the class Server42FlowRttInputFlowGenerator method generateFlowMod.
/**
* Generated OFFlowMod for Server 42 Flow RTT input rule.
*/
public static Optional<OFFlowMod> generateFlowMod(OFFactory ofFactory, Set<SwitchFeature> features, int udpOffset, int customerPort, int server42Port, MacAddress server42macAddress) {
Match match = buildMatch(ofFactory, server42Port, customerPort + udpOffset, server42macAddress);
List<OFAction> actions = Lists.newArrayList(actionSetUdpSrcAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT)), actionSetUdpDstAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT)));
if (features.contains(NOVIFLOW_COPY_FIELD)) {
actions.add(buildServer42CopyFirstTimestamp(ofFactory));
}
List<OFInstruction> instructions = ImmutableList.of(buildInstructionApplyActions(ofFactory, actions), instructionWriteMetadata(ofFactory, customerPort, features), instructionGoToTable(ofFactory, TableId.of(PRE_INGRESS_TABLE_ID)));
return Optional.of(prepareFlowModBuilder(ofFactory, encodeServer42FlowRttInput(customerPort), SERVER_42_FLOW_RTT_INPUT_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(instructions).build());
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstruction in project open-kilda by telstra.
the class SwitchManager method installServer42OuterVlanMatchSharedFlow.
@Override
public void installServer42OuterVlanMatchSharedFlow(DatapathId dpid, FlowSharedSegmentCookie cookie) throws SwitchOperationException {
IOFSwitch sw = lookupSwitch(dpid);
OFFactory of = sw.getOFFactory();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(cookie.getVlanId()).build(featureDetectorService.detectSwitch(sw));
ImmutableList<OFInstruction> instructions = ImmutableList.of(of.instructions().applyActions(ImmutableList.of(of.actions().popVlan())), of.instructions().writeMetadata(metadata.getValue(), metadata.getMask()), of.instructions().gotoTable(TableId.of(SwitchManager.INGRESS_TABLE_ID)));
OFFlowMod flow = prepareFlowModBuilder(of, cookie.getValue(), FLOW_PRIORITY, PRE_INGRESS_TABLE_ID).setCookie(U64.of(cookie.getValue())).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(cookie.getPortNumber())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(cookie.getVlanId())).build()).setInstructions(instructions).build();
pushFlow(sw, "--server 42 shared rule--", flow);
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstruction 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();
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstruction 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();
}
Aggregations