/** * Convert the ACL into an OpenFlow {@link MatchBuilder} * @return {@link MatchBuilder} */ //TODO: Matches will overwrite previous matches for ethernet and ip since these methods // can be called successively for the same ACL. // This requires fixing the MatchUtils to preserve previously set fields. protected MatchBuilder buildMatch() { if (matches.getAceType() instanceof AceEth) { addEthMatch(); } else if (matches.getAceType() instanceof AceIp) { addIpMatch(); } LOG.info("buildMatch: {}", matchBuilder.build()); return matchBuilder; }
/** * Creates a flowBuilder. * @param flowName the flow name * @param priority the priority * @param matchBuilder the match builder * @param tableNo the table no to which flow needs to be inserted. * @return the created flow builder. */ public static FlowBuilder createFlowBuilder(String flowName,Integer priority, MatchBuilder matchBuilder, short tableNo) { FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(matchBuilder.build()); initFlowBuilder(flowBuilder, flowName, tableNo).setPriority(priority); return flowBuilder; } /**
@Override public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(data.getVersion()); final SetFieldAction setFieldAction = source.getSetFieldAction(); final SetFieldBuilder setField = new SetFieldBuilder(); final Optional<MatchBuilder> matchOptional = convertorExecutor.convert(setFieldAction, datapathIdConvertorData); setField.fieldsFrom(matchOptional.orElse(new MatchBuilder()).build()); return Optional.of(new SetFieldCaseBuilder().setSetField(setField.build()).build()); } }
public static FlowBuilder getPipelineFlow(short table, short gotoTable) { FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(new MatchBuilder().build()); String flowName = "DEFAULT_PIPELINE_FLOW_" + table; return initFlowBuilder(flowBuilder, flowName, table) .setPriority(0); }
private Flow buildIngressExternalIpFlow(short goToTable, IpAddress srcIpAddress, int priority, OrdinalFactory.EndpointFwdCtxOrdinals epFwdCtxOrdinals) { MatchBuilder mb = createMatchOnIpAddress(srcIpAddress, true); if (mb == null) { return null; } FlowBuilder flowBuilder = base(tableId).setPriority(priority) .setId(FlowIdUtils.newFlowId(tableId, "inbound-external-ip", mb.build())) .setMatch(mb.build()) .setInstructions( instructions(applyActionIns(createEpFwdCtxActions(epFwdCtxOrdinals)), gotoTableIns(goToTable))); return flowBuilder.build(); }
private FlowBuilder createBaseFlowForPortMatch(NodeConnector nc) { FlowBuilder floodFlow = new FlowBuilder().setTableId(flowTableId).setFlowName("flood"); floodFlow.setId(new FlowId(Long.toString(floodFlow.hashCode()))); Match match = new MatchBuilder().setInPort(nc.getId()).build(); floodFlow.setMatch(match) // .setPriority(flowPriority) // .setBufferId(OFConstants.OFP_NO_BUFFER) // .setHardTimeout(flowHardTimeout) // .setIdleTimeout(flowIdleTimeout) // .setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement()))) .setFlags(new FlowModFlags(false, false, false, false, false)); return floodFlow; }
private Flow buildIngressExternalArpFlow(short goToTable, MacAddress srcMacAddress, int priority, OrdinalFactory.EndpointFwdCtxOrdinals epFwdCtxOrdinals) { if (srcMacAddress == null) { return null; } MatchBuilder mb = new MatchBuilder() .setEthernetMatch(ethernetMatch(srcMacAddress, null, ARP)); FlowBuilder flowBuilder = base(tableId).setPriority(priority); flowBuilder.setInstructions(instructions(applyActionIns(createEpFwdCtxActions(epFwdCtxOrdinals)), gotoTableIns(goToTable))); flowBuilder.setId(FlowIdUtils.newFlowId(tableId, "inbound-external-arp", mb.build())); flowBuilder.setMatch(mb.build()); return flowBuilder.build(); }
/** * Get a base flow builder with some common features already set * * @return {@link FlowBuilder} */ protected FlowBuilder base() { return new FlowBuilder() .setTableId(getTableId()) .setBarrier(false) .setHardTimeout(0) .setIdleTimeout(0) .setMatch(new MatchBuilder().build()); }
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; }
private Flow createArpFlow(Integer fdId) { Long etherType = FlowUtils.ARP; // L2 Classifier so 20,000 for now Integer priority = 20000; MatchBuilder mb = new MatchBuilder().setEthernetMatch(FlowUtils.ethernetMatch(null, null, etherType)); addNxRegMatch(mb, RegMatch.of(NxmNxReg5.class, Long.valueOf(fdId))); Match match = mb.build(); FlowId flowid = FlowIdUtils.newFlowId(TABLE_ID, "arp", match); return base().setPriority(priority) .setId(flowid) .setMatch(match) .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class)))) .build(); }
private FlowBuilder createFlowBuilder(final MatchBuilder matchBuilder) { final Match match = matchBuilder.build(); final FlowId flowId = new FlowId(flowName); final FlowKey key = new FlowKey(flowId); final FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(match); flowBuilder.setId(flowId); flowBuilder.setKey(key); flowBuilder.setBarrier(true); flowBuilder.setPriority(OFRendererConstants.DEFAULT_PRIORITY); flowBuilder.setFlowName(flowName); flowBuilder.setHardTimeout(OFRendererConstants.DEFAULT_HARD_TIMEOUT); flowBuilder.setIdleTimeout(OFRendererConstants.DEFAULT_IDLE_TIMEOUT); return flowBuilder; }
/** * Allow untagged frames enter policy domain. Packets are sent to ingress NAT table * * @param goToTable tableId for goToTable instruction * @param connectorId should be external for now * @param priority of flow in the table * @param ofWriter flow writer */ void allowFromExternalPortFlow(short goToTable, NodeConnectorId connectorId, int priority, OfWriter ofWriter) { Match match = new MatchBuilder().setInPort(connectorId).build(); FlowId flowid = FlowIdUtils.newFlowId(tableId, "allowExternal", match); FlowBuilder flowBuilder = FlowUtils.base(tableId).setId(flowid) .setPriority(priority) .setMatch(match) .setInstructions(FlowUtils.gotoTableInstructions(goToTable)); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); }
private Flow allowFromTunnel(NodeConnectorId tunPort) { MatchBuilder mb = new MatchBuilder().setInPort(tunPort); addNxRegMatch(mb, RegMatch.of(NxmNxReg1.class, 0xffffffL)); Match match = mb.build(); FlowId flowId = FlowIdUtils.newFlowId(TABLE_ID, "tunnelallow", match); FlowBuilder flow = base().setId(flowId).setMatch(match).setPriority(65000).setInstructions( instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class)))); return flow.build(); }
public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match toMatch( Match sourceMatch) { if (sourceMatch != null) { MatchBuilder targetBuilder = new MatchBuilder(); targetBuilder.setEthernetMatch(ethernetMatch(sourceMatch)); targetBuilder.setIpMatch(ipMatch(sourceMatch)); targetBuilder.setVlanMatch(vlanMatch(sourceMatch)); targetBuilder.setLayer3Match(layer3Match(sourceMatch)); targetBuilder.setLayer4Match(layer4Match(sourceMatch)); targetBuilder.setInPort(inPortMatch(sourceMatch)); return targetBuilder.build(); } return null; }
private Flow allowSameEpg(int epgId) { MatchBuilder mb = new MatchBuilder(); addNxRegMatch(mb, RegMatch.of(NxmNxReg0.class, (long) epgId), RegMatch.of(NxmNxReg2.class, (long) epgId)); Match match = mb.build(); FlowId flowId = FlowIdUtils.newFlowId(TABLE_ID, "intraallow", match); FlowBuilder flow = base().setId(flowId).setMatch(match).setPriority(65000).setInstructions( instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class)))); return flow.build(); }
private FlowBuilder createFlowBuilder(List<String> endPointGroups, MatchBuilder matchBuilder) { final Match match = matchBuilder.build(); // Flow named for convenience and uniqueness String flowName = createRedirectFlowName(endPointGroups); final FlowId flowId = new FlowId(flowName); final FlowKey key = new FlowKey(flowId); final FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(match); flowBuilder.setId(flowId); flowBuilder.setKey(key); flowBuilder.setBarrier(true); flowBuilder.setPriority(OFRendererConstants.DEFAULT_PRIORITY); flowBuilder.setFlowName(flowName); flowBuilder.setHardTimeout(OFRendererConstants.DEFAULT_HARD_TIMEOUT); flowBuilder.setIdleTimeout(OFRendererConstants.DEFAULT_IDLE_TIMEOUT); return flowBuilder; }
private FlowBuilder createFlowBuilder(MatchBuilder matchBuilder) { final Match match = matchBuilder.build(); // Flow named for convenience and uniqueness String flowName = createFlowName(); final FlowId flowId = new FlowId(flowName); final FlowKey key = new FlowKey(flowId); final FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(match); flowBuilder.setId(flowId); flowBuilder.setKey(key); flowBuilder.setBarrier(true); flowBuilder.setPriority(OFRendererConstants.DEFAULT_PRIORITY); flowBuilder.setFlowName(flowName); flowBuilder.setHardTimeout(OFRendererConstants.DEFAULT_HARD_TIMEOUT); flowBuilder.setIdleTimeout(OFRendererConstants.DEFAULT_IDLE_TIMEOUT); return flowBuilder; }
private FlowBuilder createFlowBuilder(MatchBuilder matchBuilder) { final Match match = matchBuilder.build(); // Flow named for convenience and uniqueness String flowName = createFlowName(); final FlowId flowId = new FlowId(flowName); final FlowKey key = new FlowKey(flowId); final FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(match); flowBuilder.setId(flowId); flowBuilder.setKey(key); flowBuilder.setBarrier(true); flowBuilder.setPriority(OFRendererConstants.DEFAULT_PRIORITY); flowBuilder.setFlowName(flowName); flowBuilder.setHardTimeout(OFRendererConstants.DEFAULT_HARD_TIMEOUT); flowBuilder.setIdleTimeout(OFRendererConstants.DEFAULT_IDLE_TIMEOUT); return flowBuilder; }
private static Flow allowFromChainTunnel(NodeConnectorId tunPort, short tableId) { MatchBuilder mb = new MatchBuilder().setInPort(tunPort); addNxRegMatch(mb, RegMatch.of(NxmNxReg1.class, 0xffffffL)); Match match = mb.build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "chainport", match); FlowBuilder flow = base(tableId).setId(flowId).setMatch(match).setPriority(65000).setInstructions( instructions(applyActionIns(nxPopNshAction(), nxOutputRegAction(NxmNxReg7.class)))); return flow.build(); }
private static Flow allowFromChainPort(SfcNshHeader sfcNshHeader, NodeConnectorId port, short tableId, OfContext ctx) { // Matching on last NSP/NSI that SFF leaves on but with C1=0 MatchBuilder mb = new MatchBuilder(); FlowUtils.addNxNshc1RegMatch(mb, 0L); FlowUtils.addNxNsiMatch(mb, sfcNshHeader.getNshNsiFromChain()); FlowUtils.addNxNspMatch(mb, sfcNshHeader.getNshNspFromChain()); Match match = mb.setInPort(port).build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "chainport", match); FlowBuilder flowb = base(tableId).setId(flowId).setPriority(1200).setMatch(match).setInstructions( FlowUtils.gotoTableInstructions(ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER())); return flowb.build(); }