This patch removes unused methods, classes and fields.
Change-Id: I8fcca759a7b6320ca0c1816e0ca535d130fbc00a
Signed-off-by: Stephen Kitt <skitt@redhat.com>
package org.opendaylight.netvirt.natservice.api;
import java.math.BigInteger;
-import java.util.Map;
import java.util.Set;
public interface NatSwitchCache {
*/
Set<BigInteger> getSwitchesConnectedToExternal(String providerNet);
- /**
- * Return the switches map with weight.
- * @return the map of switches
- */
- Map<BigInteger,SwitchInfo> getSwitches();
-
/**
* Register for switch added notification.
* @param centralizedSwitchCacheListener the instance of a listener
*/
void register(NatSwitchCacheListener centralizedSwitchCacheListener);
- /**
- * Register for switch removed notification.
- * @param centralizedSwitchCacheListener the instance of a listener
- */
- void deregister(NatSwitchCacheListener centralizedSwitchCacheListener);
-
}
package org.opendaylight.netvirt.natservice.api;
import java.math.BigInteger;
-
import java.util.concurrent.ExecutionException;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.genius.infra.Datastore.Configuration;
CNT_ROUTER_DISBL
}
- void addNatServiceListener(SnatServiceListener aclServiceListner);
-
- void removeNatServiceListener(SnatServiceListener aclServiceListner);
-
void notify(TypedReadWriteTransaction<Configuration> confTx, Routers router, @Nullable Routers oldRouter,
BigInteger primarySwitchId, @Nullable BigInteger dpnId, Action action)
throws ExecutionException, InterruptedException;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.netvirt.natservice.api.NatSwitchCache;
import org.opendaylight.netvirt.natservice.api.NatSwitchCacheListener;
}
}
- public void deregister(NatSwitchCacheListener centralizedSwitchCacheListener) {
- if (centralizedSwitchCacheListener != null) {
- centralizedSwitchCacheListenerList.remove(centralizedSwitchCacheListener);
- }
- }
-
- @Override
- public Map<BigInteger,SwitchInfo> getSwitches() {
- return switchMap;
- }
}
protected final ManagedNewTransactionRunner txRunner;
protected final IMdsalApiManager mdsalManager;
protected final IdManagerService idManager;
- protected final NAPTSwitchSelector naptSwitchSelector;
- protected final ItmRpcService itmManager;
+ private final NAPTSwitchSelector naptSwitchSelector;
+ final ItmRpcService itmManager;
protected final OdlInterfaceRpcService odlInterfaceRpcService;
protected final IInterfaceManager interfaceManager;
- protected final IVpnFootprintService vpnFootprintService;
+ final IVpnFootprintService vpnFootprintService;
protected final IFibManager fibManager;
- protected final NatDataUtil natDataUtil;
- protected final DataTreeEventCallbackRegistrar eventCallbacks;
-
- protected AbstractSnatService(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
- final ItmRpcService itmManager, final OdlInterfaceRpcService odlInterfaceRpcService,
- final IdManagerService idManager, final NAPTSwitchSelector naptSwitchSelector,
- final IInterfaceManager interfaceManager,
- final IVpnFootprintService vpnFootprintService,
- final IFibManager fibManager, final NatDataUtil natDataUtil,
- final DataTreeEventCallbackRegistrar eventCallbacks) {
+ private final NatDataUtil natDataUtil;
+ private final DataTreeEventCallbackRegistrar eventCallbacks;
+
+ AbstractSnatService(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
+ final ItmRpcService itmManager, final OdlInterfaceRpcService odlInterfaceRpcService,
+ final IdManagerService idManager, final NAPTSwitchSelector naptSwitchSelector,
+ final IInterfaceManager interfaceManager,
+ final IVpnFootprintService vpnFootprintService,
+ final IFibManager fibManager, final NatDataUtil natDataUtil,
+ final DataTreeEventCallbackRegistrar eventCallbacks) {
this.dataBroker = dataBroker;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.mdsalManager = mdsalManager;
return dataBroker;
}
- public void init() {
- LOG.info("{} init", getClass().getSimpleName());
- }
-
- public void close() {
- LOG.debug("AbstractSnatService Closed");
- }
-
@Override
public boolean addSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
BigInteger primarySwitchId) {
// Handle non NAPT switches and NAPT switches separately
if (!dpnId.equals(primarySwitchId)) {
LOG.info("addSnat : Handle non NAPT switch {} for router {}", dpnId, routers.getRouterName());
- addSnatCommonEntriesForNonNaptSwitch(confTx, routers, primarySwitchId, dpnId);
- addSnatSpecificEntriesForNonNaptSwitch(confTx, routers, dpnId);
+ addSnatCommonEntriesForNonNaptSwitch();
+ addSnatSpecificEntriesForNonNaptSwitch();
} else {
LOG.info("addSnat : Handle NAPT switch {} for router {}", dpnId, routers.getRouterName());
addSnatCommonEntriesForNaptSwitch(confTx, routers, dpnId);
// Handle non NAPT switches and NAPT switches separately
if (!dpnId.equals(primarySwitchId)) {
LOG.info("removeSnat : Handle non NAPT switch {} for router {}", dpnId, routers.getRouterName());
- removeSnatCommonEntriesForNonNaptSwitch(confTx, routers, dpnId);
- removeSnatSpecificEntriesForNonNaptSwitch(confTx, routers, dpnId);
+ removeSnatCommonEntriesForNonNaptSwitch();
+ removeSnatSpecificEntriesForNonNaptSwitch();
} else {
LOG.info("removeSnat : Handle NAPT switch {} for router {}", dpnId, routers.getRouterName());
removeSnatCommonEntriesForNaptSwitch(confTx, routers, dpnId);
if (!dpnId.equals(primarySwitchId)) {
LOG.info("removeCentralizedRouter : Handle non NAPT switch {} for router {}",
dpnId, routers.getRouterName());
- removeCommonEntriesForNonNaptSwitch(confTx, routers, primarySwitchId, dpnId);
+ removeCommonEntriesForNonNaptSwitch(confTx, routers, dpnId);
} else {
LOG.info("removeCentralizedRouter : Handle NAPT switch {} for router {}", dpnId, routers.getRouterName());
removeCommonEntriesForNaptSwitch(confTx, routers, dpnId);
return true;
}
- protected void addCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId) {
+ private void addCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ BigInteger dpnId) {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
addDefaultFibRouteForSNAT(confTx, dpnId, routerId);
- int elanId = NatUtil.getElanInstanceByName(routers.getNetworkId().getValue(), getDataBroker())
- .getElanTag().intValue();
for (ExternalIps externalIp : routers.nonnullExternalIps()) {
if (!NWUtil.isIpv4Address(externalIp.getIpAddress())) {
// In this class we handle only IPv4 use-cases.
//The logic now handle only one external IP per router, others if present will be ignored.
long extSubnetId = NatUtil.getExternalSubnetVpnId(dataBroker, externalIp.getSubnetId());
addInboundTerminatingServiceTblEntry(confTx, dpnId, routerId, extSubnetId);
- addTerminatingServiceTblEntry(confTx, dpnId, routerId, elanId);
+ addTerminatingServiceTblEntry(confTx, dpnId, routerId);
break;
}
}
- protected void removeCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId) throws ExecutionException, InterruptedException {
+ private void removeCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ BigInteger dpnId) throws ExecutionException, InterruptedException {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
removeDefaultFibRouteForSNAT(confTx, dpnId, routerId);
}
}
- protected void addSnatCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ private void addSnatCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
BigInteger dpnId) {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
}
}
- protected void removeSnatCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
+ private void removeSnatCommonEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
+ Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(confTx, routerName);
for (ExternalIps externalIp : routers.nonnullExternalIps()) {
}
- protected void addCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ private void addCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ BigInteger primarySwitchId, BigInteger dpnId) {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
addSnatMissEntry(confTx, dpnId, routerId, routerName, primarySwitchId);
addDefaultFibRouteForSNAT(confTx, dpnId, routerId);
}
- protected void removeCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) throws ExecutionException, InterruptedException {
+ private void removeCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ BigInteger dpnId) throws ExecutionException, InterruptedException {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
removeSnatMissEntry(confTx, dpnId, routerId, routerName);
removeDefaultFibRouteForSNAT(confTx, dpnId, routerId);
}
- protected void addSnatCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger primarySwitchId, BigInteger dpnId) {
+ private void addSnatCommonEntriesForNonNaptSwitch() {
/* Nothing to do here*/
}
- protected void removeSnatCommonEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
+ private void removeSnatCommonEntriesForNonNaptSwitch() {
/* Nothing to do here*/
}
protected abstract void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException;
- protected abstract void addSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId);
+ protected abstract void addSnatSpecificEntriesForNonNaptSwitch();
- protected abstract void removeSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId);
+ protected abstract void removeSnatSpecificEntriesForNonNaptSwitch();
- protected void addInboundFibEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, String externalIp,
+ private void addInboundFibEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, String externalIp,
Long routerId, long extSubnetId, String externalNetId, String subNetId, String routerMac) {
List<MatchInfo> matches = new ArrayList<>();
0, null, externalNetId, RouteOrigin.STATIC, null);
}
- protected void removeInboundFibEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- String externalIp, Long routerId, String subNetId) throws ExecutionException, InterruptedException {
+ private void removeInboundFibEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+ String externalIp, Long routerId, String subNetId) throws ExecutionException, InterruptedException {
String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, routerId);
flowRef = flowRef + "inbound" + externalIp;
NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.L3_FIB_TABLE, flowRef);
}
- protected void addTerminatingServiceTblEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId, int elanId) {
+ private void addTerminatingServiceTblEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
+ Long routerId) {
LOG.info("addTerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
List<MatchInfo> matches = new ArrayList<>();
NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
- protected void removeTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId) throws ExecutionException, InterruptedException {
+ private void removeTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+ Long routerId) throws ExecutionException, InterruptedException {
LOG.info("removeTerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.PSNAT_TABLE, flowRef);
}
- protected void addInboundTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
+ private void addInboundTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
BigInteger dpnId, Long routerId, long extSubnetId) {
//Install the tunnel table entry in NAPT switch for inbound traffic to SNAT IP from a non a NAPT switch.
NatConstants.SNAT_FIB_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
- protected void removeInboundTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) throws ExecutionException, InterruptedException {
+ private void removeInboundTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
+ BigInteger dpnId, Long routerId) throws ExecutionException, InterruptedException {
//Install the tunnel table entry in NAPT switch for inbound traffic to SNAT IP from a non a NAPT switch.
LOG.info("installInboundTerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef);
}
- protected void addDefaultFibRouteForSNAT(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+ private void addDefaultFibRouteForSNAT(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
Long extNetId) {
List<MatchInfo> matches = new ArrayList<>();
instructions);
}
- protected void removeDefaultFibRouteForSNAT(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long extNetId) throws ExecutionException, InterruptedException {
+ private void removeDefaultFibRouteForSNAT(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+ Long extNetId) throws ExecutionException, InterruptedException {
String flowRef = "DefaultFibRouteForSNAT" + getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, extNetId);
NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.L3_FIB_TABLE, flowRef);
}
return "snatmiss." + routerName;
}
- protected void removeMipAdjacencies(Routers routers) {
+ private void removeMipAdjacencies(Routers routers) {
LOG.info("removeMipAdjacencies for router {}", routers.getRouterName());
String externalSubNetId = null;
for (ExternalIps externalIp : routers.nonnullExternalIps()) {
}
@Override
- protected void addSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ protected void addSnatSpecificEntriesForNonNaptSwitch() {
// Nothing to to do here
}
@Override
- protected void removeSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ protected void removeSnatSpecificEntriesForNonNaptSwitch() {
// Nothing to to do here
}
public void onRemoveFloatingIp(final BigInteger dpnId, final String vpnName, final String externalIp,
final String floatingIpInterface, final String floatingIpPortMacAddress,
- final long routerId, TypedReadWriteTransaction<Configuration> confTx) {
+ final long routerId) {
/*
* 1) Remove the flow INTERNAL_TUNNEL_TABLE (table=36)-> PDNAT_TABLE (table=25) (SNAT VM on DPN1 is
* responding back to FIP VM on DPN2) {SNAT to DNAT traffic on different Hypervisor}
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
-import org.opendaylight.netvirt.natservice.api.CentralizedSwitchScheduler;
-import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
-import org.opendaylight.serviceutils.upgrade.UpgradeState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
private final IFibManager fibManager;
private final IVpnManager vpnManager;
private final EvpnSnatFlowProgrammer evpnSnatFlowProgrammer;
- private final CentralizedSwitchScheduler centralizedSwitchScheduler;
private final NatMode natMode;
- private final INeutronVpnManager nvpnManager;
private final IElanService elanManager;
private final JobCoordinator coordinator;
- private final UpgradeState upgradeState;
private final IInterfaceManager interfaceManager;
private final NatOverVxlanUtil natOverVxlanUtil;
private final int snatPuntTimeout;
final IFibManager fibManager,
final IVpnManager vpnManager,
final EvpnSnatFlowProgrammer evpnSnatFlowProgrammer,
- final INeutronVpnManager nvpnManager,
- final CentralizedSwitchScheduler centralizedSwitchScheduler,
final NatserviceConfig config,
final IElanService elanManager,
final JobCoordinator coordinator,
- final UpgradeState upgradeState,
final NatOverVxlanUtil natOverVxlanUtil,
final IInterfaceManager interfaceManager) {
super(Routers.class, ExternalRoutersListener.class);
this.fibManager = fibManager;
this.vpnManager = vpnManager;
this.evpnSnatFlowProgrammer = evpnSnatFlowProgrammer;
- this.nvpnManager = nvpnManager;
this.elanManager = elanManager;
- this.centralizedSwitchScheduler = centralizedSwitchScheduler;
this.coordinator = coordinator;
- this.upgradeState = upgradeState;
this.interfaceManager = interfaceManager;
this.natOverVxlanUtil = natOverVxlanUtil;
if (config != null) {
}
}
- List<BucketInfo> getBucketInfoForPrimaryNaptSwitch() {
- List<BucketInfo> listBucketInfo = new ArrayList<>();
- List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
- listActionInfoPrimary.add(new ActionNxResubmit(NwConstants.INTERNAL_TUNNEL_TABLE));
- BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
- listBucketInfo.add(0, bucketPrimary);
- return listBucketInfo;
- }
-
public void installNaptPfibEntry(BigInteger dpnId, long segmentId,
@Nullable TypedWriteTransaction<Configuration> confTx) {
LOG.debug("installNaptPfibEntry : called for dpnId {} and segmentId {} ", dpnId, segmentId);
this.ipv6SubnetFlowProgrammer = ipv6SubnetFlowProgrammer;
}
- public void init() {
- LOG.info("Ipv6ForwardingService: {} init", getClass().getSimpleName());
- }
-
@Override
public boolean addCentralizedRouterAllSwitch(TypedReadWriteTransaction<Configuration> confTx,
Routers routers, BigInteger primarySwitchId) {
NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
- protected void removeIpv6PsNatMissEntryNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId, String routerName, BigInteger primarySwitchId)
- throws ExecutionException, InterruptedException {
- LOG.debug("installIpv6PsNatMissEntryNonNaptSwitch : On Non-Napt Switch, installing SNAT miss entry in"
- + " switch {} for router {}", dpnId, routerName);
- List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
- List<BucketInfo> listBucketInfo = new ArrayList<>();
-
- String ifNamePrimary = NatUtil.getTunnelInterfaceName(dpnId, primarySwitchId, itmManager);
- if (ifNamePrimary != null) {
- LOG.debug("installIpv6PsNatMissEntryNonNaptSwitch : On Non-Napt Switch, Primary Tunnel interface is {}",
- ifNamePrimary);
- listActionInfoPrimary = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager,
- interfaceManager, ifNamePrimary, routerId, true);
- } else {
- LOG.warn("installIpv6PsNatMissEntryNonNaptSwitch: could not get tunnelInterface for {} on Switch {}",
- primarySwitchId, dpnId);
- }
-
- BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
- listBucketInfo.add(0, bucketPrimary);
-
- LOG.debug("installIpv6PsNatMissEntryNonNaptSwitch : installSnatMissEntry called for dpnId {} with"
- + " primaryBucket {} ", dpnId, listBucketInfo.get(0));
-
- long groupId = createGroupIdForIpv6Router(getGroupIdKey(routerName + "IPv6"));
- GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll,
- listBucketInfo);
- LOG.debug("removing the PSNAT to NAPTSwitch GroupEntity:{} with GroupId: {}", groupEntity, groupId);
- mdsalManager.removeGroup(confTx, groupEntity);
-
- String flowRef = NatUtil.getIpv6FlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
- NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.PSNAT_TABLE, flowRef);
- }
-
-
protected void addIpv6SnatMissEntryForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
BigInteger dpnId, Long routerId, BigInteger routerMetadata) {
LOG.debug("installIpv6SnatMissEntryForNaptSwitch {} called for routerId {}", dpnId, routerId);
return weight;
}
- public void incrementWeight() {
- ++weight;
- }
-
@Override
public int compareTo(@NonNull SwitchWeight switchWeight) {
return weight - switchWeight.getWeight();
import org.opendaylight.genius.mdsalutil.packet.UDP;
import org.opendaylight.infrautils.utils.concurrent.JdkFutures;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
-import org.opendaylight.netvirt.natservice.internal.NaptPacketInHandler.NatPacketProcessingState;
import org.opendaylight.openflowplugin.libraries.liblldp.PacketException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
internalAddress, externalAddress);
}
}, MoreExecutors.directExecutor());
-
- NatPacketProcessingState state = naptEntryEvent.getState();
- if (state != null) {
- state.setFlowInstalledTime(System.currentTimeMillis());
- }
} else {
prepareAndSendPacketOut(naptEntryEvent, routerId);
}
import java.math.BigInteger;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
@Singleton
public class NaptFlowRemovedEventHandler implements SalFlowListener {
private static final Logger LOG = LoggerFactory.getLogger(NaptFlowRemovedEventHandler.class);
- private final DataBroker dataBroker;
- private final IMdsalApiManager mdsalManager;
+
private final EventDispatcher naptEventdispatcher;
- private final NaptPacketInHandler naptPacketInHandler;
- private final NaptManager naptManager;
@Inject
- public NaptFlowRemovedEventHandler(final DataBroker dataBroker,
- final IMdsalApiManager mdsalManager,
- final EventDispatcher eventDispatcher,
- final NaptPacketInHandler handler,
- final NaptManager naptManager) {
- this.dataBroker = dataBroker;
- this.mdsalManager = mdsalManager;
+ public NaptFlowRemovedEventHandler(final EventDispatcher eventDispatcher) {
this.naptEventdispatcher = eventDispatcher;
- this.naptPacketInHandler = handler;
- this.naptManager = naptManager;
}
@Override
return null;
}
- /**
- * Release the existing mapping of internal ip/port to external ip/port pair
- * if no mapping exist for given internal ip/port, it returns false.
- *
- * @param segmentId - Router ID
- * @param address - Session Address
- * @param protocol - TCP/UDP
- * @return true if mapping exist and the mapping is removed successfully
- */
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
- public boolean releaseAddressMapping(long segmentId, SessionAddress address, NAPTEntryEvent.Protocol protocol) {
- LOG.debug("releaseAddressMapping : called with segmentId {}, internalIP {}, port {}",
- segmentId, address.getIpAddress(), address.getPortNumber());
- // delete entry from IpPort Map and IP Map if exists
- String internalIpPort = address.getIpAddress() + ":" + address.getPortNumber();
- SessionAddress existingIpPort = checkIpPortMap(segmentId, internalIpPort, protocol);
- if (existingIpPort != null) {
- // delete the entry from IpPortMap DS
- try {
- removeFromIpPortMapDS(segmentId, internalIpPort, protocol);
- } catch (Exception e) {
- LOG.error("releaseAddressMapping : failed, Removal of ipportmap {} for "
- + "router {} failed", internalIpPort, segmentId, e);
- return false;
- }
- } else {
- LOG.error("releaseAddressMapping : failed, segmentId {} and internalIpPort {} "
- + "not found in IpPortMap DS", segmentId, internalIpPort);
- return false;
- }
- String existingIp = checkIpMap(segmentId, address.getIpAddress());
- if (existingIp != null) {
- // delete the entry from IpMap DS
- try {
- removeFromIpMapDS(segmentId, address.getIpAddress());
- } catch (Exception e) {
- LOG.error("releaseAddressMapping : Removal of ipmap {} for router {} failed",
- address.getIpAddress(), segmentId, e);
- return false;
- }
- //delete the entry from snatIntIpportinfo
- try {
- removeFromSnatIpPortDS(segmentId, address.getIpAddress());
- } catch (Exception e) {
- LOG.error("releaseAddressMapping : failed, Removal of snatipportmap {} for "
- + "router {} failed", address.getIpAddress(), segmentId, e);
- return false;
- }
- } else {
- LOG.error("releaseAddressMapping : failed, segmentId {} and internalIpPort {} "
- + "not found in IpMap DS", segmentId, internalIpPort);
- return false;
- }
- // Finally release port from idmanager
- removePortFromPool(internalIpPort, existingIpPort.getIpAddress());
-
- LOG.debug("releaseAddressMapping : Exited successfully for segmentId {} and internalIpPort {}",
- segmentId, internalIpPort);
- return true;
- }
-
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void releaseIpExtPortMapping(long segmentId, SessionAddress address, NAPTEntryEvent.Protocol protocol) {
NatPacketProcessingState state = INCOMING_PKT_MAP.get(sourceIPPortKey);
if (state == null) {
- state = new NatPacketProcessingState(System.currentTimeMillis(), -1);
+ state = new NatPacketProcessingState(System.currentTimeMillis());
INCOMING_PKT_MAP.put(sourceIPPortKey, state);
LOG.trace("onPacketReceived : Processing new SNAT({}) Packet", sourceIPPortKey);
static class NatPacketProcessingState {
private final long firstPacketInTime;
- private volatile long flowInstalledTime;
- NatPacketProcessingState(long firstPacketInTime, long flowInstalledTime) {
+ NatPacketProcessingState(long firstPacketInTime) {
this.firstPacketInTime = firstPacketInTime;
- this.flowInstalledTime = flowInstalledTime;
}
long getFirstPacketInTime() {
return firstPacketInTime;
}
- long getFlowInstalledTime() {
- return flowInstalledTime;
- }
-
- void setFlowInstalledTime(long flowInstalledTime) {
- this.flowInstalledTime = flowInstalledTime;
+ void setFlowInstalledTime() {
}
}
}
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
-import org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit;
import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId;
import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
import org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable;
return NatConstants.INVALID_ID;
}
- public List<BucketInfo> handleGroupInPrimarySwitch() {
- List<BucketInfo> listBucketInfo = new ArrayList<>();
- List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
- listActionInfoPrimary.add(new ActionNxResubmit(NwConstants.INTERNAL_TUNNEL_TABLE));
- BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
- listBucketInfo.add(bucketPrimary);
- return listBucketInfo;
- }
-
@NonNull
public List<BucketInfo> handleGroupInNeighborSwitches(BigInteger dpnId, String routerName, long routerId,
BigInteger naptSwitch) {
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
}
VipState newVipState = this.vipStateTracker.buildVipState(srcIp.getIpv4Address().getValue(),
- notification.getSrcMac().getValue(), notification.getDpnId(), targetIfc.getName());
+ notification.getDpnId(), targetIfc.getName());
VipState cachedState = null;
try {
cachedState = this.vipStateTracker.get(newVipState.getIp()).orNull();
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
}
}
- @NonNull
- public static List<Uuid> getRouterIdsfromNetworkId(DataBroker broker, Uuid networkId) {
- InstanceIdentifier<Networks> id = buildNetworkIdentifier(networkId);
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker,
- LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(Networks::getRouterIds).orElse(
- emptyList());
- }
-
@Nullable
static String getAssociatedExternalNetwork(DataBroker dataBroker, String routerId) {
InstanceIdentifier<Routers> id = NatUtil.buildRouterIdentifier(routerId);
.build();
}
- public static long getIpAddress(byte[] rawIpAddress) {
- return ((rawIpAddress[0] & 0xFF) << 3 * 8) + ((rawIpAddress[1] & 0xFF) << 2 * 8)
- + ((rawIpAddress[2] & 0xFF) << 1 * 8) + (rawIpAddress[3] & 0xFF) & 0xffffffffL;
- }
-
@Nullable
public static String getEndpointIpAddressForDPN(DataBroker broker, BigInteger dpnId) {
String nextHopIp = null;
.child(VpnInterface.class, new VpnInterfaceKey(vpnInterfaceName)).build();
}
- @Nullable
- static VpnInterface getConfiguredVpnInterface(DataBroker broker, String interfaceName) {
- InstanceIdentifier<VpnInterface> interfaceId = getVpnInterfaceIdentifier(interfaceName);
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker,
- LogicalDatastoreType.CONFIGURATION, interfaceId).orNull();
- }
-
@Nullable
public static String getDpnFromNodeConnectorId(NodeConnectorId portId) {
/*
return tx.read(getVpnInstanceIdentifier(vpnName)).get().toJavaUtil().map(NatUtil::getPrimaryRd).orElse(null);
}
- public static String getPrimaryRd(DataBroker dataBroker, String vpnName) {
- InstanceIdentifier<VpnInstance> id = getVpnInstanceIdentifier(vpnName);
- Optional<VpnInstance> vpnInstance =
- SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, id);
- if (vpnInstance.isPresent()) {
- return getPrimaryRd(vpnInstance.get());
- }
- return vpnName;
- }
-
@Nullable
public static String getPrimaryRd(@Nullable VpnInstance vpnInstance) {
if (vpnInstance == null) {
vpnConfig.getRouteDistinguisher()) : new ArrayList<>();
}
- public static long getVpnIdFromExternalSubnet(DataBroker dataBroker, String routerName, String externalIpAddress) {
- if (routerName != null) {
- Routers extRouter = NatUtil.getRoutersFromConfigDS(dataBroker, routerName);
- if (extRouter != null) {
- return getExternalSubnetVpnIdForRouterExternalIp(dataBroker, externalIpAddress, extRouter);
- }
- }
-
- return NatConstants.INVALID_ID;
- }
-
public static String validateAndAddNetworkMask(String ipAddress) {
return ipAddress.contains("/32") ? ipAddress : ipAddress + "/32";
}
new VpnInterfaceOpDataEntryKey(vpnInterfaceName, vpnName)).build();
}
- @Nullable
- public static VpnInstanceOpDataEntry getVpnInstanceOpData(DataBroker broker, String rd) {
- InstanceIdentifier<VpnInstanceOpDataEntry> id = NatUtil.getVpnInstanceOpDataIdentifier(rd);
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(
- broker, LogicalDatastoreType.OPERATIONAL, id).orNull();
- }
-
public static boolean checkForRoutersWithSameExtNetAndNaptSwitch(DataBroker broker, Uuid networkId,
String routerName, BigInteger dpnId) {
InstanceIdentifier<Networks> id = buildNetworkIdentifier(networkId);
}
}
- public static DpnInterfaces getElanInterfaceInfoByElanDpn(String elanInstanceName, BigInteger dpId,
- DataBroker broker) {
- InstanceIdentifier<DpnInterfaces> elanDpnInterfacesId =
- getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
- DpnInterfaces dpnInterfaces = null;
- try {
- dpnInterfaces = SingleTransactionDataBroker.syncRead(broker, LogicalDatastoreType.OPERATIONAL,
- elanDpnInterfacesId);
- }
- catch (ReadFailedException e) {
- LOG.warn("Failed to read ElanDpnInterfacesList with error {}", e.getMessage());
- }
- return dpnInterfaces;
- }
-
- public static <T extends DataObject> Optional<T> read(DataBroker broker, LogicalDatastoreType datastoreType,
- InstanceIdentifier<T> path) {
- try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
- return tx.read(datastoreType, path).get();
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException(e);
- }
- }
-
public static boolean isLastExternalRouter(String networkid, String routerName, NatDataUtil natDataUtil) {
Set<Map.Entry<String,Routers>> extRouter = natDataUtil.getAllRouters();
for (Map.Entry<String,Routers> router : extRouter) {
return true;
}
- public static InstanceIdentifier<ExtRouters> buildExtRouters() {
- InstanceIdentifier<ExtRouters> extRouterInstanceIndentifier = InstanceIdentifier.builder(ExtRouters.class)
- .build();
- return extRouterInstanceIndentifier;
- }
-
@Nullable
public static LearntVpnVipToPortData getLearntVpnVipToPortData(DataBroker dataBroker) {
try {
return null;
}
- public static String getIpv6JobKey(String routerName) {
- return "Ipv6." + routerName;
- }
-
static ReentrantLock lockForNat(final BigInteger dataPath) {
// FIXME: wrap this in an Identifier
return JvmGlobalLocks.getLockForString(NatConstants.NAT_DJC_PREFIX + dataPath);
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
-import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.natservice.api.SnatServiceManager;
import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.serviceutils.upgrade.UpgradeState;
private final IdManagerService idManager;
private final INeutronVpnManager nvpnManager;
private final ExternalNetworkGroupInstaller extNetGroupInstaller;
- private final IElanService elanManager;
private final JobCoordinator coordinator;
private final SnatServiceManager natServiceManager;
private final NatMode natMode;
final INeutronVpnManager nvpnManager,
final SnatServiceManager natServiceManager,
final NatserviceConfig config,
- final IElanService elanManager,
final JobCoordinator coordinator,
final UpgradeState upgradeState) {
super(DpnVpninterfacesList.class, RouterDpnChangeListener.class);
this.idManager = idManager;
this.extNetGroupInstaller = extNetGroupInstaller;
this.nvpnManager = nvpnManager;
- this.elanManager = elanManager;
this.natServiceManager = natServiceManager;
this.coordinator = coordinator;
this.natMode = config != null ? config.getNatMode() : NatMode.Controller;
LOG.error("add : External Network Provider Type missing");
return;
}
- handleSNATForDPN(dpnId, routerUuid, routerId, vpnId, confTx, extNwProvType);
+ handleSNATForDPN(dpnId, routerUuid, routerId, vpnId, confTx);
} else {
LOG.info("add : SNAT is not enabled for router {} to handle addDPN event {}",
routerUuid, dpnId);
}
void handleSNATForDPN(BigInteger dpnId, String routerName, long routerId, Long routerVpnId,
- TypedReadWriteTransaction<Configuration> confTx, ProviderTypes extNwProvType) {
+ TypedReadWriteTransaction<Configuration> confTx) {
//Check if primary and secondary switch are selected, If not select the role
//Install select group to NAPT switch
//Install default miss entry to NAPT switch
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.natservice.ha.NatDataUtil;
-import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.netvirt.vpnmanager.api.IVpnFootprintService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
private final IdManagerService idManager;
private final NAPTSwitchSelector naptSwitchSelector;
private final NatMode natMode;
- private final INeutronVpnManager nvpnManager;
private final ExternalRoutersListener externalRouterListener;
private final IElanService elanManager;
private final IInterfaceManager interfaceManager;
final IdManagerService idManager,
final NAPTSwitchSelector naptSwitchSelector,
final NatserviceConfig config,
- final INeutronVpnManager nvpnManager,
final ExternalRoutersListener externalRouterListener,
final IElanService elanManager,
final IInterfaceManager interfaceManager,
} else {
this.natMode = null;
}
- this.nvpnManager = nvpnManager;
this.externalRouterListener = externalRouterListener;
this.elanManager = elanManager;
this.interfaceManager = interfaceManager;
}
}
- @Override
- public void addNatServiceListener(SnatServiceListener natServiceListner) {
+ private void addNatServiceListener(SnatServiceListener natServiceListner) {
snatServiceListeners.add(natServiceListner);
}
- @Override
- public void removeNatServiceListener(SnatServiceListener natServiceListner) {
- snatServiceListeners.remove(natServiceListner);
- }
-
@Override
public void notify(TypedReadWriteTransaction<Datastore.Configuration> confTx,
Routers router, Routers oldRouter, BigInteger primarySwitchId, BigInteger dpnId, Action action)
import java.math.BigInteger;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
}
- public VipState buildVipState(String ip, String mac, BigInteger dpnId, String ifcName) {
+ public VipState buildVipState(String ip, BigInteger dpnId, String ifcName) {
return new VipStateBuilder().setIp(ip).setDpnId(dpnId).setIfcName(ifcName).build();
}
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
-import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
private final OdlArputilService arpUtilService;
private final IElanService elanService;
private final EvpnDnatFlowProgrammer evpnDnatFlowProgrammer;
- private final INeutronVpnManager nvpnManager;
private final NatServiceCounters natServiceCounters;
private final NatOverVxlanUtil natOverVxlanUtil;
final IVpnManager vpnManager,
final IElanService elanService,
final EvpnDnatFlowProgrammer evpnDnatFlowProgrammer,
- final INeutronVpnManager nvpnManager,
final NatOverVxlanUtil natOverVxlanUtil,
NatServiceCounters natServiceCounters) {
this.dataBroker = dataBroker;
this.vpnManager = vpnManager;
this.elanService = elanService;
this.evpnDnatFlowProgrammer = evpnDnatFlowProgrammer;
- this.nvpnManager = nvpnManager;
this.natServiceCounters = natServiceCounters;
this.natOverVxlanUtil = natOverVxlanUtil;
}
if (provType == ProviderTypes.VXLAN) {
Uuid floatingIpInterface = NatEvpnUtil.getFloatingIpInterfaceIdFromFloatingIpId(dataBroker, floatingIpId);
evpnDnatFlowProgrammer.onRemoveFloatingIp(dpnId, vpnName, externalIp, floatingIpInterface.getValue(),
- floatingIpPortMacAddress, routerId, confTx);
+ floatingIpPortMacAddress, routerId);
return;
}
cleanupFibEntries(dpnId, vpnName, externalIp, label, confTx, provType);