@Test public void testIngressExternalNatFlow() throws Exception { Endpoint testEndpoint = buildEndpoint(IPV4_1, MAC_0, CONNECTOR_0).build(); when(ctx.getEndpointManager()).thenReturn(endpointManager); when(ctx.getTenant(Mockito.any(TenantId.class))).thenReturn(getTestIndexedTenant()); when(ctx.getCurrentPolicy()).thenReturn(policyInfo); OrdinalFactory.EndpointFwdCtxOrdinals ordinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, testEndpoint); InOrder order = inOrder(ctx); order.verify(ctx, times(1)).getEndpointManager(); order.verify(ctx, times(1)).getCurrentPolicy(); verify(ctx, times(3)).getTenant(TENANT_ID); assertNotNull(ordinals); List<Instruction> instructions = new ArrayList<>(); Action[] ordinalsAction = {FlowUtils.nxLoadRegAction(NxmNxReg0.class, BigInteger.valueOf(1)), FlowUtils.nxLoadRegAction(NxmNxReg1.class, BigInteger.valueOf(0)), FlowUtils.nxLoadRegAction(NxmNxReg4.class, BigInteger.valueOf(3)), FlowUtils.nxLoadRegAction(NxmNxReg5.class, BigInteger.valueOf(4)), FlowUtils.nxLoadRegAction(NxmNxReg6.class, BigInteger.valueOf(5)), FlowUtils.nxLoadTunIdAction(BigInteger.valueOf(ordinals.getTunnelId()), false)}; instructions.add(new InstructionBuilder().setOrder(0) .setInstruction(FlowUtils.applyActionIns(ArrayUtils.addAll(ordinalsAction))).build()); instructions.add(new InstructionBuilder().setOrder(1).setInstruction(FlowUtils.gotoTableIns((short) 2)).build()); InstructionsBuilder instructionsBuilder = new InstructionsBuilder(); instructionsBuilder.setInstruction(instructions); MatchBuilder matchBuilder = new MatchBuilder(); matchBuilder.setEthernetMatch(FlowUtils.ethernetMatch(null, null, FlowUtils.IPv4)); matchBuilder.setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(IPV4_1.getValue() + IP_PREFIX_32)).build()); Match match = matchBuilder.build(); Flow testFlow = buildFlow(FlowIdUtils.newFlowId(tableId, "inbound-external-ip", match), tableId, 50, match, instructionsBuilder.build()).build(); flows.createIngressExternalNatFlows((short) 2, testEndpoint, ordinals, 50, ofWriter); verify(ofWriter, times(1)).writeFlow(NODE_ID, tableId, testFlow); }
void createIngressExternalNatFlows(short goToTable, Endpoint endpoint, OrdinalFactory.EndpointFwdCtxOrdinals endpointFwdCtxOrdinals, int priority, OfWriter ofWriter) { if (endpoint.getL3Address() != null) { for (L3Address l3Address : endpoint.getL3Address()) { Flow ipFlow = buildIngressExternalIpFlow(goToTable, l3Address.getIpAddress(), priority, endpointFwdCtxOrdinals); if (ipFlow != null) { ofWriter.writeFlow(nodeId, tableId, ipFlow); } } } }
IngressNatMapperFlows { void createIngressExternalNatFlows(short goToTable, Endpoint endpoint, OrdinalFactory.EndpointFwdCtxOrdinals endpointFwdCtxOrdinals, int priority, OfWriter ofWriter) { if (endpoint.getL3Address() != null) { for (L3Address l3Address : endpoint.getL3Address()) { Flow ipFlow = buildIngressExternalIpFlow(goToTable, l3Address.getIpAddress(), priority, endpointFwdCtxOrdinals); if (ipFlow != null) { ofWriter.writeFlow(nodeId, tableId, ipFlow); } } } } }
IngressNatMapperFlows { void createIngressExternalNatFlows(short goToTable, Endpoint endpoint, OrdinalFactory.EndpointFwdCtxOrdinals endpointFwdCtxOrdinals, int priority, OfWriter ofWriter) { if (endpoint.getL3Address() != null) { for (L3Address l3Address : endpoint.getL3Address()) { Flow ipFlow = buildIngressExternalIpFlow(goToTable, l3Address.getIpAddress(), priority, endpointFwdCtxOrdinals); if (ipFlow != null) { ofWriter.writeFlow(nodeId, tableId, ipFlow); } } } } IngressNatMapperFlows(NodeId nodeId, short tableId); }
IngressNatMapperFlows { void createIngressExternalNatFlows(short goToTable, Endpoint endpoint, OrdinalFactory.EndpointFwdCtxOrdinals endpointFwdCtxOrdinals, int priority, OfWriter ofWriter) { if (endpoint.getL3Address() != null) { for (L3Address l3Address : endpoint.getL3Address()) { Flow ipFlow = buildIngressExternalIpFlow(goToTable, l3Address.getIpAddress(), priority, endpointFwdCtxOrdinals); if (ipFlow != null) { ofWriter.writeFlow(nodeId, tableId, ipFlow); } } } } IngressNatMapperFlows(NodeId nodeId, short tableId);  }
IngressNatMapperFlows { void createIngressExternalNatFlows(short goToTable, Endpoint endpoint, OrdinalFactory.EndpointFwdCtxOrdinals endpointFwdCtxOrdinals, int priority, OfWriter ofWriter) { if (endpoint.getL3Address() != null) { for (L3Address l3Address : endpoint.getL3Address()) { Flow ipFlow = buildIngressExternalIpFlow(goToTable, l3Address.getIpAddress(), priority, endpointFwdCtxOrdinals); if (ipFlow != null) { ofWriter.writeFlow(nodeId, tableId, ipFlow); } } } } IngressNatMapperFlows(NodeId nodeId, short tableId);   }