private void syncExternalFlows(DestinationMapperFlows flows, Endpoint endpoint, Endpoint peerEndpoint,
Endpoint gatewayEndpoint, Set<NodeConnectorId> externalPorts, OfWriter ofWriter) {
EndpointFwdCtxOrdinals peerOrdinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, peerEndpoint);
if (peerOrdinals == null) {
return;
}
short goToTable = ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER();
if (endpoint.getNetworkContainment().equals(peerEndpoint.getNetworkContainment())) {
if (externalPorts.iterator().hasNext()) {
flows.createExternalL2Flow(goToTable, EXTERNAL_L2, peerEndpoint, externalPorts, ofWriter);
}
} else if (gatewayEndpoint != null) {
HashSet<Subnet> subnets = utils.getSubnets(peerEndpoint.getTenant());
if (subnets == null) {
LOG.trace("No subnets in tenant {}", peerEndpoint.getTenant());
return;
}
for (L3Address l3Address : endpoint.getL3Address()) {
if (l3Address.getIpAddress() == null || l3Address.getL3Context() == null) {
LOG.error("Endpoint with L3Address but either IPAddress or L3Context is null. {}",
endpoint.getL3Address());
continue;
}
flows.createExternalL3RoutedFlow(goToTable, L3_EXTERNAL, peerEndpoint, gatewayEndpoint, l3Address,
externalPorts, ofWriter);
}
}
}