/** * Configures the flow builder to have the single given instruction. * * @param flowBuilder The flow builder. * @param instruction The instruction. * @return The flow builder. */ public static FlowBuilder setFlowBuilderInstruction(FlowBuilder flowBuilder, Instruction instruction) { flowBuilder.setInstructions( new InstructionsBuilder() .setInstruction(Collections.singletonList(instruction)) .build()); return flowBuilder; }
public static Instructions getInstructions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction... instructions) { List<Instruction> ins = new ArrayList<>(); int order = 0; for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction i : instructions) { ins.add(new InstructionBuilder() .setOrder(order) .setKey(new InstructionKey(order)) .setInstruction(i) .build()); order++; } return new InstructionsBuilder().setInstruction(ins).build(); }
private FlowBuilder addPipelineInstruction( FlowBuilder flowBuilder , InstructionBuilder instructionBuilder,boolean isDrop) { InstructionBuilder pipeLineIndstructionBuilder = createPipleLineInstructionBuilder(isDrop); List<Instruction> instructionsList = Lists.newArrayList(); instructionsList.add(pipeLineIndstructionBuilder.build()); if (null != instructionBuilder) { instructionsList.add(instructionBuilder.build()); } InstructionsBuilder isb = new InstructionsBuilder(); isb.setInstruction(instructionsList); flowBuilder.setInstructions(isb.build()); return flowBuilder; }
private FlowBuilder addPipelineInstruction( FlowBuilder flowBuilder , InstructionBuilder instructionBuilder, boolean isDrop) { InstructionBuilder pipeLineIndstructionBuilder = createPipleLineInstructionBuilder(isDrop); List<Instruction> instructionsList = Lists.newArrayList(); instructionsList.add(pipeLineIndstructionBuilder.build()); if (null != instructionBuilder) { instructionsList.add(instructionBuilder.build()); } InstructionsBuilder isb = new InstructionsBuilder(); isb.setInstruction(instructionsList); flowBuilder.setInstructions(isb.build()); return flowBuilder; }
private Instructions createInstructions(NodeConnectorRef dstPort, Long meterId) { List<Instruction> instructionList = new LinkedList<>(); Uri dstPortUri = dstPort.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId(); if (meterId != null && meterId > 0) { instructionList.add(createMeterInstruction(meterId, 0)); instructionList.add(createApplyActionsInstruction(dstPortUri, 1)); } else { instructionList.add(createApplyActionsInstruction(dstPortUri, 0)); } return new InstructionsBuilder() .setInstruction(instructionList) .build(); }
public static Instructions instructions(Instruction... instructions) { ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins = new ArrayList<>(); int order = 0; for (Instruction i : instructions) { ins.add(new InstructionBuilder().setOrder(order++).setInstruction(i).build()); } return new InstructionsBuilder().setInstruction(ins).build(); }
private FlowBuilder addInstructionWithConntrackRecirc( FlowBuilder flowBuilder) { InstructionBuilder instructionBuilder = null; if (securityServicesManager.isConntrackEnabled()) { Action conntrackAction = ActionUtils.nxConntrackAction(0, 0L, 0, (short)0x0); instructionBuilder = InstructionUtils .createInstructionBuilder(ActionUtils.conntrackActionBuilder(conntrackAction), 1, false); List<Instruction> instructionsList = Lists.newArrayList(); instructionsList.add(instructionBuilder.build()); InstructionsBuilder isb = new InstructionsBuilder(); isb.setInstruction(instructionsList); flowBuilder.setInstructions(isb.build()); } return flowBuilder; }
private FlowBuilder addInstructionWithConntrackRecirc( FlowBuilder flowBuilder) { InstructionBuilder instructionBuilder = null; if (securityServicesManager.isConntrackEnabled()) { Action conntrackAction = ActionUtils.nxConntrackAction(0, 0L, 0, (short)0x0); instructionBuilder = InstructionUtils .createInstructionBuilder(ActionUtils.conntrackActionBuilder(conntrackAction), 1, false); List<Instruction> instructionsList = Lists.newArrayList(); instructionsList.add(instructionBuilder.build()); InstructionsBuilder isb = new InstructionsBuilder(); isb.setInstruction(instructionsList); flowBuilder.setInstructions(isb.build()); } return flowBuilder; }
public static Instructions getInstructions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction... instructions) { ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins = new ArrayList<>(); int order = 0; for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction i : instructions) { ins.add(new InstructionBuilder() .setOrder(order) .setKey(new InstructionKey(order)) .setInstruction(i) .build()); order++; } return new InstructionsBuilder().setInstruction(ins).build(); }
public static Instructions gotoTableInstructions(short tableId) { return new InstructionsBuilder().setInstruction( ImmutableList.of(new InstructionBuilder().setOrder(0) .setInstruction(gotoTableIns(tableId)) .build())).build(); }
private void writeExternalL2Flow(short goToTable, int priority, OrdinalFactory.EndpointFwdCtxOrdinals ordinals, Long port, Match match, OfWriter ofWriter) { List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(ordinals.getEpgId()))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(ordinals.getCgId()))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(port))); int order = 0; Instruction applyActionsIns = new InstructionBuilder().setOrder(order++) .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()]))) .build(); Instruction gotoTable = new InstructionBuilder().setOrder(order) .setInstruction(gotoTableIns(goToTable)) .build(); ArrayList<Instruction> instructions = new ArrayList<>(); instructions.add(applyActionsIns); instructions.add(gotoTable); FlowId flowId = FlowIdUtils.newFlowId(tableId, "externalL2", match); FlowBuilder flowBuilder = base(tableId).setId(flowId) .setPriority(priority) .setMatch(match) .setInstructions(new InstructionsBuilder().setInstruction(instructions).build()); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); }
private static Optional<? extends Flow> injectMatchAndAction(Flow sourceFlow, Match match) { Instructions instructions = (new InstructionsBuilder()) .setInstruction(injectPushActionToInstruction(sourceFlow)) .build(); if (sourceFlow instanceof AddFlowInput) { return Optional.of(new AddFlowInputBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else if (sourceFlow instanceof RemoveFlowInput) { return Optional.of(new RemoveFlowInputBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else if (sourceFlow instanceof UpdatedFlow) { return Optional.of(new UpdatedFlowBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else { return Optional.empty(); } }
/** * Creates a set of redirect Instruction based on the port values * received. * @param outputPort OVS port to output the packet to * @return OpenFlow Flow Instructions */ protected Instructions createRedirectIntentInstructions(String outputPort) { List<Action> actionList = Lists.newArrayList(); int order = 0; actionList.add(FlowUtils.createOutputToPort(order++, outputPort)); ApplyActions applyRedirectActions = new ApplyActionsBuilder().setAction(actionList).build(); Instruction redirectInstruction = new InstructionBuilder().setOrder(0) .setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyRedirectActions).build()).build(); Instructions instructions = new InstructionsBuilder().setInstruction(ImmutableList.of(redirectInstruction)).build(); return instructions; }
/** * Creates a set of clear instructions to remove flows from switch * @return Instructions */ protected Instructions createClearFlowsInstructions() { Instruction clearInstruction = new InstructionBuilder().setOrder(0) .setInstruction(new ClearActionsCaseBuilder().setClearActions(new ClearActionsBuilder().build()).build()).build(); Instructions instructions = new InstructionsBuilder().setInstruction(ImmutableList.of(clearInstruction)) .build(); return instructions; }
private FlowBuilder createtablemiss() { final FlowBuilder flow = new FlowBuilder(); final long id = 456; final MatchBuilder matchBuilder = new MatchBuilder(); flow.setMatch(matchBuilder.build()); flow.setInstructions(createSentToControllerInstructions().build()); flow.setPriority(0); flow.setTableId((short) 0); final FlowKey key = new FlowKey(new FlowId(Long.toString(id))); flow.setKey(key); testFlow = flow; return flow; }
/** * Create a new apply action that contains the specified MD-SAL action * list. * * @param actions A list of MD-SAL actions. * @return An {@link Instructions} instance. */ public static Instructions newInstructions(List<Action> actions) { ApplyActionsCase apply = new ApplyActionsCaseBuilder(). setApplyActions(new ApplyActionsBuilder(). setAction(actions).build()). build(); Instruction inst = new InstructionBuilder(). setOrder(MiscUtils.ORDER_MIN).setInstruction(apply).build(); return new InstructionsBuilder(). setInstruction(Collections.singletonList(inst)).build(); }
private Flow createArpReplyToControllerFlow(final ArpMessageAddress senderAddress, final Ipv4Address ipForRequestedMac) { checkNotNull(senderAddress); checkNotNull(ipForRequestedMac); FlowBuilder arpFlow = new FlowBuilder().setTableId(Service.CLASSIFIER.getTable()) .setFlowName(ARP_REPLY_TO_CONTROLLER_FLOW_NAME) .setPriority(ARP_REPLY_TO_CONTROLLER_FLOW_PRIORITY) .setBufferId(OFConstants.OFP_NO_BUFFER) .setIdleTimeout(0) .setHardTimeout(0) .setCookie(new FlowCookie(BigInteger.valueOf(flowCookie.incrementAndGet()))) .setFlags(new FlowModFlags(false, false, false, false, false)); EthernetMatch ethernetMatch = ArpFlowFactory.createEthernetMatch(senderAddress.getHardwareAddress()); ArpMatch arpMatch = ArpFlowFactory.createArpMatch(senderAddress, ipForRequestedMac); Match match = new MatchBuilder().setEthernetMatch(ethernetMatch).setLayer3Match(arpMatch).build(); arpFlow.setMatch(match); arpFlow.setInstructions(new InstructionsBuilder().setInstruction( ImmutableList.of(SEND_TO_CONTROLLER_INSTRUCTION)).build()); arpFlow.setId(createFlowId(ipForRequestedMac)); return arpFlow.build(); }
private static Instructions makeStaticDropActionInstructions() { // Create an DropAction final DropActionCase dropAction = new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build(); // Create an Action final Action ab = new ActionBuilder().setOrder(0).setAction(dropAction).build(); // Create an Apply Action final ApplyActions aab = new ApplyActionsBuilder().setAction(Collections.singletonList(ab)).build(); // Wrap our Apply Action in an Instruction final Instruction ib = new InstructionBuilder() .setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab).build()).setOrder(0).build(); // Put our Instruction in a list of Instructions return new InstructionsBuilder().setInstruction(Collections.singletonList(ib)).build(); }
private Flow createArpReplyToControllerFlow(ArpMessageAddress senderAddress, Ipv4Address ipForRequestedMac, NodeConnectorId inPort) { checkNotNull(senderAddress); checkNotNull(ipForRequestedMac); FlowBuilder arpFlow = new FlowBuilder().setTableId(TABEL_FOR_ARP_FLOW) .setFlowName(ARP_REPLY_TO_CONTROLLER_FLOW_NAME) .setPriority(ARP_REPLY_TO_CONTROLLER_FLOW_PRIORITY) .setBufferId(OFConstants.OFP_NO_BUFFER) .setIdleTimeout(0) .setHardTimeout(0) .setFlags(new FlowModFlags(false, false, false, false, false)); EthernetMatch ethernetMatch = ArpFlowFactory.createEthernetMatch(); ArpMatch arpMatch = ArpFlowFactory.createArpMatch(senderAddress, ipForRequestedMac); Match match = new MatchBuilder().setEthernetMatch(ethernetMatch).setLayer3Match(arpMatch).setInPort(inPort).build(); arpFlow.setMatch(match); arpFlow.setInstructions(new InstructionsBuilder().setInstruction( ImmutableList.of(SEND_TO_CONTROLLER_INSTRUCTION)).build()); arpFlow.setId(createFlowId(ethernetMatch, arpMatch)); return arpFlow.build(); }
@Override public void programSfcTable(long dataPathId, long vxGpeOfPort, short goToTableId, boolean write) { NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId); FlowBuilder flowBuilder = new FlowBuilder(); String flowName = FlowNames.getSfcTable(vxGpeOfPort); initFlowBuilder(flowBuilder, flowName, getTable(Service.CLASSIFIER), FlowID.FLOW_SFCTABLE) .setPriority(1000); MatchBuilder matchBuilder = new MatchBuilder(); MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort); flowBuilder.setMatch(matchBuilder.build()); if (write) { InstructionsBuilder isb = new InstructionsBuilder(); List<Instruction> instructions = Lists.newArrayList(); InstructionBuilder ib = InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), goToTableId); ib.setOrder(0); ib.setKey(new InstructionKey(0)); instructions.add(ib.build()); isb.setInstruction(instructions); flowBuilder.setInstructions(isb.build()); writeFlow(flowBuilder, nodeBuilder); } else { removeFlow(flowBuilder, nodeBuilder); } }