@Test public void createExternalL2Flow() { EndpointBuilder endpointBuilder = buildEndpoint(IPV4_0, MAC_0, CONNECTOR_0); Set<NodeConnectorId> externalConnectors = new HashSet<>(); externalConnectors.add(new NodeConnectorId(OPENFLOW + CONNECTOR_0.getValue())); externalConnectors.add(new NodeConnectorId(OPENFLOW + CONNECTOR_1.getValue())); Endpoint endpoint = endpointBuilder.setTenant(tenant.getId()).build(); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, endpoint.getMacAddress(), null)); OrdinalFactory.EndpointFwdCtxOrdinals ord = utils.getEndpointOrdinals(endpoint); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg4.class, (long) ord.getBdId())); Match match = matchBuilder.build(); List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(1))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(0))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(0))); 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(tableId)).build(); ArrayList<Instruction> instructions = new ArrayList<>(); instructions.add(applyActionsIns); instructions.add(gotoTable); InstructionsBuilder instructionsBuilder = new InstructionsBuilder(); instructionsBuilder.setInstruction(instructions); FlowId flowId = FlowIdUtils.newFlowId(tableId, "externalL2", match); Flow flow = buildFlow(flowId, tableId, 100, match, instructionsBuilder.build()).build(); flows.createExternalL2Flow(tableId, 100, endpointBuilder.build(), externalConnectors, ofWriter); verify(ofWriter, times(1)).writeFlow(eq(NODE_ID), eq(tableId), eq(flow)); }
void createExternalL2Flow(short goToTable, int priority, Endpoint peerEndpoint, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, peerEndpoint.getMacAddress(), null)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg4.class, (long) peerOrdinals.getBdId())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL2Flow(goToTable, priority, peerOrdinals, port, match, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } }
DestinationMapperFlows { void createExternalL2Flow(short goToTable, int priority, Endpoint peerEndpoint, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, peerEndpoint.getMacAddress(), null)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg4.class, (long) peerOrdinals.getBdId())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL2Flow(goToTable, priority, peerOrdinals, port, match, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } }
DestinationMapperFlows { void createExternalL2Flow(short goToTable, int priority, Endpoint peerEndpoint, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, peerEndpoint.getMacAddress(), null)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg4.class, (long) peerOrdinals.getBdId())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL2Flow(goToTable, priority, peerOrdinals, port, match, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId); }
DestinationMapperFlows { void createExternalL2Flow(short goToTable, int priority, Endpoint peerEndpoint, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, peerEndpoint.getMacAddress(), null)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg4.class, (long) peerOrdinals.getBdId())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL2Flow(goToTable, priority, peerOrdinals, port, match, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);  }
DestinationMapperFlows { void createExternalL2Flow(short goToTable, int priority, Endpoint peerEndpoint, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, peerEndpoint.getMacAddress(), null)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg4.class, (long) peerOrdinals.getBdId())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL2Flow(goToTable, priority, peerOrdinals, port, match, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);   }