@Test public void createL3PrefixFlow_internalIpV4() { NodeConnectorId connectorId = new NodeConnectorId(OPENFLOW + CONNECTOR_0.getValue()); EndpointBuilder gatewayEp = buildEndpoint(IPV4_0, MAC_0, connectorId); OfOverlayContextBuilder ofOverlayContextBuilder = new OfOverlayContextBuilder(); ofOverlayContextBuilder.setNodeConnectorId(new NodeConnectorId(OPENFLOW + CONNECTOR_1.getValue())); gatewayEp.addAugmentation(OfOverlayContext.class, ofOverlayContextBuilder.build()); EndpointL3PrefixBuilder l3PrefixBuilder = new EndpointL3PrefixBuilder(); l3PrefixBuilder.setIpPrefix(new IpPrefix(new Ipv4Prefix(IPV4_0.getValue() + IP_PREFIX_32))); EndpointL3Prefix l3Prefix = l3PrefixBuilder.build(); IndexedTenant tenant = getTestIndexedTenant(); SubnetBuilder localSubnetBuilder = new SubnetBuilder(); localSubnetBuilder.setId(SUBNET_0); localSubnetBuilder.setParent(L2FD_ID); localSubnetBuilder.setVirtualRouterIp(new IpAddress(IPV4_0)); Subnet localSubnet = localSubnetBuilder.build(); List<Action> l3ApplyActions = new ArrayList<>(); l3ApplyActions.add(setDlDstAction(MAC_0)); l3ApplyActions.add(decNwTtlAction()); 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(1))); applyActions.addAll(l3ApplyActions); Instruction applyActionsIns = new InstructionBuilder().setOrder(0) .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()]))) .build(); Instruction gotoTable = new InstructionBuilder().setOrder(1).setInstruction(gotoTableIns(tableId)).build(); ArrayList<Instruction> l3instructions = new ArrayList<>(); l3instructions.add(applyActionsIns); l3instructions.add(gotoTable); InstructionsBuilder instructionsBuilder = new InstructionsBuilder(); instructionsBuilder.setInstruction(l3instructions); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, DestinationMapper.ROUTER_MAC, IPv4)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) 5)); Match match = matchBuilder.build(); Integer prefixLength = Integer.valueOf(l3Prefix.getIpPrefix().getIpv4Prefix().getValue().split("/")[1]); Flow flow = buildFlow(FlowIdUtils.newFlowId(tableId, "L3prefix", match), tableId, 30 + prefixLength, match, instructionsBuilder.build()).build(); flows.createL3PrefixFlow(tableId, 30, gatewayEp.build(), l3Prefix, tenant, localSubnet, null, ofWriter); verify(ofWriter, times(1)).writeFlow(any(NodeId.class), anyShort(), eq(flow)); }
void createL3PrefixFlow(short goToTable, int priority, Endpoint gatewayEp, EndpointL3Prefix l3Prefix, IndexedTenant tenant, Subnet localSubnet, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { L3Context l3Context = utils.getL3ContextForSubnet(tenant, localSubnet); if (l3Context != null && localSubnet.getVirtualRouterIp() != null) { MacAddress matcherMacAddress = utils.routerPortMac(l3Context, localSubnet.getVirtualRouterIp(), tenant.getTenant().getId()); OfOverlayContext context = gatewayEp.getAugmentation(OfOverlayContext.class); if (EndpointManager.isInternal(gatewayEp, tenant.getExternalImplicitGroups())) { Preconditions.checkNotNull(context.getNodeConnectorId()); try { Long port = getOfPortNum(context.getNodeConnectorId()); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", context.getNodeConnectorId()); } } else { for (NodeConnectorId externalPort : externalPorts) { try { Long port = getOfPortNum(externalPort); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", externalPort); } } } } }
DestinationMapperFlows { void createL3PrefixFlow(short goToTable, int priority, Endpoint gatewayEp, EndpointL3Prefix l3Prefix, IndexedTenant tenant, Subnet localSubnet, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { L3Context l3Context = utils.getL3ContextForSubnet(tenant, localSubnet); if (l3Context != null && localSubnet.getVirtualRouterIp() != null) { MacAddress matcherMacAddress = utils.routerPortMac(l3Context, localSubnet.getVirtualRouterIp(), tenant.getTenant().getId()); OfOverlayContext context = gatewayEp.getAugmentation(OfOverlayContext.class); if (EndpointManager.isInternal(gatewayEp, tenant.getExternalImplicitGroups())) { Preconditions.checkNotNull(context.getNodeConnectorId()); try { Long port = getOfPortNum(context.getNodeConnectorId()); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", context.getNodeConnectorId()); } } else { for (NodeConnectorId externalPort : externalPorts) { try { Long port = getOfPortNum(externalPort); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", externalPort); } } } } } }
DestinationMapperFlows { void createL3PrefixFlow(short goToTable, int priority, Endpoint gatewayEp, EndpointL3Prefix l3Prefix, IndexedTenant tenant, Subnet localSubnet, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { L3Context l3Context = utils.getL3ContextForSubnet(tenant, localSubnet); if (l3Context != null && localSubnet.getVirtualRouterIp() != null) { MacAddress matcherMacAddress = utils.routerPortMac(l3Context, localSubnet.getVirtualRouterIp(), tenant.getTenant().getId()); OfOverlayContext context = gatewayEp.getAugmentation(OfOverlayContext.class); if (EndpointManager.isInternal(gatewayEp, tenant.getExternalImplicitGroups())) { Preconditions.checkNotNull(context.getNodeConnectorId()); try { Long port = getOfPortNum(context.getNodeConnectorId()); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", context.getNodeConnectorId()); } } else { for (NodeConnectorId externalPort : externalPorts) { try { Long port = getOfPortNum(externalPort); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", externalPort); } } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId); }
DestinationMapperFlows { void createL3PrefixFlow(short goToTable, int priority, Endpoint gatewayEp, EndpointL3Prefix l3Prefix, IndexedTenant tenant, Subnet localSubnet, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { L3Context l3Context = utils.getL3ContextForSubnet(tenant, localSubnet); if (l3Context != null && localSubnet.getVirtualRouterIp() != null) { MacAddress matcherMacAddress = utils.routerPortMac(l3Context, localSubnet.getVirtualRouterIp(), tenant.getTenant().getId()); OfOverlayContext context = gatewayEp.getAugmentation(OfOverlayContext.class); if (EndpointManager.isInternal(gatewayEp, tenant.getExternalImplicitGroups())) { Preconditions.checkNotNull(context.getNodeConnectorId()); try { Long port = getOfPortNum(context.getNodeConnectorId()); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", context.getNodeConnectorId()); } } else { for (NodeConnectorId externalPort : externalPorts) { try { Long port = getOfPortNum(externalPort); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", externalPort); } } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);  }
DestinationMapperFlows { void createL3PrefixFlow(short goToTable, int priority, Endpoint gatewayEp, EndpointL3Prefix l3Prefix, IndexedTenant tenant, Subnet localSubnet, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { L3Context l3Context = utils.getL3ContextForSubnet(tenant, localSubnet); if (l3Context != null && localSubnet.getVirtualRouterIp() != null) { MacAddress matcherMacAddress = utils.routerPortMac(l3Context, localSubnet.getVirtualRouterIp(), tenant.getTenant().getId()); OfOverlayContext context = gatewayEp.getAugmentation(OfOverlayContext.class); if (EndpointManager.isInternal(gatewayEp, tenant.getExternalImplicitGroups())) { Preconditions.checkNotNull(context.getNodeConnectorId()); try { Long port = getOfPortNum(context.getNodeConnectorId()); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", context.getNodeConnectorId()); } } else { for (NodeConnectorId externalPort : externalPorts) { try { Long port = getOfPortNum(externalPort); if(matcherMacAddress != null) { writeL3PrefixFlow(priority, goToTable, gatewayEp, l3Prefix, port, matcherMacAddress, ofWriter); } } catch (NumberFormatException e) { LOG.warn("Could not parse port number {}", externalPort); } } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);   }