}
public void installDhcpFlowsForVms(BigInteger designatedDpnId, Set<String> listVmMacAddress,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
for (String vmMacAddress : listVmMacAddress) {
installDhcpEntries(designatedDpnId, vmMacAddress, tx);
}
}
public void updateCacheAndInstallNewFlows(List<BigInteger> listOfDpns, Pair<IpAddress, String> pair,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
BigInteger newDesignatedDpn = chooseDpn(pair.getLeft(), pair.getRight(), listOfDpns);
if (newDesignatedDpn.equals(DhcpMConstants.INVALID_DPID)) {
return;
}
private void changeExistingFlowToDrop(Pair<IpAddress, String> tunnelIpElanNamePair, BigInteger dpnId,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx)
+ throws ExecutionException, InterruptedException {
Set<String> setOfVmMacAddress = tunnelIpElanNameToVmMacCache.get(tunnelIpElanNamePair);
if (setOfVmMacAddress == null || setOfVmMacAddress.isEmpty()) {
return;
}
private void installDhcpEntries(BigInteger dpnId, String vmMacAddress,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpFlowEntry(dpnId, NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL,
vmMacAddress, NwConstants.ADD_FLOW, mdsalUtil, dhcpServiceCounters, tx);
}
public void unInstallDhcpEntries(BigInteger dpnId, String vmMacAddress,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpFlowEntry(dpnId, NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL,
vmMacAddress, NwConstants.DEL_FLOW, mdsalUtil, dhcpServiceCounters, tx);
}
private void installDhcpDropAction(BigInteger dpn, String vmMacAddress,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpDropAction(dpn, NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL,
vmMacAddress, NwConstants.ADD_FLOW, mdsalUtil, dhcpServiceCounters, tx);
}
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
}
public void installDhcpEntries(@Nullable BigInteger dpnId, @Nullable String vmMacAddress,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpFlowEntry(dpnId, NwConstants.DHCP_TABLE, vmMacAddress, NwConstants.ADD_FLOW,
mdsalUtil, dhcpServiceCounters, tx);
}
public void unInstallDhcpEntries(@Nullable BigInteger dpId, @Nullable String vmMacAddress,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpFlowEntry(dpId, NwConstants.DHCP_TABLE, vmMacAddress, NwConstants.DEL_FLOW,
mdsalUtil, dhcpServiceCounters, tx);
}
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,
- TypedReadWriteTransaction<Configuration> tx) {
+ TypedReadWriteTransaction<Configuration> tx)
+ throws ExecutionException, InterruptedException {
if (dpId == null || dpId.equals(DhcpMConstants.INVALID_DPID) || vmMacAddress == null) {
return;
}
if (addOrRemove == NwConstants.DEL_FLOW) {
LOG.trace("Removing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
dhcpServiceCounters.removeDhcpFlow();
- 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);
- }
+ mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
} 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) {
+ TypedReadWriteTransaction<Configuration> tx)
+ throws ExecutionException, InterruptedException {
if (dpId == null || dpId.equals(DhcpMConstants.INVALID_DPID) || vmMacAddress == null) {
return;
}
if (addOrRemove == NwConstants.DEL_FLOW) {
LOG.trace("Removing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
dhcpServiceCounters.removeDhcpDropFlow();
- 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);
- }
+ mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
} else {
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY,
}
}
- @SuppressWarnings("checkstyle:IllegalCatch")
public static void setupDhcpArpRequest(BigInteger dpId, short tableId, BigInteger vni, String dhcpIpAddress,
int lportTag, Long elanTag, boolean add, IMdsalApiManager mdsalUtil) {
List<MatchInfo> matches = getDhcpArpMatch(vni, dhcpIpAddress);
import com.google.common.base.Preconditions;
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;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
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) {
- try {
- int ifTag = interfaceInfo.getInterfaceTag();
- Flow flow = MDSALUtil.buildFlow(NwConstants.ELAN_FILTER_EQUALS_TABLE,
- getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"));
+ TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
+ 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,
- 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());
+ 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);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flowEntity);
}
private List<Bucket> getRemoteBCGroupBucketInfos(ElanInstance elanInfo, int bucketKeyStart,
import java.util.List;
import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
}
private void deleteMacEntryFromDsAndRemoveFlows(String elanName,
- TypedWriteTransaction<Operational> interfaceTx, TypedReadWriteTransaction<Configuration> flowTx) {
+ TypedWriteTransaction<Operational> interfaceTx, TypedReadWriteTransaction<Configuration> flowTx)
+ throws ExecutionException, InterruptedException {
LOG.trace("Deleting mac address {} and interface name {} from ElanInterfaceForwardingEntries "
+ "and ElanForwardingTables DS", macAddress, interfaceName);
PhysAddress physAddress = new PhysAddress(macAddress);
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;
}
public void deleteMacFlows(@Nullable ElanInstance elanInfo, @Nullable InterfaceInfo interfaceInfo,
- MacEntry macEntry, TypedReadWriteTransaction<Configuration> flowTx) {
+ MacEntry macEntry, TypedReadWriteTransaction<Configuration> flowTx)
+ throws ExecutionException, InterruptedException {
if (elanInfo == null || interfaceInfo == null) {
return;
}
}
public void deleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
- boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) {
+ boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx)
+ throws ExecutionException, InterruptedException {
String elanInstanceName = elanInfo.getElanInstanceName();
List<DpnInterfaces> remoteFEs = getInvolvedDpnsInElan(elanInstanceName);
BigInteger srcdpId = interfaceInfo.getDpId();
private void executeEtreeDeleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
boolean deleteSmac, String elanInstanceName, BigInteger srcdpId, Long elanTag, BigInteger dstDpId,
- TypedReadWriteTransaction<Configuration> flowTx) {
+ TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
EtreeLeafTagName etreeLeafTag = elanEtreeUtils.getEtreeLeafTagByElanTag(elanTag);
if (etreeLeafTag != null) {
executeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId,
}
}
- // 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) {
+ TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
boolean isFlowsRemovedInSrcDpn = false;
if (dstDpId.equals(srcdpId)) {
isFlowsRemovedInSrcDpn = true;
deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
} else if (isDpnPresent(dstDpId)) {
- try {
- mdsalManager
- .removeFlow(flowTx, dstDpId,
- 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);
- }
+ mdsalManager
+ .removeFlow(flowTx, dstDpId,
+ MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
+ NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)));
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) {
+ boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx)
+ throws ExecutionException, InterruptedException {
String elanInstanceName = elanInfo.getElanInstanceName();
long ifTag = interfaceInfo.getInterfaceTag();
BigInteger srcdpId = interfaceInfo.getDpId();
Long elanTag = elanInfo.getElanTag();
- 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)));
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
+ 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)));
LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}",
elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
import java.math.BigInteger;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
* @return returns success/failure.
*/
boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId);
+ BigInteger primarySwitchId) throws ExecutionException, InterruptedException;
/**
* Removes snat flows for the dpnId.
* @return returns success/failure.
*/
boolean removeSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers, BigInteger primarySwitchId,
- BigInteger dpnId);
+ BigInteger dpnId) throws ExecutionException, InterruptedException;
}
import java.math.BigInteger;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
void removeNatServiceListener(SnatServiceListener aclServiceListner);
void notify(TypedReadWriteTransaction<Configuration> confTx,
- Routers router, BigInteger primarySwitchId, BigInteger dpnId, Action action);
+ Routers router, BigInteger primarySwitchId, BigInteger dpnId, Action action)
+ throws ExecutionException, InterruptedException;
}
import java.math.BigInteger;
import java.time.Duration;
+import java.util.concurrent.ExecutionException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
}
private void handleAdd(TypedReadWriteTransaction<Datastore.Configuration> confTx,
- String routerName, Routers router, BigInteger primarySwitchId) {
+ String routerName, Routers router, BigInteger primarySwitchId)
+ throws ExecutionException, InterruptedException {
if (router != null) {
natDataUtil.addtoRouterMap(router);
snatServiceManger.notify(confTx, router, primarySwitchId, null,
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.time.Duration;
import java.util.ArrayList;
@Override
public boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) {
+ BigInteger primarySwitchId) throws ExecutionException, InterruptedException {
LOG.info("handleSnatAllSwitch : Handle Snat in all switches for router {}", routers.getRouterName());
String routerName = routers.getRouterName();
List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
@Override
public boolean removeSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ BigInteger primarySwitchId, BigInteger dpnId) throws ExecutionException, InterruptedException {
// Handle non NAPT switches and NAPT switches separately
if (!dpnId.equals(primarySwitchId)) {
}
protected void removeSnatCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(confTx, routerName);
removeDefaultFibRouteForSNAT(confTx, dpnId, routerId);
}
protected void removeSnatCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
removeDefaultFibRouteForSNAT(confTx, dpnId, routerId);
Routers routers, BigInteger dpnId);
protected abstract void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId);
+ Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException;
protected abstract void addSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
Routers routers, BigInteger dpnId);
}
protected void removeInboundFibEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- String externalIp, Long routerId, String subNetId) {
-
+ String externalIp, Long routerId, String subNetId) throws ExecutionException, InterruptedException {
String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, routerId);
flowRef = flowRef + "inbound" + externalIp;
removeFlow(confTx, dpnId, NwConstants.L3_FIB_TABLE, flowRef);
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) {
+ Long routerId, String routerName) throws ExecutionException, InterruptedException {
LOG.debug("installSnatMissEntry : Removing SNAT miss entry from switch {}", dpnId);
// Install the select group
long groupId = createGroupId(getGroupIdKey(routerName));
LOG.debug("removing the PSNAT to NAPTSwitch on DPN {} with GroupId: {}", dpnId, groupId);
- try {
- mdsalManager.removeGroup(confTx, dpnId, groupId);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeGroup(confTx, dpnId, groupId);
// Install miss entry pointing to group
LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}",
}
protected void removeInboundTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) {
-
+ BigInteger dpnId, Long routerId) throws ExecutionException, InterruptedException {
//Install the tunnel table entry in NAPT switch for inbound traffic to SNAP IP from a non a NAPT switch.
LOG.info("installInboundTerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
}
protected void removeDefaultFibRouteForSNAT(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long extNetId) {
-
+ Long extNetId) throws ExecutionException, InterruptedException {
String flowRef = "DefaultFibRouteForSNAT" + getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, extNetId);
removeFlow(confTx, dpnId, NwConstants.L3_FIB_TABLE, flowRef);
}
protected String getFlowRef(BigInteger dpnId, short tableId, long routerID) {
- return new StringBuilder().append(NatConstants.NAPT_FLOWID_PREFIX).append(dpnId).append(NatConstants
- .FLOWID_SEPARATOR).append(tableId).append(NatConstants.FLOWID_SEPARATOR).append(routerID).toString();
- }
-
- protected void syncFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpId, short tableId,
- String flowId, int priority, String flowName, BigInteger cookie, List<? extends MatchInfoBase> matches,
- List<InstructionInfo> instructions, int addOrRemove) {
- if (addOrRemove == NwConstants.DEL_FLOW) {
- removeFlow(confTx, dpId, tableId, flowId);
- } else {
- addFlow(confTx, dpId, tableId, flowId, priority, flowName, cookie, matches, instructions);
- }
+ return NatConstants.NAPT_FLOWID_PREFIX + dpnId + NatConstants.FLOWID_SEPARATOR
+ + tableId + NatConstants.FLOWID_SEPARATOR + routerID;
}
protected void addFlow(TypedWriteTransaction<Configuration> confTx, BigInteger dpId, short tableId,
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) {
+ String flowId) throws ExecutionException, InterruptedException {
LOG.trace("syncFlow : Removing Acl Flow DpnId {}, flowId {}", dpId, flowId);
- try {
- mdsalManager.removeFlow(confTx, dpId, flowId, tableId);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, dpId, flowId, tableId);
}
protected long createGroupId(String groupIdKey) {
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
@Override
protected void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
LOG.info("installSnatSpecificEntriesForNaptSwitch: called for router {}",
routers.getRouterName());
String routerName = routers.getRouterName();
}
protected void removeSnatMissEntryForPrimrySwch(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId) {
+ Long routerId) throws ExecutionException, InterruptedException {
LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
}
protected void removeTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId) {
+ Long routerId) throws ExecutionException, InterruptedException {
LOG.info("installTerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
}
protected void removeOutboundTblTrackEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId) {
+ Long routerId) throws ExecutionException, InterruptedException {
LOG.info("createOutboundTblTrackEntry : called for switch {}, routerId {}", dpnId, routerId);
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
}
protected void removeOutboundTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId) {
+ long routerId) throws ExecutionException, InterruptedException {
LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
}
protected void removeNaptPfibFlow(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId, long routerId) {
+ BigInteger dpnId, long routerId) throws ExecutionException, InterruptedException {
Long extNetId = NatUtil.getVpnId(confTx, routers.getNetworkId().getValue());
LOG.info("installNaptPfibFlow : dpId {}, extNetId {}", dpnId, extNetId);
String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "OUTBOUND";
}
protected void removeInboundEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId) {
+ long routerId) throws ExecutionException, InterruptedException {
LOG.info("installInboundEntry : dpId {} and routerId {}", dpnId, routerId);
String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId) + "OUTBOUND";
}
protected void removeNaptPfibEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId) {
+ long routerId) throws ExecutionException, InterruptedException {
LOG.info("installNaptPfibEntry : called for dpnId {} and routerId {} ", dpnId, routerId);
String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "INBOUND";
removeFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);
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;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Singleton;
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) {
+ private void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on DpnId {} "
+ "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.PDNAT_TABLE,
dpnId, l3Vni);
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);
- try {
- mdsalManager.removeFlow(confTx, dpnId, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, dpnId, flowEntity);
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 java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
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) {
+ BigInteger naptSwitch, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
//Handling VXLAN Provider type flow removal from old NAPT switch
Long vpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
if (vpnId == NatConstants.INVALID_ID) {
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);
- try {
- mdsalManager.removeFlow(confTx, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, flowEntity);
//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);
- try {
- mdsalManager.removeFlow(confTx, tsNatFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
-
+ mdsalManager.removeFlow(confTx, tsNatFlowEntity);
}
private String getFlowRefTs(BigInteger dpnId, short tableId, long routerID) {
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;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Singleton;
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) {
+ public void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on NAPT DpnId {} "
+ "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE,
NwConstants.INBOUND_NAPT_TABLE, dpnId, l3Vni);
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);
- try {
- mdsalManager.removeFlow(confTx, dpnId, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, dpnId, flowEntity);
LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}",
flowEntity, dpnId);
}
}
}
- private void associateExternalNetworkWithVPN(Networks network, TypedReadWriteTransaction<Configuration> confTx) {
+ private void associateExternalNetworkWithVPN(Networks network, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
List<Uuid> routerIds = network.getRouterIds();
for (Uuid routerId : routerIds) {
//long router = NatUtil.getVpnId(dataBroker, routerId.getValue());
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;
}
private void addOrDelDefFibRouteToSNAT(String routerName, long routerId, long bgpVpnId,
- Uuid bgpVpnUuid, boolean create, TypedReadWriteTransaction<Configuration> confTx) {
+ Uuid bgpVpnUuid, boolean create, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
//Check if BGP VPN exists. If exists then invoke the new method.
if (bgpVpnId != NatConstants.INVALID_ID) {
if (bgpVpnUuid != null) {
}
private void addOrDelDefaultFibRouteForSNAT(String routerName, long routerId, boolean create,
- TypedReadWriteTransaction<Configuration> confTx) {
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
if (switches.isEmpty()) {
LOG.info("addOrDelDefaultFibRouteForSNAT : No switches found for router {}", routerName);
}
private void removeDefaultFibRouteForSnatWithBgpVpn(String routerName, long routerId,
- long bgpVpnId, TypedReadWriteTransaction<Configuration> confTx) {
+ long bgpVpnId, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
List<BigInteger> dpnIds = NatUtil.getDpnsForRouter(dataBroker, routerName);
if (dpnIds.isEmpty()) {
LOG.error("addOrDelDefaultFibRouteForSNATWIthBgpVpn: No dpns are part of router {} to program "
})), NatConstants.NAT_DJC_MAX_RETRIES);
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void handleDisableSnat(Routers router, Uuid networkUuid, @Nonnull Collection<String> externalIps,
boolean routerFlag, String vpnName, BigInteger naptSwitchDpnId,
long routerId, TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
removeNaptFlowsFromActiveSwitch(routerId, routerName, naptSwitchDpnId, networkUuid, vpnName, externalIps,
externalSubnetList, removeFlowInvTx, extNwProvType);
removeFlowsFromNonActiveSwitches(routerId, routerName, naptSwitchDpnId, removeFlowInvTx);
- try {
- String externalSubnetVpn = null;
- for (Uuid externalSubnetId : externalSubnetList) {
- Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(dataBroker, externalSubnetId);
- // externalSubnet data model will exist for FLAT/VLAN external netowrk UCs.
- if (externalSubnet.isPresent()) {
- externalSubnetVpn = externalSubnetId.getValue();
- clrRtsFromBgpAndDelFibTs(naptSwitchDpnId, routerId, networkUuid, externalIps, externalSubnetVpn,
- router.getExtGwMacAddress(), removeFlowInvTx);
- }
- }
- if (externalSubnetVpn == null) {
- clrRtsFromBgpAndDelFibTs(naptSwitchDpnId, routerId, networkUuid, externalIps, vpnName,
+ String externalSubnetVpn = null;
+ for (Uuid externalSubnetId : externalSubnetList) {
+ Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(dataBroker, externalSubnetId);
+ // externalSubnet data model will exist for FLAT/VLAN external netowrk UCs.
+ if (externalSubnet.isPresent()) {
+ externalSubnetVpn = externalSubnetId.getValue();
+ clrRtsFromBgpAndDelFibTs(naptSwitchDpnId, routerId, networkUuid, externalIps, externalSubnetVpn,
router.getExtGwMacAddress(), removeFlowInvTx);
}
- } catch (Exception ex) {
- LOG.error("handleDisableSnat : Failed to remove fib entries for routerId {} in naptSwitchDpnId {}",
- routerId, naptSwitchDpnId, ex);
+ }
+ if (externalSubnetVpn == null) {
+ clrRtsFromBgpAndDelFibTs(naptSwitchDpnId, routerId, networkUuid, externalIps, vpnName,
+ router.getExtGwMacAddress(), removeFlowInvTx);
}
// Use the NaptMananager removeMapping API to remove the entire list of IP addresses maintained
// for the router ID.
LOG.debug("handleDisableSnat : Remove the Internal to external IP address maintained for the "
+ "router ID {} in the DS", routerId);
naptManager.removeMapping(routerId);
- } catch (Exception ex) {
- LOG.error("handleDisableSnat : Exception while handling disableSNAT for router :{}", routerName, ex);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("handleDisableSnat : Exception while handling disableSNAT for router :{}", routerName, e);
}
LOG.info("handleDisableSnat : Exit");
}
+ "in naptSwitchDpnId {}", routerId, naptSwitchDpnId, ex);
}
NatOverVxlanUtil.releaseVNI(vpnId, idManager);
- } catch (Exception ex) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("handleDisableSnatInternetVpn: Exception while handling disableSNATInternetVpn for router {} "
- + "with internet vpn {}", routerName, vpnId, ex);
+ + "with internet vpn {}", routerName, vpnId, e);
}
LOG.debug("handleDisableSnatInternetVpn: Processed handle disable snat for router {} with internet vpn {}",
routerName, vpnId);
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) {
- 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);
- }
+ ProviderTypes extNwProvType)
+ throws InterruptedException, ExecutionException {
- //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);
+ LOG.debug("removeNaptFlowsFromActiveSwitch : Remove NAPT flows from Active switch");
+ BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(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);
+ //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);
- String outboundUdpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
- NwConstants.IP_PROT_UDP);
- FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
- outboundUdpNatFlowRef);
- mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+ 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);
- String icmpDropFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
- NwConstants.IP_PROT_ICMP);
- FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
- icmpDropFlowRef);
- mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
- boolean lastRouterOnExternalNetwork =
- !NatUtil.checkForRoutersWithSameExtNetAndNaptSwitch(dataBroker, networkId, routerName, dpnId);
- if (lastRouterOnExternalNetwork) {
- 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 && !NatUtil.checkForRoutersWithSameExtSubnetAndNaptSwitch(
- dataBroker, externalSubnetId, routerName, dpnId)) {
- 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,
- subnetVpnId, dpnId);
- }
+ //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);
+ }
+
+ //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,
+ NwConstants.IP_PROT_TCP);
+ FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ outboundTcpNatFlowRef);
+ mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
+
+ String outboundUdpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+ NwConstants.IP_PROT_UDP);
+ FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ outboundUdpNatFlowRef);
+ mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+
+ String icmpDropFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+ NwConstants.IP_PROT_ICMP);
+ FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+ icmpDropFlowRef);
+ mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
+ boolean lastRouterOnExternalNetwork =
+ !NatUtil.checkForRoutersWithSameExtNetAndNaptSwitch(dataBroker, networkId, routerName, dpnId);
+ if (lastRouterOnExternalNetwork) {
+ 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 && !NatUtil.checkForRoutersWithSameExtSubnetAndNaptSwitch(
+ dataBroker, externalSubnetId, routerName, dpnId)) {
+ 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,
+ 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);
-
- if (lastRouterOnExternalNetwork) {
- // 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 {}",
- vpnName);
- 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);
+ //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);
+
+ if (lastRouterOnExternalNetwork) {
+ // 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 {}",
+ vpnName);
+ vpnId = NatUtil.getVpnId(dataBroker, vpnName);
+ LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId for disassociate nw with vpn scenario {}",
+ vpnId);
}
- //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;
+ 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);
}
+ }
- 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
- + 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);
-
- 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);
-
- 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);
+ //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;
+ }
- 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);
+ 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
+ + 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);
+
+ 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);
+
+ 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);
+
+ 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);
}
- } 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) {
+ TypedReadWriteTransaction<Configuration> writeFlowInvTx)
+ throws ExecutionException, InterruptedException {
long extVpnId = NatConstants.INVALID_ID;
if (networkId != null) {
Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
+ " 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);
- try {
- mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
}
}
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) {
+ TypedReadWriteTransaction<Configuration> writeFlowInvTx)
+ throws ExecutionException, InterruptedException {
LOG.debug("removeNaptFlowsFromActiveSwitchInternetVpn : Remove NAPT flows from Active switch Internet Vpn");
BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
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);
- try {
- mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
// 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);
- try {
- mdsalManager.removeFlow(writeFlowInvTx, outboundNaptFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(writeFlowInvTx, outboundNaptFlowEntity);
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);
- try {
- mdsalManager.removeFlow(writeFlowInvTx, inboundNaptFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(writeFlowInvTx, inboundNaptFlowEntity);
// 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) {
+ BigInteger naptSwitchDpnId, TypedReadWriteTransaction<Configuration> removeFlowInvTx)
+ throws ExecutionException, InterruptedException {
LOG.debug("removeFlowsFromNonActiveSwitches : Remove NAPT related flows from non active switches");
// Remove the flows from the other switches which points to the primary and secondary switches
LOG.error("removeFlowsFromNonActiveSwitches : Unable to get the swithces for the router {}", routerName);
return;
}
- try {
- for (BigInteger dpnId : allSwitchList) {
- if (!naptSwitchDpnId.equals(dpnId)) {
- LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
+ 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 "
- + "with the DPN ID {} and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
- mdsalManager.removeFlow(removeFlowInvTx, preSnatFlowEntity);
+ 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);
- //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 "
- + "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
- mdsalManager.removeGroup(removeFlowInvTx, preSnatGroupEntity);
+ //Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
+ long groupId = createGroupId(getGroupIdKey(routerName));
- }
+ LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with "
+ + "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
+ mdsalManager.removeGroup(removeFlowInvTx, dpnId, groupId);
}
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
}
}
public void clrRtsFromBgpAndDelFibTs(final BigInteger dpnId, Long routerId, Uuid networkUuid,
@Nonnull Collection<String> externalIps, String vpnName,
- String extGwMacAddress, TypedReadWriteTransaction<Configuration> confTx) {
+ String extGwMacAddress, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
//Withdraw the corresponding routes from the BGP.
//Get the network ID using the router ID.
LOG.debug("clrRtsFromBgpAndDelFibTs : Advertise to BGP and remove routes for externalIps {} with routerId {},"
protected void clrRtsFromBgpAndDelFibTs(final BigInteger dpnId, long routerId, String extIp, final String vpnName,
final Uuid networkUuid, String extGwMacAddress,
- TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
+ TypedReadWriteTransaction<Configuration> removeFlowInvTx)
+ throws ExecutionException, InterruptedException {
clearBgpRoutes(extIp, vpnName);
delFibTsAndReverseTraffic(dpnId, routerId, extIp, vpnName, networkUuid, extGwMacAddress, false,
removeFlowInvTx);
protected void delFibTsAndReverseTraffic(final BigInteger dpnId, long routerId, String extIp,
final String vpnName, Uuid extNetworkId, long tempLabel,
String gwMacAddress, boolean switchOver,
- TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
+ TypedReadWriteTransaction<Configuration> removeFlowInvTx)
+ throws ExecutionException, InterruptedException {
LOG.debug("delFibTsAndReverseTraffic : Removing fib entry for externalIp {} in routerId {}", extIp, routerId);
String routerName = NatUtil.getRouterName(dataBroker,routerId);
if (routerName == null) {
private void delFibTsAndReverseTraffic(final BigInteger dpnId, long routerId, String extIp, final String vpnName,
final Uuid networkUuid, String extGwMacAddress, boolean switchOver,
- TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
+ TypedReadWriteTransaction<Configuration> removeFlowInvTx)
+ throws ExecutionException, InterruptedException {
LOG.debug("delFibTsAndReverseTraffic : Removing fib entry for externalIp {} in routerId {}", extIp, routerId);
String routerName = NatUtil.getRouterName(dataBroker,routerId);
if (routerName == null) {
protected void clearFibTsAndReverseTraffic(final BigInteger dpnId, Long routerId, Uuid networkUuid,
List<String> externalIps, String vpnName, String extGwMacAddress,
- TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
+ TypedReadWriteTransaction<Configuration> writeFlowInvTx)
+ throws ExecutionException, InterruptedException {
//Withdraw the corresponding routes from the BGP.
//Get the network ID using the router ID.
LOG.debug("clearFibTsAndReverseTraffic : for externalIps {} with routerId {},"
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) {
+ TypedReadWriteTransaction<Configuration> writeFlowInvTx) throws ExecutionException, InterruptedException {
LOG.info("removeTunnelTableEntry : called with DpnId = {} and label = {}", dpnId, serviceId);
- List<MatchInfo> mkMatches = new ArrayList<>();
- // Matching metadata
- mkMatches.add(new MatchTunnelId(BigInteger.valueOf(serviceId)));
- Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE,
- 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);
- try {
- mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(writeFlowInvTx, dpnId,
+ getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""), NwConstants.INTERNAL_TUNNEL_TABLE);
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<>();
- matches.add(MatchEthernetType.MPLS_UNICAST);
- matches.add(new MatchMplsLabel(serviceId));
-
+ TypedReadWriteTransaction<Configuration> writeFlowInvTx) throws ExecutionException, InterruptedException {
String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, serviceId, "");
-
LOG.debug("removeLFibTableEntry : with flow ref {}", flowRef);
-
- Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef,
- 10, flowRef, 0, 0,
- COOKIE_VM_LFIB_TABLE, matches, null);
-
- try {
- mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
-
+ mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowRef, NwConstants.L3_LFIB_TABLE);
LOG.debug("removeLFibTableEntry : dpID : {} label : {} removed successfully", dpnId, serviceId);
}
import java.math.BigInteger;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
import org.opendaylight.genius.infra.Datastore.Configuration;
@Override
public boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) {
+ BigInteger primarySwitchId) throws ExecutionException, InterruptedException {
return !checkProviderType(confTx, routers) && super.removeSnatAllSwitch(confTx, routers, primarySwitchId);
}
@Override
public boolean removeSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ BigInteger primarySwitchId, BigInteger dpnId) throws ExecutionException, InterruptedException {
return !checkProviderType(confTx, routers) && super.removeSnat(confTx, routers, primarySwitchId, dpnId);
}
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;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
}
}
- // 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) {
- try {
- FlowEntity preFlowEntity = buildPreDNATDeleteFlowEntity(dpnId, externalIp, routerId);
- mdsalManager.removeFlow(confTx, preFlowEntity);
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
+ FlowEntity preFlowEntity = buildPreDNATDeleteFlowEntity(dpnId, externalIp, routerId);
+ mdsalManager.removeFlow(confTx, preFlowEntity);
- 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);
+ FlowEntity flowEntity = buildDNATDeleteFlowEntity(dpnId, internalIp, routerId);
+ if (flowEntity != null) {
+ mdsalManager.removeFlow(confTx, flowEntity);
}
}
}
}
- // 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) {
- try {
- FlowEntity preFlowEntity = buildPreSNATDeleteFlowEntity(dpnId, internalIp, routerId);
- mdsalManager.removeFlow(removeFlowInvTx, preFlowEntity);
+ TypedReadWriteTransaction<Configuration> removeFlowInvTx)
+ throws ExecutionException, InterruptedException {
+ FlowEntity preFlowEntity = buildPreSNATDeleteFlowEntity(dpnId, internalIp, routerId);
+ mdsalManager.removeFlow(removeFlowInvTx, preFlowEntity);
- 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);
+ FlowEntity flowEntity = buildSNATDeleteFlowEntity(dpnId, externalIp, vpnId);
+ if (flowEntity != null) {
+ mdsalManager.removeFlow(removeFlowInvTx, flowEntity);
}
}
void createNATFlowEntries(String interfaceName, final InternalToExternalPortMap mapping,
final InstanceIdentifier<RouterPorts> portIid, final String routerName,
- TypedReadWriteTransaction<Configuration> confTx) {
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
if (!validateIpMapping(mapping)) {
LOG.error("createNATFlowEntries : Not a valid ip addresses in the mapping {}", mapping);
return;
}
void createNATFlowEntries(BigInteger dpnId, String interfaceName, String routerName, Uuid externalNetworkId,
- InternalToExternalPortMap mapping, TypedReadWriteTransaction<Configuration> confTx) {
+ InternalToExternalPortMap mapping, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
String internalIp = mapping.getInternalIp();
long routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
}
void createNATOnlyFlowEntries(BigInteger dpnId, String routerName, String associatedVPN,
- Uuid externalNetworkId, InternalToExternalPortMap mapping) {
+ Uuid externalNetworkId, InternalToExternalPortMap mapping)
+ throws ExecutionException, InterruptedException {
String internalIp = mapping.getInternalIp();
//String segmentId = associatedVPN == null ? routerName : associatedVPN;
LOG.debug("createNATOnlyFlowEntries : Retrieving vpn id for VPN {} to proceed with create NAT Flows",
void removeNATFlowEntries(String interfaceName, final InternalToExternalPortMap mapping,
InstanceIdentifier<RouterPorts> portIid, final String routerName, BigInteger dpnId,
- TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
+ TypedReadWriteTransaction<Configuration> removeFlowInvTx)
+ throws ExecutionException, InterruptedException {
String internalIp = mapping.getInternalIp();
String externalIp = mapping.getExternalIp();
//Get the DPN on which this interface resides
}
void removeNATFlowEntries(BigInteger dpnId, String interfaceName, String vpnName, String routerName,
- InternalToExternalPortMap mapping, TypedReadWriteTransaction<Configuration> confTx) {
+ InternalToExternalPortMap mapping, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
String internalIp = mapping.getInternalIp();
String externalIp = mapping.getExternalIp();
long routerId = NatUtil.getVpnId(dataBroker, routerName);
}
private void addOrDelDefaultFibRouteForDnat(BigInteger dpnId, String routerName, long routerId,
- TypedReadWriteTransaction<Configuration> confTx, boolean create) {
+ TypedReadWriteTransaction<Configuration> confTx, boolean create)
+ throws ExecutionException, InterruptedException {
if (confTx == null) {
ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
newTx -> addOrDelDefaultFibRouteForDnat(dpnId, routerName, routerId, newTx, create)), LOG,
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;
}
}
- /* This method checks the switch that gone down is a NaptSwitch for a router.
- If it is a NaptSwitch
- 1) selects new NAPT switch
- 2) installs nat flows in new NAPT switch
- table 21(FIB)->26(PSNAT)->group(resubmit/napttunnel)->36(Terminating)->46(outbound)->47(resubmit)->21
- 3) modify the group and miss entry flow in other vSwitches pointing to newNaptSwitch
- 4) Remove nat flows in oldNaptSwitch
- */
- /*public void handleNaptSwitchDown(BigInteger dpnId){
-
- LOG.debug("handleNaptSwitchDown method is called with dpnId {}",dpnId);
- BigInteger naptSwitch;
- try {
- NaptSwitches naptSwitches = NatUtil.getNaptSwitch(dataBroker);
- if (naptSwitches == null || naptSwitches.getRouterToNaptSwitch() == null
- || naptSwitches.getRouterToNaptSwitch().isEmpty()) {
- LOG.debug("NaptSwitchDown: NaptSwitch is not allocated for none of the routers");
- return;
- }
- for (RouterToNaptSwitch routerToNaptSwitch : naptSwitches.getRouterToNaptSwitch()) {
- String routerName = routerToNaptSwitch.getRouterName();
- naptSwitch = routerToNaptSwitch.getPrimarySwitchId();
- boolean naptStatus = isNaptSwitchDown(routerName,dpnId,naptSwitch);
- if (!naptStatus) {
- LOG.debug("NaptSwitchDown: Switch with DpnId {} is not naptSwitch for router {}",
- dpnId, routerName);
- } else {
- removeSnatFlowsInOldNaptSwitch(routerName,naptSwitch);
- return;
- }
- }
- } catch (Exception ex) {
- LOG.error("Exception in handleNaptSwitchDown method {}",ex);
- }
- }*/
-
- // 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) {
+ TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
- 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 "
- + "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,
- routerName);
- String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
- tunnelId);
- FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
- tsFlowRef);
-
- 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 {}",
- 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 outboundUdpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
- NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_UDP);
- FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
- NwConstants.OUTBOUND_NAPT_TABLE, outboundUdpNatFlowRef);
- mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
-
- String icmpDropFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
- NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_ICMP);
- FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
- icmpDropFlowRef);
- 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 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);
- for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
- long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
- if (subnetVpnId != -1 && !NatUtil.checkForRoutersWithSameExtSubnetAndNaptSwitch(
- dataBroker, externalSubnetId, routerName, naptSwitch)) {
- String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch,
- NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
- 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,
- subnetVpnId, naptSwitch);
- }
- }
+ 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,
+ routerName);
+ String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
+ tunnelId);
+ FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
+ tsFlowRef);
- // 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 && !NatUtil.checkForRoutersWithSameExtNetAndNaptSwitch(
- dataBroker, networkId, routerName, naptSwitch)) {
- 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;
- }
- }
- }
- if (!switchSharedByRouters) {
- Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
- if (vpnId != NatConstants.INVALID_ID) {
- String naptFibflowRef =
- externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, vpnId);
- FlowEntity naptFibFlowEntity =
- NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptFibflowRef);
- 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 {}",
- routerId);
- return;
- }
- }
+ + "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 {}",
+ 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 outboundUdpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+ NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_UDP);
+ FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
+ NwConstants.OUTBOUND_NAPT_TABLE, outboundUdpNatFlowRef);
+ mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+
+ String icmpDropFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+ NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_ICMP);
+ FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
+ icmpDropFlowRef);
+ 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,
+ routerName);
+ for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
+ long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
+ if (subnetVpnId != -1 && !NatUtil.checkForRoutersWithSameExtSubnetAndNaptSwitch(
+ dataBroker, externalSubnetId, routerName, naptSwitch)) {
+ String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch,
+ NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
+ 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,
+ subnetVpnId, naptSwitch);
}
+ }
- //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 {} "
- + "for router {} and externalIps {} label {}", naptSwitch, routerId, externalIp, label);
+ // 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 && !NatUtil.checkForRoutersWithSameExtNetAndNaptSwitch(
+ dataBroker, networkId, routerName, naptSwitch)) {
+ 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;
+ }
}
- } 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,
- externalIps);
+ }
+ if (!switchSharedByRouters) {
+ Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
+ if (vpnId != NatConstants.INVALID_ID) {
+ String naptFibflowRef =
+ externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, vpnId);
+ FlowEntity naptFibFlowEntity =
+ NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptFibflowRef);
+ 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.debug("removeSnatFlowsInOldNaptSwitch : External network not associated to router {}",
+ LOG.error("removeSnatFlowsInOldNaptSwitch : Invalid vpnId retrieved for routerId {}",
routerId);
+ return;
}
- 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 {}, "
- + "no flows need to be removed in oldNaptSwitch {}", routerId, naptSwitch);
- 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,
+ extNetworkId, label, gwMacAddress, true, confTx);
+ 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,
+ externalIps, null, gwMacAddress, confTx);
+ 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,
+ 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 {}, "
+ + "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;
}
- 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;
+ 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;
}
- 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);
-
- 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 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);
+
+ 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);
}
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
}
}
public boolean isNaptSwitchDown(String routerName, Long routerId, BigInteger dpnId, BigInteger naptSwitch,
Long routerVpnId, Collection<String> externalIpCache,
- TypedReadWriteTransaction<Configuration> confTx) {
+ TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
return isNaptSwitchDown(routerName, routerId, dpnId, naptSwitch, routerVpnId, externalIpCache, true,
confTx);
}
@SuppressWarnings("checkstyle:IllegalCatch")
public boolean isNaptSwitchDown(String routerName, Long routerId, BigInteger dpnId, BigInteger naptSwitch,
Long routerVpnId, Collection<String> externalIpCache, boolean isClearBgpRts,
- TypedReadWriteTransaction<Configuration> confTx) {
+ TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
externalIpsCache = externalIpCache;
if (!naptSwitch.equals(dpnId)) {
LOG.debug("isNaptSwitchDown : DpnId {} is not a naptSwitch {} for Router {}",
}
protected void bestEffortDeletion(long routerId, String routerName, Map<String, Long> externalIpLabel,
- TypedReadWriteTransaction<Configuration> confTx) {
+ TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
Collection<String> newExternalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
if (externalIpsCache != null) {
Set<String> removedExternalIps = new HashSet<>(externalIpsCache);
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) {
+ IMdsalApiManager mdsalManager, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
List<MatchInfo> matchInfo = new ArrayList<>();
matchInfo.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matchInfo.add(new MatchEthernetSource(new MacAddress(macAddress)));
Flow l3GwMacTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_GW_MAC_TABLE,
flowRef, 21, flowRef, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, matchInfo, null);
- try {
- mdsalManager.removeFlow(confTx, dpnId, l3GwMacTableFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, dpnId, l3GwMacTableFlowEntity);
LOG.debug("removeL3GwMacTableEntry : Successfully removed flow entity {} on DPN = {}",
l3GwMacTableFlowEntity, dpnId);
}
//best effort to check IntExt model
naptSwitchHA.bestEffortDeletion(routerId, routerName, externalIpLabel, confTx);
}
- } catch (Exception ex) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("removeSNATFromDPN : SNAT->Exception while handling naptSwitch down for router {}",
- routerName, ex);
+ routerName, e);
}
}
}
private boolean hndlTepAddForAllRtrs(BigInteger srcDpnId, String tunnelType, String tunnelName, String srcTepIp,
- String destTepIp, TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
+ String destTepIp, TypedReadWriteTransaction<Configuration> writeFlowInvTx)
+ throws ExecutionException, InterruptedException {
LOG.trace("hndlTepAddForAllRtrs: TEP ADD ----- for EXTERNAL/HWVTEP ITM Tunnel, TYPE {} ,State is UP b/w SRC IP"
+ " : {} and DEST IP: {}", fibManager.getTransportTypeStr(tunnelType), srcTepIp, destTepIp);
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private boolean handleTepDelForAllRtrs(BigInteger srcDpnId, String tunnelType, String tunnelName, String srcTepIp,
- String destTepIp, TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
+ String destTepIp, TypedReadWriteTransaction<Configuration> writeFlowInvTx)
+ throws ExecutionException, InterruptedException {
LOG.trace("handleTepDelForAllRtrs : TEP DEL ----- for EXTERNAL/HWVTEP ITM Tunnel,TYPE {},State is UP b/w SRC IP"
+ " : {} and DEST IP: {}", fibManager.getTransportTypeStr(tunnelType), srcTepIp, destTepIp);
private void hndlTepAddForSnatInEachRtr(RoutersList router, long routerId, final BigInteger srcDpnId,
String tunnelType, String srcTepIp, String destTepIp, String tunnelName, String nextHopIp,
- ProviderTypes extNwProvType, TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
+ ProviderTypes extNwProvType, TypedReadWriteTransaction<Configuration> writeFlowInvTx)
+ throws ExecutionException, InterruptedException {
/*SNAT : Remove the old routes to the external IP having the old TEP IP as the next hop IP
Advertise to the BGP about the new route to the external IP having the new TEP IP
}
private void hndlTepDelForSnatInEachRtr(RoutersList router, long routerId, BigInteger dpnId, String tunnelType,
- String srcTepIp, String destTepIp, String tunnelName, ProviderTypes extNwProvType,
- TypedReadWriteTransaction<Configuration> confTx) {
+ String srcTepIp, String destTepIp, String tunnelName, ProviderTypes extNwProvType,
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
/*SNAT :
1) Elect a new switch as the primary NAPT
2) Advertise the new routes to BGP for the newly elected TEP IP as the DPN IP
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) {
+ IMdsalApiManager mdsalManager, BigInteger naptDpnId) throws ExecutionException, InterruptedException {
LOG.debug("removePreDnatToSnatTableEntry : Remove Pre-DNAT table {} --> table {} flow on NAPT DpnId {} ",
NwConstants.PDNAT_TABLE, NwConstants.INBOUND_NAPT_TABLE, naptDpnId);
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);
- try {
- mdsalManager.removeFlow(confTx, naptDpnId, preDnatToSnatTableFlowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, naptDpnId, flowRef, NwConstants.PDNAT_TABLE);
LOG.debug("removePreDnatToSnatTableEntry: Successfully removed Pre-DNAT flow {} on NAPT DpnId = {}",
- preDnatToSnatTableFlowEntity, naptDpnId);
+ flowRef, naptDpnId);
}
private static String getFlowRefPreDnatToSnat(BigInteger dpnId, short tableId, String uniqueId) {
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
LOG.trace("Update key: {}, original: {}, update: {}", update.key(), original, update);
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
void handleSNATForDPN(BigInteger dpnId, String routerName, long routerId, Long routerVpnId,
TypedReadWriteTransaction<Configuration> confTx, ProviderTypes extNwProvType) {
//Check if primary and secondary switch are selected, If not select the role
mdsalManager.addFlow(confTx, flowEntity);
}
- } catch (Exception ex) {
- LOG.error("handleSNATForDPN : Exception in handleSNATForDPN", ex);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("handleSNATForDPN : Exception in handleSNATForDPN", e);
}
}
//best effort to check IntExt model
naptSwitchHA.bestEffortDeletion(routerId, routerName, externalIpLabel, confTx);
}
- } catch (Exception ex) {
- LOG.error("removeSNATFromDPN : Exception while handling naptSwitch down for router {}", routerName, ex);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("removeSNATFromDPN : Exception while handling naptSwitch down for router {}", routerName, e);
}
}
//check router is associated to external network
String extNetwork = NatUtil.getAssociatedExternalNetwork(dataBroker, routerName);
if (extNetwork != null) {
- LOG.debug("onRouterAssociatedToVpn : Router {} is associated with ext nw {}", routerName, extNetwork);
- handleDNATConfigurationForRouterAssociation(routerName, vpnName, extNetwork);
- Uuid extNetworkUuid = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
- if (extNetworkUuid == null) {
- LOG.error("onRouterAssociatedToVpn : Unable to retrieve external network Uuid for router {}",
+ try {
+ LOG.debug("onRouterAssociatedToVpn : Router {} is associated with ext nw {}", routerName, extNetwork);
+ handleDNATConfigurationForRouterAssociation(routerName, vpnName, extNetwork);
+ Uuid extNetworkUuid = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
+ if (extNetworkUuid == null) {
+ LOG.error("onRouterAssociatedToVpn : Unable to retrieve external network Uuid for router {}",
routerName);
- return;
- }
- ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName,
+ return;
+ }
+ ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName,
extNetworkUuid);
- if (extNwProvType == null) {
- LOG.error("onRouterAssociatedToVpn : External Network Provider Type missing");
- return;
- }
- long routerId = NatUtil.getVpnId(dataBroker, routerName);
- try {
+ if (extNwProvType == null) {
+ LOG.error("onRouterAssociatedToVpn : External Network Provider Type missing");
+ return;
+ }
+ long routerId = NatUtil.getVpnId(dataBroker, routerName);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> externalRoutersListener.changeLocalVpnIdToBgpVpnId(routerName, routerId, vpnName, tx,
extNwProvType)).get();
//check router is associated to external network
String extNetwork = NatUtil.getAssociatedExternalNetwork(dataBroker, routerName);
if (extNetwork != null) {
- LOG.debug("onRouterDisassociatedFromVpn : Router {} is associated with ext nw {}", routerName, extNetwork);
- handleDNATConfigurationForRouterDisassociation(routerName, vpnName, extNetwork);
- Uuid extNetworkUuid = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
- if (extNetworkUuid == null) {
- LOG.error("onRouterDisassociatedFromVpn : Unable to retrieve external network Uuid for router {}",
- routerName);
- return;
- }
- ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName,
- extNetworkUuid);
- if (extNwProvType == null) {
- LOG.error("onRouterDisassociatedFromVpn : External Network Provider Type missing");
- return;
- }
- long routerId = NatUtil.getVpnId(dataBroker, routerName);
try {
+ LOG.debug("onRouterDisassociatedFromVpn : Router {} is associated with ext nw {}", routerName,
+ extNetwork);
+ handleDNATConfigurationForRouterDisassociation(routerName, vpnName, extNetwork);
+ Uuid extNetworkUuid = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
+ if (extNetworkUuid == null) {
+ LOG.error("onRouterDisassociatedFromVpn : Unable to retrieve external network Uuid for router {}",
+ routerName);
+ return;
+ }
+ ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName,
+ extNetworkUuid);
+ if (extNwProvType == null) {
+ LOG.error("onRouterDisassociatedFromVpn : External Network Provider Type missing");
+ return;
+ }
+ long routerId = NatUtil.getVpnId(dataBroker, routerName);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> externalRoutersListener.changeBgpVpnIdToLocalVpnId(routerName, routerId, vpnName, tx,
extNwProvType)).get();
}
}
- void handleDNATConfigurationForRouterAssociation(String routerName, String vpnName, String externalNetwork) {
+ void handleDNATConfigurationForRouterAssociation(String routerName, String vpnName, String externalNetwork)
+ throws ExecutionException, InterruptedException {
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName);
Optional<RouterPorts> optRouterPorts =
MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
}
}
- void handleDNATConfigurationForRouterDisassociation(String routerName, String vpnName, String externalNetwork) {
+ void handleDNATConfigurationForRouterDisassociation(String routerName, String vpnName, String externalNetwork)
+ throws ExecutionException, InterruptedException {
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName);
Optional<RouterPorts> optRouterPorts =
MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
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;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.inject.Singleton;
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) {
+ void removeDefNATRouteInDPN(BigInteger dpnId, long vpnId, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
FlowEntity flowEntity = buildDefNATFlowEntity(dpnId, vpnId);
if (flowEntity == null) {
LOG.error("removeDefNATRouteInDPN : Flow entity received is NULL."
return;
}
natServiceCounters.removeDefaultNatFlow();
- try {
- mdsalManager.removeFlow(confTx, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, flowEntity);
}
- // 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) {
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
FlowEntity flowEntity = buildDefNATFlowEntity(dpnId, bgpVpnId, routerId);
if (flowEntity == null) {
LOG.error("removeDefNATRouteInDPN : Flow entity received is NULL."
return;
}
natServiceCounters.removeDefaultNatFlow();
- try {
- mdsalManager.removeFlow(confTx, flowEntity);
- } catch (Exception e) {
- LOG.error("Error removing flow", e);
- throw new RuntimeException("Error removing flow", e);
- }
+ mdsalManager.removeFlow(confTx, flowEntity);
}
void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, long vpnId) {
import java.math.BigInteger;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.genius.infra.Datastore;
@Override
public void notify(TypedReadWriteTransaction<Datastore.Configuration> confTx,
- Routers router, BigInteger primarySwitchId, BigInteger dpnId, Action action) {
+ Routers router, BigInteger primarySwitchId, BigInteger dpnId, Action action)
+ throws ExecutionException, InterruptedException {
for (SnatServiceListener snatServiceListener : snatServiceListeners) {
boolean result = false;
switch (action) {
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;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Singleton;
+ 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) {
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
LOG.debug("removeTunnelTableEntry : called with DpnId = {} and label = {}", dpnId, serviceId);
- 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);
- }
+ mdsalManager.removeFlow(confTx, dpnId,
+ new FlowKey(new FlowId(getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""))),
+ NwConstants.INTERNAL_TUNNEL_TABLE);
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) {
+ TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, serviceId, "");
LOG.debug("removeLFibTableEntry : removing LFib entry with flow ref {}", flowRef);
- 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);
- }
+ mdsalManager.removeFlow(confTx, dpnId, new FlowKey(new FlowId(flowRef)), NwConstants.L3_LFIB_TABLE);
LOG.debug("removeLFibTableEntry : LFIB Entry for dpID : {} label : {} removed successfully",
dpnId, serviceId);
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
import org.opendaylight.genius.infra.Datastore.Configuration;
@Override
public boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) {
+ BigInteger primarySwitchId) throws ExecutionException, InterruptedException {
ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(confTx, routers.getNetworkId());
LOG.debug("VxlanGreConntrackBasedSnatService: handleSnatAllSwitch ProviderTypes {}", extNwProviderType);
if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
@Override
public boolean removeSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ BigInteger primarySwitchId, BigInteger dpnId) throws ExecutionException, InterruptedException {
ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(confTx, routers.getNetworkId());
LOG.debug("VxlanGreConntrackBasedSnatService: handleSnat ProviderTypes {}", extNwProviderType);
if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
@Override
protected void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
LOG.info("installSnatSpecificEntriesForNaptSwitch for router {}",
routers.getRouterName());
}
protected void removeOutboundTblTrackEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) {
+ BigInteger dpnId, Long routerId) throws ExecutionException, InterruptedException {
LOG.info("createOutboundTblTrackEntryForVxlanGre: Install Outbound tracking table flow on dpId {} for "
+ "routerId {}", dpnId, routerId);
}
protected void removeOutboundTblEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, List<ExternalIps> externalIps) {
+ long routerId, List<ExternalIps> externalIps) throws ExecutionException, InterruptedException {
LOG.info("createOutboundTblEntryForVxlanGre: Install Outbound table flow on dpId {} for routerId {}", dpnId,
routerId);
if (externalIps.isEmpty()) {
}
protected void removeNaptPfibFlowForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId, Long extNetVpnId) {
+ BigInteger dpnId, Long extNetVpnId) throws ExecutionException, InterruptedException {
LOG.info("installNaptPfibFlowForVxlanGre: Install Napt preFibFlow on dpId {} with matching extNetVpnId {} "
+ "for router {}", dpnId, extNetVpnId, routers.getRouterName());
String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, extNetVpnId);
}
protected void removeInboundEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, List<ExternalIps> externalIps) {
+ long routerId, List<ExternalIps> externalIps) throws ExecutionException, InterruptedException {
LOG.info("removeInboundEntryForVxlanGre: remove Inbound table entry on dpId {} for routerId {}",
dpnId, routerId);
if (externalIps.isEmpty()) {
}
protected void removeTerminatingServiceTblEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) {
+ BigInteger dpnId, Long routerId) throws ExecutionException, InterruptedException {
LOG.info("removeTerminatingServiceTblEntryForVxlanGre : removing entry for"
+ "Terminating Service Table for switch {}, routerId {}", dpnId, routerId);
@Override
protected void removeSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId, String routerName) {
+ Long routerId, String routerName) throws ExecutionException, InterruptedException {
LOG.debug("installSnatMissEntry : Removing SNAT miss entry in switch {}", dpnId);
String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.genius.infra.Datastore.Configuration;
@Deprecated
void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, WriteTransaction tx);
+ BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException;
void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, TypedWriteTransaction<Configuration> confTx);
+ BigInteger dpnId, TypedWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException;
@Deprecated
void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, WriteTransaction tx);
+ BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException;
void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, TypedReadWriteTransaction<Configuration> confTx);
+ BigInteger dpnId, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException;
@Deprecated
void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, WriteTransaction writeTx);
+ String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException;
void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, TypedWriteTransaction<Configuration> confTx);
+ String subnetVpnName, TypedWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException;
@Deprecated
void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, WriteTransaction writeTx);
+ String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException;
void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, TypedReadWriteTransaction<Configuration> confTx);
+ String subnetVpnName, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException;
@Deprecated
void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress,
import java.math.BigInteger;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.ExecutionException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
return this;
}
- private void setupRouterGwFlows(RouterToNaptSwitch routerToNaptSwitch, WriteTransaction writeTx, int addOrRemove) {
+ private void setupRouterGwFlows(RouterToNaptSwitch routerToNaptSwitch, WriteTransaction writeTx, int addOrRemove)
+ throws ExecutionException, InterruptedException {
Routers router = null;
if (addOrRemove == NwConstants.ADD_FLOW) {
router = vpnUtil.getExternalRouter(routerToNaptSwitch.getRouterName());
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;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.function.Consumer;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer;
import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
import org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput;
import org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder;
@Override
public void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, TypedWriteTransaction<Configuration> confTx) {
+ BigInteger dpnId, TypedWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
setupSubnetMacInVpnInstance(vpnName, subnetVpnName, srcMacAddress, dpnId,
(vpnId, dpId, subnetVpnId) -> addGwMac(srcMacAddress, confTx, vpnId, dpId, subnetVpnId));
}
@Override
public void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, WriteTransaction tx) {
+ BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException {
setupSubnetMacInVpnInstance(vpnName, subnetVpnName, srcMacAddress, dpnId,
(vpnId, dpId, subnetVpnId) -> addGwMac(srcMacAddress, tx, vpnId, dpId, subnetVpnId));
}
@Override
public void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, TypedReadWriteTransaction<Configuration> confTx) {
+ BigInteger dpnId, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
setupSubnetMacInVpnInstance(vpnName, subnetVpnName, srcMacAddress, dpnId,
(vpnId, dpId, subnetVpnId) -> removeGwMac(srcMacAddress, confTx, vpnId, dpId, subnetVpnId));
}
@Override
public void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, WriteTransaction tx) {
+ BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException {
setupSubnetMacInVpnInstance(vpnName, subnetVpnName, srcMacAddress, dpnId,
(vpnId, dpId, subnetVpnId) -> removeGwMac(srcMacAddress, tx, vpnId, dpId, subnetVpnId));
}
@FunctionalInterface
private interface VpnInstanceSubnetMacSetupMethod {
- void process(long vpnId, BigInteger dpId, long subnetVpnId);
+ void process(long vpnId, BigInteger dpId, long subnetVpnId) throws InterruptedException, ExecutionException;
}
private void setupSubnetMacInVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
- BigInteger dpnId, VpnInstanceSubnetMacSetupMethod consumer) {
+ BigInteger dpnId, VpnInstanceSubnetMacSetupMethod consumer)
+ throws ExecutionException, InterruptedException {
if (vpnName == null) {
LOG.warn("Cannot setup subnet MAC {} on DPN {}, null vpnName", srcMacAddress, dpnId);
return;
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) {
- 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);
- }
+ BigInteger dpId, long subnetVpnId) throws ExecutionException, InterruptedException {
+ mdsalManager.removeFlow(tx, dpId,
+ VpnUtil.getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, srcMacAddress, subnetVpnId),
+ NwConstants.L3_GW_MAC_TABLE);
}
@Override
public void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, TypedWriteTransaction<Configuration> confTx) {
+ String subnetVpnName, TypedWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
setupRouterGwMacFlow(routerName, routerGwMac, dpnId, extNetworkId,
vpnId -> addSubnetMacIntoVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, confTx), "Installing");
}
@Override
public void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, WriteTransaction writeTx) {
+ String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException {
setupRouterGwMacFlow(routerName, routerGwMac, dpnId, extNetworkId, writeTx,
(vpnId, tx) -> addSubnetMacIntoVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, tx), "Installing");
}
@Override
public void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, TypedReadWriteTransaction<Configuration> confTx) {
+ String subnetVpnName, TypedReadWriteTransaction<Configuration> confTx)
+ throws ExecutionException, InterruptedException {
setupRouterGwMacFlow(routerName, routerGwMac, dpnId, extNetworkId,
vpnId -> removeSubnetMacFromVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, confTx), "Removing");
}
@Override
public void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- String subnetVpnName, WriteTransaction writeTx) {
+ String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException {
setupRouterGwMacFlow(routerName, routerGwMac, dpnId, extNetworkId, writeTx,
(vpnId, tx) -> removeSubnetMacFromVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, tx), "Removing");
}
@FunctionalInterface
private interface RouterGwMacFlowSetupMethod {
- void process(String vpnId, WriteTransaction tx);
+ void process(String vpnId, WriteTransaction tx) throws InterruptedException, ExecutionException;
}
private void setupRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- WriteTransaction writeTx, RouterGwMacFlowSetupMethod consumer, String operation) {
+ WriteTransaction writeTx, RouterGwMacFlowSetupMethod consumer, String operation)
+ throws ExecutionException, InterruptedException {
if (routerGwMac == null) {
LOG.warn("Failed to handle router GW flow in GW-MAC table. MAC address is missing for router-id {}",
routerName);
}
private void setupRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
- Consumer<String> consumer, String operation) {
+ InterruptibleCheckedConsumer<String, ExecutionException> consumer, String operation)
+ throws ExecutionException, InterruptedException {
if (routerGwMac == null) {
LOG.warn("Failed to handle router GW flow in GW-MAC table. MAC address is missing for router-id {}",
routerName);