import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
private DhcpServiceUtils() { }
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public static void setupDhcpFlowEntry(@Nullable BigInteger dpId, short tableId, @Nullable String vmMacAddress,
int addOrRemove,
IMdsalApiManager mdsalUtil, DhcpServiceCounters dhcpServiceCounters,
if (addOrRemove == NwConstants.DEL_FLOW) {
LOG.trace("Removing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
dhcpServiceCounters.removeDhcpFlow();
- mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+ try {
+ mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
} else {
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY,
.append(ipAddress).toString();
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public static void setupDhcpDropAction(BigInteger dpId, short tableId, String vmMacAddress, int addOrRemove,
IMdsalApiManager mdsalUtil, DhcpServiceCounters dhcpServiceCounters,
TypedReadWriteTransaction<Configuration> tx) {
if (addOrRemove == NwConstants.DEL_FLOW) {
LOG.trace("Removing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
dhcpServiceCounters.removeDhcpDropFlow();
- mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+ try {
+ mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
} else {
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY,
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
mdsalManager.addFlowToTx(interfaceInfo.getDpId(), flowEntry, writeFlowGroupTx);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public void removeFilterEqualsTable(ElanInstance elanInfo, InterfaceInfo interfaceInfo,
TypedReadWriteTransaction<Configuration> flowTx) {
- int ifTag = interfaceInfo.getInterfaceTag();
- Flow flow = MDSALUtil.buildFlow(NwConstants.ELAN_FILTER_EQUALS_TABLE,
+ try {
+ int ifTag = interfaceInfo.getInterfaceTag();
+ Flow flow = MDSALUtil.buildFlow(NwConstants.ELAN_FILTER_EQUALS_TABLE,
getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"));
- mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flow);
+ mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flow);
- Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE,
+ Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE,
getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "drop"), 10, elanInfo.getElanInstanceName(), 0,
0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)),
getMatchesForFilterEqualsLPortTag(ifTag), MDSALUtil.buildInstructionsDrop());
- mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flowEntity);
+ mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
private List<Bucket> getRemoteBCGroupBucketInfos(ElanInstance elanInfo, int bucketKeyStart,
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
}
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private boolean executeDeleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
boolean deleteSmac, String elanInstanceName, BigInteger srcdpId, Long elanTag, BigInteger dstDpId,
TypedReadWriteTransaction<Configuration> flowTx) {
isFlowsRemovedInSrcDpn = true;
deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
} else if (isDpnPresent(dstDpId)) {
- mdsalManager
+ try {
+ mdsalManager
.removeFlow(flowTx, dstDpId,
- MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
- NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)));
+ MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
+ NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)));
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("Dmac flow entry deleted for elan:{}, logical interface port:{} and mac address:{} on dpn:{}",
elanInstanceName, interfaceInfo.getPortName(), macAddress, dstDpId);
}
return isFlowsRemovedInSrcDpn;
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void deleteSmacAndDmacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) {
String elanInstanceName = elanInfo.getElanInstanceName();
long ifTag = interfaceInfo.getInterfaceTag();
BigInteger srcdpId = interfaceInfo.getDpId();
Long elanTag = elanInfo.getElanTag();
- if (deleteSmac) {
- mdsalManager
- .removeFlow(flowTx, srcdpId,
- MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(
- NwConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
- }
- mdsalManager.removeFlow(flowTx, srcdpId,
+ try {
+ if (deleteSmac) {
+ mdsalManager
+ .removeFlow(flowTx, srcdpId,
+ MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(
+ NwConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+ }
+ mdsalManager.removeFlow(flowTx, srcdpId,
MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE,
- getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+ getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}",
elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
*/
package org.opendaylight.netvirt.natservice.internal;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
protected void removeSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
Long routerId, String routerName) {
LOG.debug("installSnatMissEntry : Removing SNAT miss entry from switch {}", dpnId);
long groupId = createGroupId(getGroupIdKey(routerName));
LOG.debug("removing the PSNAT to NAPTSwitch on DPN {} with GroupId: {}", dpnId, groupId);
- mdsalManager.removeGroup(confTx, dpnId, groupId);
+ try {
+ mdsalManager.removeGroup(confTx, dpnId, groupId);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
// Install miss entry pointing to group
LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}",
mdsalManager.addFlow(confTx, flowEntity);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
protected void removeFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpId, short tableId,
String flowId) {
LOG.trace("syncFlow : Removing Acl Flow DpnId {}, flowId {}", dpId, flowId);
- mdsalManager.removeFlow(confTx, dpId, flowId, tableId);
+ try {
+ mdsalManager.removeFlow(confTx, dpId, flowId, tableId);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
protected long createGroupId(String groupIdKey) {
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
terminatingServiceTableFlowEntity, dpnId);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, TypedReadWriteTransaction<Configuration> confTx) {
LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on DpnId {} "
+ "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.PDNAT_TABLE,
NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.DNAT_FLOW_NAME),
6, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0,
COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, null);
- mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}",
flowEntity, dpnId);
}
package org.opendaylight.netvirt.natservice.internal;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import javax.inject.Inject;
this.idManager = idManager;
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public void evpnRemoveSnatFlowsInOldNaptSwitch(String routerName, long routerId, String vpnName,
BigInteger naptSwitch, TypedReadWriteTransaction<Configuration> confTx) {
//Handling VXLAN Provider type flow removal from old NAPT switch
LOG.info("evpnRemoveSnatFlowsInOldNaptSwitch: Remove the flow (table26->46) in table {} "
+ "for the old napt switch with the DPN ID {} and router ID {}",
NwConstants.PSNAT_TABLE, naptSwitch, routerId);
- mdsalManager.removeFlow(confTx, flowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
//Remove the Terminating Service table entry which forwards the packet to Inbound NAPT Table (table36->44)
LOG.info("evpnRemoveSnatFlowsInOldNaptSwitch : Remove the flow (table36->44) in table {} "
FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
LOG.info("evpnRemoveSnatFlowsInOldNaptSwitch : Remove the flow in the {} for the active switch "
+ "with the DPN ID {} and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, naptSwitch, routerId);
- mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
terminatingServiceTableFlowEntity, dpnId);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, TypedReadWriteTransaction<Configuration> confTx) {
LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on NAPT DpnId {} "
+ "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE,
NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.SNAT_FLOW_NAME),
5, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0,
COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, null);
- mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}",
flowEntity, dpnId);
}
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.net.Inet6Address;
import java.net.InetAddress;
NatEvpnUtil.releaseLPortTagForRouter(dataBroker, idManager, routerName);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public void removeNaptFlowsFromActiveSwitch(long routerId, String routerName,
BigInteger dpnId, Uuid networkId, String vpnName,
@Nonnull Collection<String> externalIps,
Collection<Uuid> externalSubnetList,
TypedReadWriteTransaction<Configuration> confTx,
ProviderTypes extNwProvType) {
- LOG.debug("removeNaptFlowsFromActiveSwitch : Remove NAPT flows from Active switch");
- BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
-
- //Remove the PSNAT entry which forwards the packet to Outbound NAPT Table (For the
- // traffic which comes from the VMs of the NAPT switches)
- String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, routerName);
- FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
-
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
- + "and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(confTx, preSnatFlowEntity);
-
- //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table (For the
- // traffic which comes from the VMs of the non NAPT switches)
- long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
+ try {
+ LOG.debug("removeNaptFlowsFromActiveSwitch : Remove NAPT flows from Active switch");
+ BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
+
+ //Remove the PSNAT entry which forwards the packet to Outbound NAPT Table (For the
+ // traffic which comes from the VMs of the NAPT switches)
+ String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, routerName);
+ FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
+
+ LOG.info(
+ "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
+ + "and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
+ mdsalManager.removeFlow(confTx, preSnatFlowEntity);
+
+ //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table (For the
+ // traffic which comes from the VMs of the non NAPT switches)
+ long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
routerName);
- String tsFlowRef = getFlowRefTs(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tunnelId);
- FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
- + "and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(confTx, tsNatFlowEntity);
-
- //Remove the flow table 25->44 from NAPT Switch
- if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
- NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, dpnId);
- }
+ String tsFlowRef = getFlowRefTs(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tunnelId);
+ FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
+ LOG.info(
+ "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
+ + "and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, dpnId, routerId);
+ mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+
+ //Remove the flow table 25->44 from NAPT Switch
+ if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
+ NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, dpnId);
+ }
- //Remove the Outbound flow entry which forwards the packet to FIB Table
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {}"
- + " and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
+ //Remove the Outbound flow entry which forwards the packet to FIB Table
+ LOG.info(
+ "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {}"
+ + " and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
- String outboundTcpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+ String outboundTcpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
NwConstants.IP_PROT_TCP);
- FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
- outboundTcpNatFlowRef);
- mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
+ FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ outboundTcpNatFlowRef);
+ mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
- String outboundUdpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+ String outboundUdpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
NwConstants.IP_PROT_UDP);
- FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
outboundUdpNatFlowRef);
- mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+ mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
- String icmpDropFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+ String icmpDropFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
NwConstants.IP_PROT_ICMP);
- FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
icmpDropFlowRef);
- mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
-
- removeNaptFibExternalOutputFlows(routerId, dpnId, networkId, externalIps, confTx);
- //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
- // External Subnet Vpn Id.
- for (Uuid externalSubnetId : externalSubnetList) {
- long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
- if (subnetVpnId != -1) {
- String natPfibSubnetFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
- FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE,
+ mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
+
+ removeNaptFibExternalOutputFlows(routerId, dpnId, networkId, externalIps, confTx);
+ //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
+ // External Subnet Vpn Id.
+ for (Uuid externalSubnetId : externalSubnetList) {
+ long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
+ if (subnetVpnId != -1) {
+ String natPfibSubnetFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
+ FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE,
natPfibSubnetFlowRef);
- mdsalManager.removeFlow(confTx, natPfibFlowEntity);
- LOG.debug("removeNaptFlowsFromActiveSwitch : Removed the flow in table {} with external subnet "
- + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
+ mdsalManager.removeFlow(confTx, natPfibFlowEntity);
+ LOG.debug("removeNaptFlowsFromActiveSwitch : Removed the flow in table {} with external subnet "
+ + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
subnetVpnId, dpnId);
+ }
}
- }
-
- //Remove the NAPT PFIB TABLE which forwards the incoming packet to FIB Table matching on the router ID.
- String natPfibFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
- FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibFlowRef);
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
- + "and router ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(confTx, natPfibFlowEntity);
-
- // Long vpnId = NatUtil.getVpnId(dataBroker, routerId);
- // - This does not work since ext-routers is deleted already - no network info
- //Get the VPN ID from the ExternalNetworks model
- long vpnId = -1;
- if (vpnName == null || vpnName.isEmpty()) {
- // ie called from router delete cases
- Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
- LOG.debug("removeNaptFlowsFromActiveSwitch : vpnUuid is {}", vpnUuid);
- if (vpnUuid != null) {
- vpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
- LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId {} for external network {} router delete or "
+ //Remove the NAPT PFIB TABLE which forwards the incoming packet to FIB Table matching on the router ID.
+ String natPfibFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
+ FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibFlowRef);
+
+ LOG.info(
+ "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
+ + "and router ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, routerId);
+ mdsalManager.removeFlow(confTx, natPfibFlowEntity);
+
+ // Long vpnId = NatUtil.getVpnId(dataBroker, routerId);
+ // - This does not work since ext-routers is deleted already - no network info
+ //Get the VPN ID from the ExternalNetworks model
+ long vpnId = -1;
+ if (vpnName == null || vpnName.isEmpty()) {
+ // ie called from router delete cases
+ Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
+ LOG.debug("removeNaptFlowsFromActiveSwitch : vpnUuid is {}", vpnUuid);
+ if (vpnUuid != null) {
+ vpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
+ LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId {} for external network {} router delete or "
+ "disableSNAT scenario", vpnId, networkId);
- }
- } else {
- // ie called from disassociate vpn case
- LOG.debug("removeNaptFlowsFromActiveSwitch : This is disassociate nw with vpn case with vpnName {}",
+ }
+ } else {
+ // ie called from disassociate vpn case
+ LOG.debug("removeNaptFlowsFromActiveSwitch : This is disassociate nw with vpn case with vpnName {}",
vpnName);
- vpnId = NatUtil.getVpnId(dataBroker, vpnName);
- LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId for disassociate nw with vpn scenario {}", vpnId);
- }
+ vpnId = NatUtil.getVpnId(dataBroker, vpnName);
+ LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId for disassociate nw with vpn scenario {}", vpnId);
+ }
- if (vpnId != NatConstants.INVALID_ID) {
- //Remove the NAPT PFIB TABLE which forwards the outgoing packet to FIB Table matching on the VPN ID.
- String natPfibVpnFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, vpnId);
- FlowEntity natPfibVpnFlowEntity =
- NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in {} for the active switch with the DPN ID {} "
- + "and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
- mdsalManager.removeFlow(confTx, natPfibVpnFlowEntity);
- }
+ if (vpnId != NatConstants.INVALID_ID) {
+ //Remove the NAPT PFIB TABLE which forwards the outgoing packet to FIB Table matching on the VPN ID.
+ String natPfibVpnFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, vpnId);
+ FlowEntity natPfibVpnFlowEntity =
+ NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
+ LOG.info(
+ "removeNaptFlowsFromActiveSwitch : Remove the flow in {} for the active switch with the DPN ID {} "
+ + "and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
+ mdsalManager.removeFlow(confTx, natPfibVpnFlowEntity);
+ }
- //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
- IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
- if (ipPortMapping == null) {
- LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the IpPortMapping");
- return;
- }
+ //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
+ IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
+ if (ipPortMapping == null) {
+ LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the IpPortMapping");
+ return;
+ }
- List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
- for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
- List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
- for (IpPortMap ipPortMap : ipPortMaps) {
- String ipPortInternal = ipPortMap.getIpPortInternal();
- String[] ipPortParts = ipPortInternal.split(":");
- if (ipPortParts.length != 2) {
- LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the Internal IP and port");
- return;
- }
- String internalIp = ipPortParts[0];
- String internalPort = ipPortParts[1];
+ List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
+ for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
+ List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
+ for (IpPortMap ipPortMap : ipPortMaps) {
+ String ipPortInternal = ipPortMap.getIpPortInternal();
+ String[] ipPortParts = ipPortInternal.split(":");
+ if (ipPortParts.length != 2) {
+ LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the Internal IP and port");
+ return;
+ }
+ String internalIp = ipPortParts[0];
+ String internalPort = ipPortParts[1];
- //Build the flow for the outbound NAPT table
- naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR + internalIp
+ //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.parseInt(internalPort));
- FlowEntity outboundNaptFlowEntity =
- NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
+ String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ String.valueOf(routerId), internalIp, Integer.parseInt(internalPort));
+ FlowEntity outboundNaptFlowEntity =
+ NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch "
+ LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch "
+ "with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
+ mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
- IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
- String externalIp = ipPortExternal.getIpAddress();
- int externalPort = ipPortExternal.getPortNum();
+ IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
+ String externalIp = ipPortExternal.getIpAddress();
+ int externalPort = ipPortExternal.getPortNum();
- //Build the flow for the inbound NAPT table
- switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE,
- String.valueOf(routerId), externalIp, externalPort);
- FlowEntity inboundNaptFlowEntity =
- NatUtil.buildFlowEntity(dpnId, NwConstants.INBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
+ //Build the flow for the inbound NAPT table
+ switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE,
+ String.valueOf(routerId), externalIp, externalPort);
+ FlowEntity inboundNaptFlowEntity =
+ NatUtil.buildFlowEntity(dpnId, NwConstants.INBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
- LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active active switch "
+ LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active active switch "
+ "with the DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
+ mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
+ }
}
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
}
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
protected void removeNaptFibExternalOutputFlows(long routerId, BigInteger dpnId, Uuid networkId,
@Nonnull Collection<String> externalIps,
TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
+ " with the DPN ID {} and router ID {} and IP {} flowRef {}",
NwConstants.NAPT_PFIB_TABLE, dpnId, routerId, extIp, naptFlowRef);
FlowEntity natPfibVpnFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, naptFlowRef);
- mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+ try {
+ mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
}
return ip;
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public void removeNaptFlowsFromActiveSwitchInternetVpn(long routerId, String routerName,
BigInteger dpnId, Uuid networkId, String vpnName,
TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the active switch "
+ "with the DPN ID {} and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
- mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+ try {
+ mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
// Remove IP-PORT active NAPT entries and release port from IdManager
// For the router ID get the internal IP , internal port and the corresponding
LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the "
+ "active switch with the DPN ID {} and router ID {}",
NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(writeFlowInvTx, outboundNaptFlowEntity);
+ try {
+ mdsalManager.removeFlow(writeFlowInvTx, outboundNaptFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
String externalIp = ipPortExternal.getIpAddress();
LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the "
+ "active active switch with the DPN ID {} and router ID {}",
NwConstants.INBOUND_NAPT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(writeFlowInvTx, inboundNaptFlowEntity);
+ try {
+ mdsalManager.removeFlow(writeFlowInvTx, inboundNaptFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
// Finally release port from idmanager
String internalIpPort = internalIp + ":" + internalPort;
}
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public void removeFlowsFromNonActiveSwitches(long routerId, String routerName,
BigInteger naptSwitchDpnId, TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
LOG.debug("removeFlowsFromNonActiveSwitches : Remove NAPT related flows from non active switches");
LOG.error("removeFlowsFromNonActiveSwitches : Unable to get the swithces for the router {}", routerName);
return;
}
- for (BigInteger dpnId : allSwitchList) {
- if (!naptSwitchDpnId.equals(dpnId)) {
- LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
+ try {
+ for (BigInteger dpnId : allSwitchList) {
+ if (!naptSwitchDpnId.equals(dpnId)) {
+ LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
- //Remove the PSNAT entry which forwards the packet to Terminating Service table
- String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
- FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
+ //Remove the PSNAT entry which forwards the packet to Terminating Service table
+ String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
+ FlowEntity preSnatFlowEntity =
+ NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
- LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch "
+ LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch "
+ "with the DPN ID {} and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(removeFlowInvTx, preSnatFlowEntity);
+ mdsalManager.removeFlow(removeFlowInvTx, preSnatFlowEntity);
- //Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
- long groupId = createGroupId(getGroupIdKey(routerName));
- List<BucketInfo> listBucketInfo = new ArrayList<>();
- GroupEntity preSnatGroupEntity =
- MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
+ //Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
+ long groupId = createGroupId(getGroupIdKey(routerName));
+ List<BucketInfo> listBucketInfo = new ArrayList<>();
+ GroupEntity preSnatGroupEntity =
+ MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
- LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with "
+ LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with "
+ "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
- mdsalManager.removeGroup(removeFlowInvTx, preSnatGroupEntity);
+ mdsalManager.removeGroup(removeFlowInvTx, preSnatGroupEntity);
+ }
}
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
}
}
NatUtil.removePrefixFromBGP(bgpManager, fibManager, rd, externalIp, vpnName, LOG);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeTunnelTableEntry(BigInteger dpnId, long serviceId,
TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
LOG.info("removeTunnelTableEntry : called with DpnId = {} and label = {}", dpnId, serviceId);
getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""),
5, String.format("%s:%d", "TST Flow Entry ", serviceId), 0, 0,
COOKIE_TUNNEL.add(BigInteger.valueOf(serviceId)), mkMatches, null);
- mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+ try {
+ mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeTunnelTableEntry : dpID {} : label : {} removed successfully", dpnId, serviceId);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeLFibTableEntry(BigInteger dpnId, long serviceId,
TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
List<MatchInfo> matches = new ArrayList<>();
10, flowRef, 0, 0,
COOKIE_VM_LFIB_TABLE, matches, null);
- mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+ try {
+ mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeLFibTableEntry : dpID : {} label : {} removed successfully", dpnId, serviceId);
}
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
}
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeDNATTblEntry(BigInteger dpnId, String internalIp, String externalIp, long routerId,
- TypedReadWriteTransaction<Configuration> confTx) {
- FlowEntity preFlowEntity = buildPreDNATDeleteFlowEntity(dpnId, externalIp, routerId);
- mdsalManager.removeFlow(confTx, preFlowEntity);
+ TypedReadWriteTransaction<Configuration> confTx) {
+ try {
+ FlowEntity preFlowEntity = buildPreDNATDeleteFlowEntity(dpnId, externalIp, routerId);
+ mdsalManager.removeFlow(confTx, preFlowEntity);
- FlowEntity flowEntity = buildDNATDeleteFlowEntity(dpnId, internalIp, routerId);
- if (flowEntity != null) {
- mdsalManager.removeFlow(confTx, flowEntity);
+ FlowEntity flowEntity = buildDNATDeleteFlowEntity(dpnId, internalIp, routerId);
+ if (flowEntity != null) {
+ mdsalManager.removeFlow(confTx, flowEntity);
+ }
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
}
}
}
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeSNATTblEntry(BigInteger dpnId, String internalIp, String externalIp, long routerId, long vpnId,
TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
- FlowEntity preFlowEntity = buildPreSNATDeleteFlowEntity(dpnId, internalIp, routerId);
- mdsalManager.removeFlow(removeFlowInvTx, preFlowEntity);
+ try {
+ FlowEntity preFlowEntity = buildPreSNATDeleteFlowEntity(dpnId, internalIp, routerId);
+ mdsalManager.removeFlow(removeFlowInvTx, preFlowEntity);
- FlowEntity flowEntity = buildSNATDeleteFlowEntity(dpnId, externalIp, vpnId);
- if (flowEntity != null) {
- mdsalManager.removeFlow(removeFlowInvTx, flowEntity);
+ FlowEntity flowEntity = buildSNATDeleteFlowEntity(dpnId, externalIp, vpnId);
+ if (flowEntity != null) {
+ mdsalManager.removeFlow(removeFlowInvTx, flowEntity);
+ }
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
}
}
package org.opendaylight.netvirt.natservice.internal;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
}
}*/
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
protected void removeSnatFlowsInOldNaptSwitch(String routerName, Long routerId, BigInteger naptSwitch,
Map<String, Long> externalIpmap,
TypedReadWriteTransaction<Configuration> confTx) {
- //remove SNAT flows in old NAPT SWITCH
- Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
- String vpnName = getExtNetworkVpnName(routerName, networkId);
- if (vpnName == null) {
- LOG.error("removeSnatFlowsInOldNaptSwitch : Vpn is not associated to externalN/w of router {}",
+ try {
+ //remove SNAT flows in old NAPT SWITCH
+ Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
+ String vpnName = getExtNetworkVpnName(routerName, networkId);
+ if (vpnName == null) {
+ LOG.error("removeSnatFlowsInOldNaptSwitch : Vpn is not associated to externalN/w of router {}",
routerName);
- return;
- }
- ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkId);
- if (extNwProvType == null) {
- LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the External Network Provider Type "
+ return;
+ }
+ ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkId);
+ if (extNwProvType == null) {
+ LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the External Network Provider Type "
+ "for Router {}", routerName);
- return;
- }
- if (extNwProvType == ProviderTypes.VXLAN) {
- evpnNaptSwitchHA.evpnRemoveSnatFlowsInOldNaptSwitch(routerName, routerId, vpnName, naptSwitch, confTx);
- } else {
- //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table
- long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
+ return;
+ }
+ if (extNwProvType == ProviderTypes.VXLAN) {
+ evpnNaptSwitchHA.evpnRemoveSnatFlowsInOldNaptSwitch(routerName, routerId, vpnName, naptSwitch, confTx);
+ } else {
+ //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table
+ long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
routerName);
- String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
+ String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
tunnelId);
- FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
+ FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
tsFlowRef);
- LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
+ LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
+ "with the DPN ID {} and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, naptSwitch, routerId);
- mdsalManager.removeFlow(confTx, tsNatFlowEntity);
- }
- if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
- //Remove the flow table 25->44 If there is no FIP Match on table 25 (PDNAT_TABLE)
- NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, naptSwitch);
- }
- //Remove the Outbound flow entry which forwards the packet to Outbound NAPT Table
- LOG.info("Remove the flow in table {} for the old napt switch with the DPN ID {} and router ID {}",
+ mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+ }
+ if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
+ //Remove the flow table 25->44 If there is no FIP Match on table 25 (PDNAT_TABLE)
+ NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, naptSwitch);
+ }
+ //Remove the Outbound flow entry which forwards the packet to Outbound NAPT Table
+ LOG.info("Remove the flow in table {} for the old napt switch with the DPN ID {} and router ID {}",
NwConstants.OUTBOUND_NAPT_TABLE, naptSwitch, routerId);
- String outboundTcpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
- NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_TCP);
- FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
- NwConstants.OUTBOUND_NAPT_TABLE, outboundTcpNatFlowRef);
- mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
+ String outboundTcpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+ NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_TCP);
+ FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
+ NwConstants.OUTBOUND_NAPT_TABLE, outboundTcpNatFlowRef);
+ mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
- String outboundUdpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+ String outboundUdpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_UDP);
- FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
+ FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
NwConstants.OUTBOUND_NAPT_TABLE, outboundUdpNatFlowRef);
- mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+ mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
- String icmpDropFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+ String icmpDropFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_ICMP);
- FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
+ FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
icmpDropFlowRef);
- mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
+ mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
- //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
- // External Subnet Vpn Id.
- Collection<Uuid> externalSubnetIdsForRouter = NatUtil.getExternalSubnetIdsForRouter(dataBroker,
+ //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
+ // External Subnet Vpn Id.
+ Collection<Uuid> externalSubnetIdsForRouter = NatUtil.getExternalSubnetIdsForRouter(dataBroker,
routerName);
- for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
- long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
- if (subnetVpnId != -1) {
- String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch,
+ for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
+ long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
+ if (subnetVpnId != -1) {
+ String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch,
NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
- FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE,
+ FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE,
natPfibSubnetFlowRef);
- mdsalManager.removeFlow(confTx, natPfibFlowEntity);
- LOG.debug("removeSnatFlowsInOldNaptSwitch : Removed the flow in table {} with external subnet "
- + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
+ mdsalManager.removeFlow(confTx, natPfibFlowEntity);
+ LOG.debug("removeSnatFlowsInOldNaptSwitch : Removed the flow in table {} with external subnet "
+ + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
subnetVpnId, naptSwitch);
+ }
}
- }
- // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for inbound traffic
- // matching on the router ID.
- String naptPFibflowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, routerId);
- FlowEntity naptPFibFlowEntity =
- NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptPFibflowRef);
- LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
+ // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for inbound traffic
+ // matching on the router ID.
+ String naptPFibflowRef =
+ externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, routerId);
+ FlowEntity naptPFibFlowEntity =
+ NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptPFibflowRef);
+ LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
+ "with the DPN ID {} and router ID {}", NwConstants.NAPT_PFIB_TABLE, naptSwitch, routerId);
- mdsalManager.removeFlow(confTx, naptPFibFlowEntity);
-
- // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for outbound traffic
- // matching on the vpn ID.
- boolean switchSharedByRouters = false;
- Uuid extNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
- if (extNetworkId != null) {
- List<String> routerNamesAssociated = getRouterIdsForExtNetwork(extNetworkId);
- for (String routerNameAssociated : routerNamesAssociated) {
- if (!routerNameAssociated.equals(routerName)) {
- Long routerIdAssociated = NatUtil.getVpnId(dataBroker, routerNameAssociated);
- BigInteger naptDpn = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerNameAssociated);
- if (naptDpn != null && naptDpn.equals(naptSwitch)) {
- LOG.debug("removeSnatFlowsInOldNaptSwitch : Napt switch {} is also acting as primary "
+ mdsalManager.removeFlow(confTx, naptPFibFlowEntity);
+
+ // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for outbound traffic
+ // matching on the vpn ID.
+ boolean switchSharedByRouters = false;
+ Uuid extNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
+ if (extNetworkId != null) {
+ List<String> routerNamesAssociated = getRouterIdsForExtNetwork(extNetworkId);
+ for (String routerNameAssociated : routerNamesAssociated) {
+ if (!routerNameAssociated.equals(routerName)) {
+ Long routerIdAssociated = NatUtil.getVpnId(dataBroker, routerNameAssociated);
+ BigInteger naptDpn = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerNameAssociated);
+ if (naptDpn != null && naptDpn.equals(naptSwitch)) {
+ LOG.debug("removeSnatFlowsInOldNaptSwitch : Napt switch {} is also acting as primary "
+ "for router {}", naptSwitch, routerIdAssociated);
- switchSharedByRouters = true;
- break;
+ switchSharedByRouters = true;
+ break;
+ }
}
}
- }
- if (!switchSharedByRouters) {
- Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
- if (vpnId != NatConstants.INVALID_ID) {
- String naptFibflowRef =
+ if (!switchSharedByRouters) {
+ Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
+ if (vpnId != NatConstants.INVALID_ID) {
+ String naptFibflowRef =
externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, vpnId);
- FlowEntity naptFibFlowEntity =
+ FlowEntity naptFibFlowEntity =
NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptFibflowRef);
- LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch"
+ LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch"
+ " with the DPN ID {} and vpnId {}", NwConstants.NAPT_PFIB_TABLE, naptSwitch, vpnId);
- mdsalManager.removeFlow(confTx, naptFibFlowEntity);
- } else {
- LOG.error("removeSnatFlowsInOldNaptSwitch : Invalid vpnId retrieved for routerId {}",
+ mdsalManager.removeFlow(confTx, naptFibFlowEntity);
+ } else {
+ LOG.error("removeSnatFlowsInOldNaptSwitch : Invalid vpnId retrieved for routerId {}",
routerId);
- return;
+ return;
+ }
}
}
- }
- //Remove Fib entries,tables 20->44 ,36-> 44
- String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
- if (externalIpmap != null && !externalIpmap.isEmpty()) {
- for (Entry<String, Long> entry : externalIpmap.entrySet()) {
- String externalIp = entry.getKey();
- Long label = entry.getValue();
- externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName,
+ //Remove Fib entries,tables 20->44 ,36-> 44
+ String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
+ if (externalIpmap != null && !externalIpmap.isEmpty()) {
+ for (Entry<String, Long> entry : externalIpmap.entrySet()) {
+ String externalIp = entry.getKey();
+ Long label = entry.getValue();
+ externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName,
extNetworkId, label, gwMacAddress, true, confTx);
- LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} "
+ LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} "
+ "for router {} and externalIps {} label {}", naptSwitch, routerId, externalIp, label);
- }
- } else {
- List<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerName);
- if (networkId != null) {
- externalRouterListener.clearFibTsAndReverseTraffic(naptSwitch, routerId, networkId,
+ }
+ } else {
+ List<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerName);
+ if (networkId != null) {
+ externalRouterListener.clearFibTsAndReverseTraffic(naptSwitch, routerId, networkId,
externalIps, null, gwMacAddress, confTx);
- LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} for "
- + "router {} with networkId {} and externalIps {}", naptSwitch, routerId, networkId,
+ LOG.debug(
+ "removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} for "
+ + "router {} with networkId {} and externalIps {}", naptSwitch, routerId, networkId,
externalIps);
- } else {
- LOG.debug("removeSnatFlowsInOldNaptSwitch : External network not associated to router {}", routerId);
- }
- externalRouterListener.removeNaptFibExternalOutputFlows(routerId, naptSwitch, extNetworkId,
+ } else {
+ LOG.debug("removeSnatFlowsInOldNaptSwitch : External network not associated to router {}",
+ routerId);
+ }
+ externalRouterListener.removeNaptFibExternalOutputFlows(routerId, naptSwitch, extNetworkId,
externalIps, confTx);
- }
+ }
- //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
- IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
- if (ipPortMapping == null || ipPortMapping.getIntextIpProtocolType() == null
- || ipPortMapping.getIntextIpProtocolType().isEmpty()) {
- LOG.warn("removeSnatFlowsInOldNaptSwitch : No Internal Ip Port mapping associated to router {}, "
+ //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
+ IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
+ if (ipPortMapping == null || ipPortMapping.getIntextIpProtocolType() == null
+ || ipPortMapping.getIntextIpProtocolType().isEmpty()) {
+ LOG.warn("removeSnatFlowsInOldNaptSwitch : No Internal Ip Port mapping associated to router {}, "
+ "no flows need to be removed in oldNaptSwitch {}", routerId, naptSwitch);
- return;
- }
- BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
- List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
- for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
- if (intextIpProtocolType.getIpPortMap() == null || intextIpProtocolType.getIpPortMap().isEmpty()) {
- LOG.debug("removeSnatFlowsInOldNaptSwitch : No {} session associated to router {},"
- + "no flows need to be removed in oldNaptSwitch {}",
- intextIpProtocolType.getProtocol(), routerId, naptSwitch);
- break;
+ return;
}
- List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
- for (IpPortMap ipPortMap : ipPortMaps) {
- String ipPortInternal = ipPortMap.getIpPortInternal();
- String[] ipPortParts = ipPortInternal.split(":");
- if (ipPortParts.length != 2) {
- LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the Internal IP and port");
- continue;
+ BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
+ List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
+ for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
+ if (intextIpProtocolType.getIpPortMap() == null || intextIpProtocolType.getIpPortMap().isEmpty()) {
+ LOG.debug("removeSnatFlowsInOldNaptSwitch : No {} session associated to router {},"
+ + "no flows need to be removed in oldNaptSwitch {}",
+ intextIpProtocolType.getProtocol(), routerId, naptSwitch);
+ break;
}
- String internalIp = ipPortParts[0];
- String internalPort = ipPortParts[1];
-
- //Build and remove flow in outbound NAPT table
- String switchFlowRef =
- NatUtil.getNaptFlowRef(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, String.valueOf(routerId),
- internalIp, Integer.parseInt(internalPort));
- FlowEntity outboundNaptFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
- cookieSnatFlow, switchFlowRef);
-
- LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch "
+ List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
+ for (IpPortMap ipPortMap : ipPortMaps) {
+ String ipPortInternal = ipPortMap.getIpPortInternal();
+ String[] ipPortParts = ipPortInternal.split(":");
+ if (ipPortParts.length != 2) {
+ LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the Internal IP and port");
+ continue;
+ }
+ String internalIp = ipPortParts[0];
+ String internalPort = ipPortParts[1];
+
+ //Build and remove flow in outbound NAPT table
+ String switchFlowRef =
+ NatUtil.getNaptFlowRef(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, String.valueOf(routerId),
+ internalIp, Integer.parseInt(internalPort));
+ FlowEntity outboundNaptFlowEntity =
+ NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
+ cookieSnatFlow, switchFlowRef);
+
+ LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch "
+ "with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, naptSwitch, routerId);
- mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
+ mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
- IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
- if (ipPortExternal == null) {
- LOG.debug("removeSnatFlowsInOldNaptSwitch : External Ipport mapping not found for internalIp {} "
- + "with port {} for router {}", internalIp, internalPort, routerId);
- continue;
+ IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
+ if (ipPortExternal == null) {
+ LOG.debug(
+ "removeSnatFlowsInOldNaptSwitch : External Ipport mapping not found for internalIp {} "
+ + "with port {} for router {}", internalIp, internalPort, routerId);
+ continue;
+ }
+ String externalIp = ipPortExternal.getIpAddress();
+ int externalPort = ipPortExternal.getPortNum();
+
+ //Build and remove flow in inbound NAPT table
+ switchFlowRef =
+ NatUtil.getNaptFlowRef(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, String.valueOf(routerId),
+ externalIp, externalPort);
+ FlowEntity inboundNaptFlowEntity =
+ NatUtil.buildFlowEntity(naptSwitch, NwConstants.INBOUND_NAPT_TABLE,
+ cookieSnatFlow, switchFlowRef);
+
+ LOG.info(
+ "removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch with the "
+ + "DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, naptSwitch, routerId);
+ mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
}
- String externalIp = ipPortExternal.getIpAddress();
- int externalPort = ipPortExternal.getPortNum();
-
- //Build and remove flow in inbound NAPT table
- switchFlowRef =
- NatUtil.getNaptFlowRef(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, String.valueOf(routerId),
- externalIp, externalPort);
- FlowEntity inboundNaptFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INBOUND_NAPT_TABLE,
- cookieSnatFlow, switchFlowRef);
-
- LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch with the "
- + "DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, naptSwitch, routerId);
- mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
}
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
}
}
package org.opendaylight.netvirt.natservice.internal;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
l3GwMacTableFlowEntity, dpnId);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
static void removeL3GwMacTableEntry(final BigInteger dpnId, final long vpnId, final String macAddress,
IMdsalApiManager mdsalManager, TypedReadWriteTransaction<Configuration> confTx) {
List<MatchInfo> matchInfo = new ArrayList<>();
Flow l3GwMacTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_GW_MAC_TABLE,
flowRef, 21, flowRef, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, matchInfo, null);
- mdsalManager.removeFlow(confTx, dpnId, l3GwMacTableFlowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, dpnId, l3GwMacTableFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeL3GwMacTableEntry : Successfully removed flow entity {} on DPN = {}",
l3GwMacTableFlowEntity, dpnId);
}
preDnatToSnatTableFlowEntity, naptDpnId);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
public static void removePreDnatToSnatTableEntry(TypedReadWriteTransaction<Configuration> confTx,
IMdsalApiManager mdsalManager, BigInteger naptDpnId) {
LOG.debug("removePreDnatToSnatTableEntry : Remove Pre-DNAT table {} --> table {} flow on NAPT DpnId {} ",
String flowRef = getFlowRefPreDnatToSnat(naptDpnId, NwConstants.PDNAT_TABLE, "PreDNATToSNAT");
Flow preDnatToSnatTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.PDNAT_TABLE,flowRef,
5, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, null, null);
- mdsalManager.removeFlow(confTx, naptDpnId, preDnatToSnatTableFlowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, naptDpnId, preDnatToSnatTableFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removePreDnatToSnatTableEntry: Successfully removed Pre-DNAT flow {} on NAPT DpnId = {}",
preDnatToSnatTableFlowEntity, naptDpnId);
}
package org.opendaylight.netvirt.natservice.internal;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
mdsalManager.installFlow(flowEntity);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
void removeDefNATRouteInDPN(BigInteger dpnId, long vpnId, TypedReadWriteTransaction<Configuration> confTx) {
FlowEntity flowEntity = buildDefNATFlowEntity(dpnId, vpnId);
if (flowEntity == null) {
return;
}
natServiceCounters.removeDefaultNatFlow();
- mdsalManager.removeFlow(confTx, flowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
void removeDefNATRouteInDPN(BigInteger dpnId, long bgpVpnId, long routerId,
TypedReadWriteTransaction<Configuration> confTx) {
FlowEntity flowEntity = buildDefNATFlowEntity(dpnId, bgpVpnId, routerId);
return;
}
natServiceCounters.removeDefaultNatFlow();
- mdsalManager.removeFlow(confTx, flowEntity);
+ try {
+ mdsalManager.removeFlow(confTx, flowEntity);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, long vpnId) {
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
+ NwConstants.FLOWID_SEPARATOR + ipAddress;
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeTunnelTableEntry(BigInteger dpnId, long serviceId,
TypedReadWriteTransaction<Configuration> confTx) {
LOG.debug("removeTunnelTableEntry : called with DpnId = {} and label = {}", dpnId, serviceId);
- mdsalManager.removeFlow(confTx, dpnId,
- new FlowKey(new FlowId(getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""))),
- NwConstants.INTERNAL_TUNNEL_TABLE);
+ try {
+ mdsalManager.removeFlow(confTx, dpnId,
+ new FlowKey(new FlowId(getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""))),
+ NwConstants.INTERNAL_TUNNEL_TABLE);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeTunnelTableEntry : Terminating service Entry for dpID {} : label : {} removed successfully",
dpnId, serviceId);
}
LOG.debug("makeLFibTableEntry : LFIB Entry for dpID {} : label : {} modified successfully", dpId, serviceId);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeLFibTableEntry(BigInteger dpnId, long serviceId,
TypedReadWriteTransaction<Configuration> confTx) {
LOG.debug("removeLFibTableEntry : removing LFib entry with flow ref {}", flowRef);
- mdsalManager.removeFlow(confTx, dpnId, new FlowKey(new FlowId(flowRef)), NwConstants.L3_LFIB_TABLE);
+ try {
+ mdsalManager.removeFlow(confTx, dpnId, new FlowKey(new FlowId(flowRef)), NwConstants.L3_LFIB_TABLE);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
LOG.debug("removeLFibTableEntry : LFIB Entry for dpID : {} label : {} removed successfully",
dpnId, serviceId);
package org.opendaylight.netvirt.vpnmanager;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
mdsalManager.removeFlowToTx(flowEntity, tx);
}
+ // TODO skitt Fix the exception handling here
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void removeGwMac(String srcMacAddress, TypedReadWriteTransaction<Configuration> tx, long vpnId,
BigInteger dpId, long subnetVpnId) {
- mdsalManager.removeFlow(tx, dpId,
- VpnUtil.getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, srcMacAddress, subnetVpnId),
- NwConstants.L3_GW_MAC_TABLE);
+ try {
+ mdsalManager.removeFlow(tx, dpId,
+ VpnUtil.getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, srcMacAddress, subnetVpnId),
+ NwConstants.L3_GW_MAC_TABLE);
+ } catch (Exception e) {
+ LOG.error("Error removing flow", e);
+ throw new RuntimeException("Error removing flow", e);
+ }
}
@Override