@Test public void createRemoteL3RoutedFlow_noL3Context() { EndpointBuilder endpointBuilder = buildEndpoint(IPV6_1, MAC_1, CONNECTOR_0); Endpoint endpoint = endpointBuilder.build(); flows.createRemoteL3RoutedFlow(tableId, 60, endpoint, null, null, null, null, null, ofWriter); verifyZeroInteractions(ofWriter); }
void createRemoteL3RoutedFlow(short goToTable, int priority, Endpoint endpoint, L3Address destL3Address, Subnet destSubnet, IpAddress tunDst, NodeConnectorId connectorId, Subnet localSubnet, OfWriter ofWriter) { L3Context context = utils.getL3ContextForSubnet(utils.getIndexedTenant(endpoint.getTenant()), destSubnet); if (context == null) { return; } OrdinalFactory.EndpointFwdCtxOrdinals ordinals = utils.getEndpointOrdinals(endpoint); MacAddress matcherMac = utils.routerPortMac(context, localSubnet.getVirtualRouterIp(), endpoint.getTenant()); MacAddress epDestMac = endpoint.getMacAddress(); if (matcherMac == null || epDestMac == null) { return; } MacAddress destSubnetGatewayMac = utils.routerPortMac(context, destSubnet.getVirtualRouterIp(), endpoint.getTenant()); List<Action> l3ApplyActions = new ArrayList<>(); if (localSubnet.getId().getValue().equals(destSubnet.getId().getValue())) { matcherMac = epDestMac; } if (!(matcherMac.getValue().equals(epDestMac.getValue()))) { Action setDlSrc = setDlSrcAction(destSubnetGatewayMac); l3ApplyActions.add(setDlSrc); } l3ApplyActions.add(setDlDstAction(epDestMac)); l3ApplyActions.add(decNwTtlAction()); Action tunnelDestinationAction; if (tunDst != null && tunDst.getIpv4Address() != null) { tunnelDestinationAction = nxLoadTunIPv4Action(tunDst.getIpv4Address().getValue(), false); } else if (tunDst != null && tunDst.getIpv6Address() != null) { LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(), nodeId); return; } else { LOG.error("Tunnel IP for {} invalid", nodeId); return; } long port; try { port = getOfPortNum(connectorId); } catch (NumberFormatException ex) { LOG.warn("Could not parse port number {}", connectorId, ex); return; } List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(ordinals.getEpgId()))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(ordinals.getCgId()))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(port))); applyActions.add(tunnelDestinationAction); applyActions.addAll(l3ApplyActions); 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(goToTable)) .build(); ArrayList<Instruction> l3instructions = new ArrayList<>(); l3instructions.add(applyActionsIns); l3instructions.add(gotoTable); Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) ordinals.getL3Id())); Match match = matchBuilder.build(); FlowId flowid = FlowIdUtils.newFlowId(tableId, "remoteL3", match); FlowBuilder flowBuilder = base(tableId).setId(flowid) .setPriority(priority) .setMatch(match) .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build()); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); }
DestinationMapperFlows { void createRemoteL3RoutedFlow(short goToTable, int priority, Endpoint endpoint, L3Address destL3Address, Subnet destSubnet, IpAddress tunDst, NodeConnectorId connectorId, Subnet localSubnet, OfWriter ofWriter) { L3Context context = utils.getL3ContextForSubnet(utils.getIndexedTenant(endpoint.getTenant()), destSubnet); if (context == null) { return; } OrdinalFactory.EndpointFwdCtxOrdinals ordinals = utils.getEndpointOrdinals(endpoint); MacAddress matcherMac = utils.routerPortMac(context, localSubnet.getVirtualRouterIp(), endpoint.getTenant()); MacAddress epDestMac = endpoint.getMacAddress(); if (matcherMac == null || epDestMac == null) { return; } MacAddress destSubnetGatewayMac = utils.routerPortMac(context, destSubnet.getVirtualRouterIp(), endpoint.getTenant()); List<Action> l3ApplyActions = new ArrayList<>(); if (localSubnet.getId().getValue().equals(destSubnet.getId().getValue())) { matcherMac = epDestMac; } if (!(matcherMac.getValue().equals(epDestMac.getValue()))) { Action setDlSrc = setDlSrcAction(destSubnetGatewayMac); l3ApplyActions.add(setDlSrc); } l3ApplyActions.add(setDlDstAction(epDestMac)); l3ApplyActions.add(decNwTtlAction()); Action tunnelDestinationAction; if (tunDst != null && tunDst.getIpv4Address() != null) { tunnelDestinationAction = nxLoadTunIPv4Action(tunDst.getIpv4Address().getValue(), false); } else if (tunDst != null && tunDst.getIpv6Address() != null) { LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(), nodeId); return; } else { LOG.error("Tunnel IP for {} invalid", nodeId); return; } long port; try { port = getOfPortNum(connectorId); } catch (NumberFormatException ex) { LOG.warn("Could not parse port number {}", connectorId, ex); return; } List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(ordinals.getEpgId()))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(ordinals.getCgId()))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(port))); applyActions.add(tunnelDestinationAction); applyActions.addAll(l3ApplyActions); 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(goToTable)) .build(); ArrayList<Instruction> l3instructions = new ArrayList<>(); l3instructions.add(applyActionsIns); l3instructions.add(gotoTable); Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) ordinals.getL3Id())); Match match = matchBuilder.build(); FlowId flowid = FlowIdUtils.newFlowId(tableId, "remoteL3", match); FlowBuilder flowBuilder = base(tableId).setId(flowid) .setPriority(priority) .setMatch(match) .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build()); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } }
DestinationMapperFlows { void createRemoteL3RoutedFlow(short goToTable, int priority, Endpoint endpoint, L3Address destL3Address, Subnet destSubnet, IpAddress tunDst, NodeConnectorId connectorId, Subnet localSubnet, OfWriter ofWriter) { L3Context context = utils.getL3ContextForSubnet(utils.getIndexedTenant(endpoint.getTenant()), destSubnet); if (context == null) { return; } OrdinalFactory.EndpointFwdCtxOrdinals ordinals = utils.getEndpointOrdinals(endpoint); MacAddress matcherMac = utils.routerPortMac(context, localSubnet.getVirtualRouterIp(), endpoint.getTenant()); MacAddress epDestMac = endpoint.getMacAddress(); if (matcherMac == null || epDestMac == null) { return; } MacAddress destSubnetGatewayMac = utils.routerPortMac(context, destSubnet.getVirtualRouterIp(), endpoint.getTenant()); List<Action> l3ApplyActions = new ArrayList<>(); if (localSubnet.getId().getValue().equals(destSubnet.getId().getValue())) { matcherMac = epDestMac; } if (!(matcherMac.getValue().equals(epDestMac.getValue()))) { Action setDlSrc = setDlSrcAction(destSubnetGatewayMac); l3ApplyActions.add(setDlSrc); } l3ApplyActions.add(setDlDstAction(epDestMac)); l3ApplyActions.add(decNwTtlAction()); Action tunnelDestinationAction; if (tunDst != null && tunDst.getIpv4Address() != null) { tunnelDestinationAction = nxLoadTunIPv4Action(tunDst.getIpv4Address().getValue(), false); } else if (tunDst != null && tunDst.getIpv6Address() != null) { LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(), nodeId); return; } else { LOG.error("Tunnel IP for {} invalid", nodeId); return; } long port; try { port = getOfPortNum(connectorId); } catch (NumberFormatException ex) { LOG.warn("Could not parse port number {}", connectorId, ex); return; } List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(ordinals.getEpgId()))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(ordinals.getCgId()))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(port))); applyActions.add(tunnelDestinationAction); applyActions.addAll(l3ApplyActions); 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(goToTable)) .build(); ArrayList<Instruction> l3instructions = new ArrayList<>(); l3instructions.add(applyActionsIns); l3instructions.add(gotoTable); Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) ordinals.getL3Id())); Match match = matchBuilder.build(); FlowId flowid = FlowIdUtils.newFlowId(tableId, "remoteL3", match); FlowBuilder flowBuilder = base(tableId).setId(flowid) .setPriority(priority) .setMatch(match) .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build()); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId); }
DestinationMapperFlows { void createRemoteL3RoutedFlow(short goToTable, int priority, Endpoint endpoint, L3Address destL3Address, Subnet destSubnet, IpAddress tunDst, NodeConnectorId connectorId, Subnet localSubnet, OfWriter ofWriter) { L3Context context = utils.getL3ContextForSubnet(utils.getIndexedTenant(endpoint.getTenant()), destSubnet); if (context == null) { return; } OrdinalFactory.EndpointFwdCtxOrdinals ordinals = utils.getEndpointOrdinals(endpoint); MacAddress matcherMac = utils.routerPortMac(context, localSubnet.getVirtualRouterIp(), endpoint.getTenant()); MacAddress epDestMac = endpoint.getMacAddress(); if (matcherMac == null || epDestMac == null) { return; } MacAddress destSubnetGatewayMac = utils.routerPortMac(context, destSubnet.getVirtualRouterIp(), endpoint.getTenant()); List<Action> l3ApplyActions = new ArrayList<>(); if (localSubnet.getId().getValue().equals(destSubnet.getId().getValue())) { matcherMac = epDestMac; } if (!(matcherMac.getValue().equals(epDestMac.getValue()))) { Action setDlSrc = setDlSrcAction(destSubnetGatewayMac); l3ApplyActions.add(setDlSrc); } l3ApplyActions.add(setDlDstAction(epDestMac)); l3ApplyActions.add(decNwTtlAction()); Action tunnelDestinationAction; if (tunDst != null && tunDst.getIpv4Address() != null) { tunnelDestinationAction = nxLoadTunIPv4Action(tunDst.getIpv4Address().getValue(), false); } else if (tunDst != null && tunDst.getIpv6Address() != null) { LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(), nodeId); return; } else { LOG.error("Tunnel IP for {} invalid", nodeId); return; } long port; try { port = getOfPortNum(connectorId); } catch (NumberFormatException ex) { LOG.warn("Could not parse port number {}", connectorId, ex); return; } List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(ordinals.getEpgId()))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(ordinals.getCgId()))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(port))); applyActions.add(tunnelDestinationAction); applyActions.addAll(l3ApplyActions); 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(goToTable)) .build(); ArrayList<Instruction> l3instructions = new ArrayList<>(); l3instructions.add(applyActionsIns); l3instructions.add(gotoTable); Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) ordinals.getL3Id())); Match match = matchBuilder.build(); FlowId flowid = FlowIdUtils.newFlowId(tableId, "remoteL3", match); FlowBuilder flowBuilder = base(tableId).setId(flowid) .setPriority(priority) .setMatch(match) .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build()); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);  }
DestinationMapperFlows { void createRemoteL3RoutedFlow(short goToTable, int priority, Endpoint endpoint, L3Address destL3Address, Subnet destSubnet, IpAddress tunDst, NodeConnectorId connectorId, Subnet localSubnet, OfWriter ofWriter) { L3Context context = utils.getL3ContextForSubnet(utils.getIndexedTenant(endpoint.getTenant()), destSubnet); if (context == null) { return; } OrdinalFactory.EndpointFwdCtxOrdinals ordinals = utils.getEndpointOrdinals(endpoint); MacAddress matcherMac = utils.routerPortMac(context, localSubnet.getVirtualRouterIp(), endpoint.getTenant()); MacAddress epDestMac = endpoint.getMacAddress(); if (matcherMac == null || epDestMac == null) { return; } MacAddress destSubnetGatewayMac = utils.routerPortMac(context, destSubnet.getVirtualRouterIp(), endpoint.getTenant()); List<Action> l3ApplyActions = new ArrayList<>(); if (localSubnet.getId().getValue().equals(destSubnet.getId().getValue())) { matcherMac = epDestMac; } if (!(matcherMac.getValue().equals(epDestMac.getValue()))) { Action setDlSrc = setDlSrcAction(destSubnetGatewayMac); l3ApplyActions.add(setDlSrc); } l3ApplyActions.add(setDlDstAction(epDestMac)); l3ApplyActions.add(decNwTtlAction()); Action tunnelDestinationAction; if (tunDst != null && tunDst.getIpv4Address() != null) { tunnelDestinationAction = nxLoadTunIPv4Action(tunDst.getIpv4Address().getValue(), false); } else if (tunDst != null && tunDst.getIpv6Address() != null) { LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(), nodeId); return; } else { LOG.error("Tunnel IP for {} invalid", nodeId); return; } long port; try { port = getOfPortNum(connectorId); } catch (NumberFormatException ex) { LOG.warn("Could not parse port number {}", connectorId, ex); return; } List<Action> applyActions = new ArrayList<>(); applyActions.add(nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(ordinals.getEpgId()))); applyActions.add(nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(ordinals.getCgId()))); applyActions.add(nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(port))); applyActions.add(tunnelDestinationAction); applyActions.addAll(l3ApplyActions); 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(goToTable)) .build(); ArrayList<Instruction> l3instructions = new ArrayList<>(); l3instructions.add(applyActionsIns); l3instructions.add(gotoTable); Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) ordinals.getL3Id())); Match match = matchBuilder.build(); FlowId flowid = FlowIdUtils.newFlowId(tableId, "remoteL3", match); FlowBuilder flowBuilder = base(tableId).setId(flowid) .setPriority(priority) .setMatch(match) .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build()); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);   }