// which were containing the removed external IP
naptManager.removeFromIpPortMapDS(routerId, removedInternalIpPort, protocolType);
//Remove the IP port incomint packer map.
- naptPacketInHandler.removeIncomingPacketMap(removedInternalIpPort);
- String[] removedInternalIpPortParts = removedInternalIpPort.split(":");
+ naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR
+ + removedInternalIpPort);
+ String[] removedInternalIpPortParts = removedInternalIpPort
+ .split(NatConstants.COLON_SEPARATOR);
if (removedInternalIpPortParts.length == 2) {
String removedInternalIp = removedInternalIpPortParts[0];
String removedInternalPort = removedInternalIpPortParts[1];
List<String> internalPorts = internalIpPort.getValue();
for (String internalPort : internalPorts) {
//Remove the NAPT translation entries from Outbound NAPT table
+ naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR
+ + internalIp + NatConstants.COLON_SEPARATOR + internalPort);
naptEventHandler.removeNatFlows(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
routerId, internalIp, Integer.valueOf(internalPort));
}
String internalPort = ipPortParts[1];
//Build the flow for the outbound NAPT table
+ naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR + internalIp
+ + NatConstants.COLON_SEPARATOR + internalPort);
String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
String.valueOf(routerId), internalIp, Integer.valueOf(internalPort));
FlowEntity outboundNaptFlowEntity =
String internalPort = ipPortParts[1];
//Build the flow for the outbound NAPT table
+ naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR + internalIp
+ + NatConstants.COLON_SEPARATOR + internalPort);
String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
String.valueOf(routerId), internalIp, Integer.valueOf(internalPort));
FlowEntity outboundNaptFlowEntity =
internalAddress, externalAddress);
}
});
- String key = naptEntryEvent.getIpAddress() + ":" + naptEntryEvent.getPortNumber();
+ String key = naptEntryEvent.getRouterId() + NatConstants.COLON_SEPARATOR
+ + naptEntryEvent.getIpAddress() + NatConstants.COLON_SEPARATOR
+ + naptEntryEvent.getPortNumber();
NatPacketProcessingState state = NaptPacketInHandler.INCOMING_PACKET_MAP.get(key);
state.setFlowInstalledTime(System.currentTimeMillis());
} else {
LOG.error("onFlowRemoved : Null exception while retrieving routerId");
return;
}
-
+ final String internalIpPortKey = routerId + NatConstants.COLON_SEPARATOR
+ + internalIpv4HostAddress + NatConstants.COLON_SEPARATOR + internalPortNumber;
//Get the external IP address and the port from the model
IpPortExternal ipPortExternal = NatUtil.getExternalIpPortMap(dataBroker, routerId,
internalIpv4HostAddress, internalPortNumber.toString(), protocol);
FlowEntity snatFlowEntity = NatUtil.buildFlowEntity(dpnId, tableId, switchFlowRef);
long startTime = System.currentTimeMillis();
mdsalManager.removeFlow(snatFlowEntity);
- String internalIpPortKey = internalIpv4HostAddress + ":" + internalPortNumber;
LOG.debug("onFlowRemoved : Elapsed time fo deleting table-{} flow for snat ({}) session:{}ms",
tableId, internalIpPortKey, (System.currentTimeMillis() - startTime));
//Remove the SourceIP:Port key from the Napt packet handler map.
LOG.error("onPacketReceived : Router ID is invalid");
return;
}
- String sourceIPPortKey = internalIPAddress + ":" + portNumber;
+ String sourceIPPortKey = routerId + NatConstants.COLON_SEPARATOR
+ + internalIPAddress + NatConstants.COLON_SEPARATOR + portNumber;
if (!INCOMING_PACKET_MAP.containsKey(sourceIPPortKey)) {
INCOMING_PACKET_MAP.put(sourceIPPortKey,
new NatPacketProcessingState(System.currentTimeMillis(), -1));
NatPacketProcessingState state = INCOMING_PACKET_MAP.get(sourceIPPortKey);
long firstPacketInTime = state.getFirstPacketInTime();
long flowInstalledTime = state.getFlowInstalledTime();
- if (flowInstalledTime == -1
- && (System.currentTimeMillis() - firstPacketInTime) > 4000) {
+ if ((System.currentTimeMillis() - firstPacketInTime) > 4000) {
LOG.error("onPacketReceived : Flow not installed even after 4sec."
+ "Dropping SNAT ({}) Packet", sourceIPPortKey);
removeIncomingPacketMap(sourceIPPortKey);
public static BigInteger COOKIE_NAPT_BASE = new BigInteger("8000000", 16);
public static final String NAPT_FLOWID_PREFIX = "SNAT.";
public static final String FLOWID_SEPARATOR = ".";
+ public static final String COLON_SEPARATOR = ":";
public static final int DEFAULT_NAPT_IDLE_TIMEOUT = 300;
public static int EVENT_QUEUE_LENGTH = 1000000;
public static final String FLOWID_PREFIX = "L3.";