@Test public void createExternalL3RoutedFlow_nullIpAddress() { EndpointBuilder gatewayBuilder = buildEndpoint(IPV4_0, MAC_0, CONNECTOR_0); EndpointBuilder endpointBuilder = buildEndpoint(IPV4_1, MAC_1, CONNECTOR_1); Endpoint gateway = gatewayBuilder.build(); Endpoint endpoint = endpointBuilder.build(); L3AddressBuilder l3AddressBuilder = new L3AddressBuilder(); l3AddressBuilder.setIpAddress(null); Set<NodeConnectorId> externalConnectors = new HashSet<>(); externalConnectors.add(new NodeConnectorId(CONNECTOR_0)); externalConnectors.add(new NodeConnectorId(CONNECTOR_1)); flows.createExternalL3RoutedFlow(tableId, 90, endpoint, gateway, l3AddressBuilder.build(), externalConnectors, ofWriter); verifyZeroInteractions(ofWriter); }
void createExternalL3RoutedFlow(short goToTable, int priority, Endpoint peerEndpoint, Endpoint l2GatewayEp, L3Address destL3Address, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv6Address() != null) { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } else { LOG.error("Endpoint has Ip Address that is not recognised as either IPv4 or IPv6.", destL3Address); return; } MacAddress matcherMac = peerEndpoint.getMacAddress(); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) peerOrdinals.getL3Id())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL3RoutedFlow(goToTable, priority, port, l2GatewayEp, match, peerOrdinals, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } }
DestinationMapperFlows { void createExternalL3RoutedFlow(short goToTable, int priority, Endpoint peerEndpoint, Endpoint l2GatewayEp, L3Address destL3Address, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv6Address() != null) { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } else { LOG.error("Endpoint has Ip Address that is not recognised as either IPv4 or IPv6.", destL3Address); return; } MacAddress matcherMac = peerEndpoint.getMacAddress(); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) peerOrdinals.getL3Id())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL3RoutedFlow(goToTable, priority, port, l2GatewayEp, match, peerOrdinals, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } }
DestinationMapperFlows { void createExternalL3RoutedFlow(short goToTable, int priority, Endpoint peerEndpoint, Endpoint l2GatewayEp, L3Address destL3Address, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv6Address() != null) { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } else { LOG.error("Endpoint has Ip Address that is not recognised as either IPv4 or IPv6.", destL3Address); return; } MacAddress matcherMac = peerEndpoint.getMacAddress(); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) peerOrdinals.getL3Id())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL3RoutedFlow(goToTable, priority, port, l2GatewayEp, match, peerOrdinals, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId); }
DestinationMapperFlows { void createExternalL3RoutedFlow(short goToTable, int priority, Endpoint peerEndpoint, Endpoint l2GatewayEp, L3Address destL3Address, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv6Address() != null) { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } else { LOG.error("Endpoint has Ip Address that is not recognised as either IPv4 or IPv6.", destL3Address); return; } MacAddress matcherMac = peerEndpoint.getMacAddress(); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) peerOrdinals.getL3Id())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL3RoutedFlow(goToTable, priority, port, l2GatewayEp, match, peerOrdinals, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);  }
DestinationMapperFlows { void createExternalL3RoutedFlow(short goToTable, int priority, Endpoint peerEndpoint, Endpoint l2GatewayEp, L3Address destL3Address, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) { OrdinalFactory.EndpointFwdCtxOrdinals peerOrdinals = utils.getEndpointOrdinals(peerEndpoint); if (peerOrdinals != null) { Layer3Match layer3Match; Long etherType; String ikey; if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv4Address() != null) { ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32"; etherType = IPv4; layer3Match = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build(); } else if (destL3Address.getIpAddress() != null && destL3Address.getIpAddress().getIpv6Address() != null) { ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128"; etherType = IPv6; layer3Match = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build(); } else { LOG.error("Endpoint has Ip Address that is not recognised as either IPv4 or IPv6.", destL3Address); return; } MacAddress matcherMac = peerEndpoint.getMacAddress(); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType)) .setLayer3Match(layer3Match); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) peerOrdinals.getL3Id())); Match match = matchBuilder.build(); long port; for (NodeConnectorId externalPort : externalPorts) { try { port = getOfPortNum(externalPort); writeExternalL3RoutedFlow(goToTable, priority, port, l2GatewayEp, match, peerOrdinals, ofWriter); } catch (NumberFormatException e) { LOG.warn("Invalid NodeConnectorId. External port: {}", externalPort); } } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);   }