@Test public void createL3PrefixFlow_externalIpv6() throws Exception { NodeConnectorId connectorId = new NodeConnectorId(OPENFLOW + CONNECTOR_0.getValue()); EndpointBuilder gatewayEpBuilder = buildEndpoint(IPV6_1, MAC_0, connectorId); gatewayEpBuilder.setNetworkContainment(SUBNET_0); OfOverlayContextBuilder ofOverlayContextBuilder = new OfOverlayContextBuilder(); ofOverlayContextBuilder.setNodeConnectorId(new NodeConnectorId(OPENFLOW + CONNECTOR_1)); gatewayEpBuilder.addAugmentation(OfOverlayContext.class, ofOverlayContextBuilder.build()); gatewayEpBuilder.setEndpointGroup(ENDPOINT_GROUP_0); TenantBuilder tenantBuilder = new TenantBuilder(getTestIndexedTenant().getTenant()); List<ExternalImplicitGroup> externalImplicitGroups = new ArrayList<>(); ExternalImplicitGroupBuilder externalImplicitGroupBuilder = new ExternalImplicitGroupBuilder(); externalImplicitGroupBuilder.setId(ENDPOINT_GROUP_0); externalImplicitGroups.add(externalImplicitGroupBuilder.build()); tenantBuilder.setPolicy(new PolicyBuilder().setExternalImplicitGroup(externalImplicitGroups).build()); IndexedTenant tenant = new IndexedTenant(tenantBuilder.build()); SubnetBuilder localSubnetBuilder = new SubnetBuilder(); localSubnetBuilder.setId(SUBNET_0); localSubnetBuilder.setVirtualRouterIp(new IpAddress(IPV6_2)); localSubnetBuilder.setParent(L2FD_ID); Subnet localSubnet = localSubnetBuilder.build(); Set<NodeConnectorId> externalPorts = new HashSet<>(); externalPorts.add(new NodeConnectorId(OPENFLOW + CONNECTOR_0.getValue())); externalPorts.add(new NodeConnectorId(OPENFLOW + CONNECTOR_1.getValue())); EndpointL3PrefixBuilder l3PrefixBuilder = new EndpointL3PrefixBuilder(); l3PrefixBuilder.setIpPrefix(new IpPrefix(new Ipv6Prefix(IPV6_1.getValue() + IP_PREFIX_128))); EndpointL3Prefix l3Prefix = l3PrefixBuilder.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(0))); 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, IPv6)); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) 5)); Match match = matchBuilder.build(); Integer prefixLength = Integer.valueOf(l3Prefix.getIpPrefix().getIpv6Prefix().getValue().split("/")[1]); Flow flow = buildFlow(FlowIdUtils.newFlowId(tableId, "L3prefix", match), tableId, 30 + prefixLength, match, instructionsBuilder.build()).build(); flows.createL3PrefixFlow(tableId, 30, gatewayEpBuilder.build(), l3Prefix, tenant, localSubnet, externalPorts, 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);   }