*/
package org.opendaylight.netvirt.natservice.internal;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.mdsalutil.matches.MatchMetadata;
import org.opendaylight.genius.mdsalutil.matches.MatchTunnelId;
import org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.natservice.ha.NatDataUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.NxActionNatFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.NxActionNatRangePresent;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(VxlanGreConntrackBasedSnatService.class);
private final ExternalRoutersListener externalRouterListener;
private final IElanService elanManager;
+ private final NatOverVxlanUtil natOverVxlanUtil;
public VxlanGreConntrackBasedSnatService(DataBroker dataBroker, IMdsalApiManager mdsalManager,
ItmRpcService itmManager, OdlInterfaceRpcService odlInterfaceRpcService,
IInterfaceManager interfaceManager,
IVpnFootprintService vpnFootprintService,
IFibManager fibManager, NatDataUtil natDataUtil,
- DataTreeEventCallbackRegistrar eventCallbacks) {
+ DataTreeEventCallbackRegistrar eventCallbacks,
+ NatOverVxlanUtil natOverVxlanUtil) {
super(dataBroker, mdsalManager, itmManager, idManager, naptSwitchSelector, odlInterfaceRpcService,
interfaceManager, vpnFootprintService, fibManager, natDataUtil, eventCallbacks);
this.externalRouterListener = externalRouterListener;
this.elanManager = elanManager;
+ this.natOverVxlanUtil = natOverVxlanUtil;
}
@Override
public boolean addSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) {
+ Uint64 primarySwitchId) {
ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(confTx, routers.getNetworkId());
LOG.debug("VxlanGreConntrackBasedSnatService: handleSnatAllSwitch ProviderTypes {}", extNwProviderType);
if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
@Override
public boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) {
+ Uint64 primarySwitchId) throws ExecutionException, InterruptedException {
ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(confTx, routers.getNetworkId());
LOG.debug("VxlanGreConntrackBasedSnatService: handleSnatAllSwitch ProviderTypes {}", extNwProviderType);
if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
return super.removeSnatAllSwitch(confTx, routers, primarySwitchId);
}
+ public boolean addCentralizedRouterAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ Uint64 primarySwitchId) {
+ ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(dataBroker, routers.getNetworkId());
+ LOG.debug("VxlanGreConntrackBasedSnatService: handleCentralizedRouterAllSwitch ProviderTypes {}",
+ extNwProviderType);
+ if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
+ LOG.debug("handleCentralizedRouterAllSwitch : Skip FLAT/VLAN provider networks.");
+ return true;
+ }
+ return super.addCentralizedRouterAllSwitch(confTx, routers, primarySwitchId);
+ }
+
+ public boolean removeCentralizedRouterAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ Uint64 primarySwitchId) throws ExecutionException, InterruptedException {
+ ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(dataBroker, routers.getNetworkId());
+ LOG.debug("VxlanGreConntrackBasedSnatService: handleCentralizedRouterAllSwitch ProviderTypes {}",
+ extNwProviderType);
+ if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
+ LOG.debug("handleCentralizedRouterAllSwitch : Skip FLAT/VLAN provider networks.");
+ return true;
+ }
+ return super.removeCentralizedRouterAllSwitch(confTx, routers, primarySwitchId);
+ }
+
+ public boolean addCentralizedRouter(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ Uint64 primarySwitchId, Uint64 dpnId) {
+ ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(dataBroker, routers.getNetworkId());
+ LOG.debug("VxlanGreConntrackBasedSnatService: handleCentralizedRouter ProviderTypes {}", extNwProviderType);
+ if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
+ LOG.debug("handleCentralizedRouter : Skip FLAT/VLAN provider networks.");
+ return true;
+ }
+ return super.addCentralizedRouter(confTx, routers, primarySwitchId, dpnId);
+ }
+
+ public boolean removeCentralizedRouter(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
+ Uint64 primarySwitchId, Uint64 dpnId) throws ExecutionException, InterruptedException {
+ ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(dataBroker, routers.getNetworkId());
+ LOG.debug("VxlanGreConntrackBasedSnatService: handleCentralizedRouter ProviderTypes {}", extNwProviderType);
+ if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
+ LOG.debug("handleCentralizedRouter : Skip FLAT/VLAN provider networks.");
+ return true;
+ }
+ return super.removeCentralizedRouter(confTx, routers, primarySwitchId, dpnId);
+ }
+
@Override
public boolean addSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ Uint64 primarySwitchId, Uint64 dpnId) {
ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(confTx, routers.getNetworkId());
LOG.debug("VxlanGreConntrackBasedSnatService: handleSnat ProviderTypes {}", extNwProviderType);
if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
@Override
public boolean removeSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ Uint64 primarySwitchId, Uint64 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 addSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId) {
+ Uint64 dpnId) {
LOG.info("installSnatSpecificEntriesForNaptSwitch for router {}",
routers.getRouterName());
String routerName = routers.getRouterName();
- Long routerId = NatUtil.getVpnId(dataBroker, routerName);
+ Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
int elanId = NatUtil.getElanInstanceByName(routers.getNetworkId().getValue(), dataBroker)
.getElanTag().intValue();
/* Install Outbound NAT entries */
+ "external network {} with routerId {}", routers.getNetworkId(), routerId);
return;
}
- Long extNetVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
+ Uint32 extNetVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
LOG.info("installSnatSpecificEntriesForNaptSwitch: external network vpn_id {} for router {}",
extNetVpnId, routers.getRouterName());
List<ExternalIps> externalIps = routers.getExternalIps();
@Override
protected void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger dpnId) {
+ Routers routers, Uint64 dpnId) throws ExecutionException, InterruptedException {
LOG.info("installSnatSpecificEntriesForNaptSwitch for router {}",
routers.getRouterName());
String routerName = routers.getRouterName();
- Long routerId = NatUtil.getVpnId(dataBroker, routerName);
+ Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
/* Remove Outbound NAT entries */
removeSnatMissEntryForPrimrySwch(confTx, dpnId, routerId);
+ "external network {} with routerId {}", routers.getNetworkId(), routerId);
return;
}
- Long extNetVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
+ Uint32 extNetVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
LOG.info("installSnatSpecificEntriesForNaptSwitch: external network vpn_id {} for router {}",
extNetVpnId, routers.getRouterName());
List<ExternalIps> externalIps = routers.getExternalIps();
Collections.singletonList(externalIp), null, routers.getExtGwMacAddress(), confTx);
}
- protected void addOutboundTblTrackEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId, Long extNetVpnId) {
+ protected void addOutboundTblTrackEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, Uint32 extNetVpnId) {
LOG.info("createOutboundTblTrackEntryForVxlanGre: Install Outbound tracking table flow on dpId {} for "
+ "routerId {}", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(SNAT_CT_STATE, SNAT_CT_STATE_MASK));
- matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
+ matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()),
+ MetaDataUtil.METADATA_MASK_VRFID));
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
- ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil.getVpnIdMetadata(extNetVpnId));
+ ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(
+ MetaDataUtil.getVpnIdMetadata(extNetVpnId.longValue()));
listActionInfo.add(actionSetFieldMeta);
ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
listActionInfo.add(new ActionNxResubmit(NwConstants.NAPT_PFIB_TABLE));
instructionInfo.add(new InstructionApplyActions(listActionInfo));
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
- addFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef,
- NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
+ NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef,
+ NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
}
protected void removeOutboundTblTrackEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) {
+ Uint64 dpnId, Uint32 routerId) throws ExecutionException, InterruptedException {
LOG.info("createOutboundTblTrackEntryForVxlanGre: Install Outbound tracking table flow on dpId {} for "
+ "routerId {}", dpnId, routerId);
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
- removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
+ NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
}
- protected void addOutboundTblEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, Long extNetVpnId, List<ExternalIps> externalIps, int elanId) {
+ protected void addOutboundTblEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, Uint32 extNetVpnId, List<ExternalIps> externalIps,
+ int elanId) {
LOG.info("createOutboundTblEntryForVxlanGre: Install Outbound table flow on dpId {} for routerId {}", dpnId,
routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(TRACKED_NEW_CT_STATE, TRACKED_NEW_CT_MASK));
- matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
+ matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()),
+ MetaDataUtil.METADATA_MASK_VRFID));
if (externalIps.isEmpty()) {
LOG.error("createOutboundTblEntryForVxlanGre: No externalIP present for routerId {}",
routerId);
String externalIp = externalIps.get(0).getIpAddress();
List<ActionInfo> actionsInfos = new ArrayList<>();
ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil
- .getVpnIdMetadata(extNetVpnId));
+ .getVpnIdMetadata(extNetVpnId.longValue()));
actionsInfos.add(actionSetFieldMeta);
List<ActionNxConntrack.NxCtAction> ctActionsListCommit = new ArrayList<>();
int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
- addFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_NEW_FLOW_PRIORITY,
- flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
+ NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef,
+ NatConstants.SNAT_NEW_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
- protected void removeOutboundTblEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, List<ExternalIps> externalIps) {
+ protected void removeOutboundTblEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, List<ExternalIps> externalIps)
+ throws ExecutionException, InterruptedException {
LOG.info("createOutboundTblEntryForVxlanGre: Install Outbound table flow on dpId {} for routerId {}", dpnId,
routerId);
if (externalIps.isEmpty()) {
}
//The logic now handle only one external IP per router, others if present will be ignored.
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
- removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
+ NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
}
protected void addNaptPfibFlowForVxlanGre(TypedWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId, Long extNetVpnId) {
+ Uint64 dpnId, Uint32 extNetVpnId) {
LOG.info("installNaptPfibFlowForVxlanGre: Install Napt preFibFlow on dpId {} with matching extNetVpnId {} "
+ "for router {}", dpnId, extNetVpnId, routers.getRouterName());
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
- matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNetVpnId),
+ matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNetVpnId.longValue()),
MetaDataUtil.METADATA_MASK_VRFID));
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
ArrayList<InstructionInfo> instructions = new ArrayList<>();
- listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
+ listActionInfo.add(new ActionNxLoadInPort(Uint64.ZERO));
listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
instructions.add(new InstructionApplyActions(listActionInfo));
String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, extNetVpnId);
- addFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY,
- flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
+ NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef,
+ NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
protected void removeNaptPfibFlowForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger dpnId, Long extNetVpnId) {
+ Uint64 dpnId, Uint32 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);
- removeFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);
+ NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);
}
- protected void addInboundEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, Long extNeVpnId, List<ExternalIps> externalIps, int elanId) {
+ protected void addInboundEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, Uint32 extNeVpnId, List<ExternalIps> externalIps,
+ int elanId) {
LOG.info("installInboundEntryForVxlanGre: Install Inbound table entry on dpId {} for routerId {}",
dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
}
String externalIp = externalIps.get(0).getIpAddress();
matches.add(new MatchIpv4Destination(externalIp,"32"));
- matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNeVpnId), MetaDataUtil.METADATA_MASK_VRFID));
+ matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNeVpnId.longValue()),
+ MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfos = new ArrayList<>();
List<ActionNxConntrack.NxCtAction> ctActionsList = new ArrayList<>();
ActionNxConntrack.NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0,null, null,0, 0);
ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil
- .getVpnIdMetadata(routerId));
+ .getVpnIdMetadata(routerId.longValue()));
actionsInfos.add(actionSetFieldMeta);
ctActionsList.add(nxCtAction);
ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId);
- addFlow(confTx, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef,
- NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
+ NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef,
+ NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
- protected void removeInboundEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, List<ExternalIps> externalIps) {
+ protected void removeInboundEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, List<ExternalIps> externalIps)
+ throws ExecutionException, InterruptedException {
LOG.info("removeInboundEntryForVxlanGre: remove Inbound table entry on dpId {} for routerId {}",
dpnId, routerId);
if (externalIps.isEmpty()) {
}
String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId);
- removeFlow(confTx, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef);
+ NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef);
}
protected void addTerminatingServiceTblEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx,
- BigInteger dpnId, String routerName, Long routerId, int elanId) {
+ Uint64 dpnId, String routerName, Uint32 routerId, int elanId) {
LOG.info("installTerminatingServiceTblEntryForVxlanGre : creating entry for"
+ "Terminating Service Table for switch {}, routerId {}", dpnId, routerId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
- BigInteger tunnelId = BigInteger.valueOf(routerId);
+ Uint64 tunnelId = Uint64.valueOf(routerId);
if (elanManager.isOpenStackVniSemanticsEnforced()) {
- tunnelId = NatOverVxlanUtil.getRouterVni(idManager, routerName, routerId);
+ tunnelId = natOverVxlanUtil.getRouterVni(routerName, routerId);
}
matches.add(new MatchTunnelId(tunnelId));
actionsInfos.add(actionNxConntrack);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
- String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
- addFlow(confTx, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY,
- flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
+ String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId);
+ NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef,
+ NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
protected void removeTerminatingServiceTblEntryForVxlanGre(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) {
+ Uint64 dpnId, Uint32 routerId) throws ExecutionException, InterruptedException {
LOG.info("removeTerminatingServiceTblEntryForVxlanGre : removing entry for"
+ "Terminating Service Table for switch {}, routerId {}", dpnId, routerId);
- String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
- removeFlow(confTx, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef);
+ String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId);
+ NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef);
}
@Override
- protected void addSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId, Long routerId,
- String routerName, BigInteger primarySwitchId) {
- LOG.debug("installSnatMissEntry : Installing SNAT miss entry in switch {}", dpnId);
+ protected void addSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId, Uint32 routerId,
+ String routerName, Uint64 primarySwitchId) {
+ LOG.debug("addSnatMissEntry : Installing SNAT miss entry in switch {}", dpnId);
List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
- String ifNamePrimary = getTunnelInterfaceName(dpnId, primarySwitchId);
+ String ifNamePrimary = NatUtil.getTunnelInterfaceName(dpnId, primarySwitchId, itmManager);
List<BucketInfo> listBucketInfo = new ArrayList<>();
if (ifNamePrimary != null) {
- LOG.debug("installSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
+ LOG.debug("addSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
listActionInfoPrimary = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager,
interfaceManager, ifNamePrimary, routerId, true);
}
BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
listBucketInfo.add(0, bucketPrimary);
- LOG.debug("installSnatMissEntry : installSnatMissEntry called for dpnId {} with primaryBucket {} ", dpnId,
+ LOG.debug("addSnatMissEntry : addSnatMissEntry called for dpnId {} with primaryBucket {} ", dpnId,
listBucketInfo.get(0));
// Install the select group
- long groupId = createGroupId(getGroupIdKey(routerName));
- GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll,
- listBucketInfo);
- LOG.debug("installSnatMissEntry : installing the SNAT to NAPT GroupEntity:{}", groupEntity);
- mdsalManager.addGroup(confTx, groupEntity);
- // Install miss entry pointing to group
- LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}",
+ Uint32 groupId = NatUtil.getUniqueId(idManager, NatConstants.SNAT_IDPOOL_NAME, getGroupIdKey(routerName));
+ if (groupId != NatConstants.INVALID_ID) {
+ GroupEntity groupEntity = MDSALUtil
+ .buildGroupEntity(dpnId, groupId.longValue(), routerName, GroupTypes.GroupAll,
+ listBucketInfo);
+ LOG.debug("addSnatMissEntry : installing the SNAT to NAPT GroupEntity:{}", groupEntity);
+ mdsalManager.addGroup(confTx, groupEntity);
+ // Install miss entry pointing to group
+ LOG.debug(
+ "addSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}",
dpnId, routerName, groupId);
- List<MatchInfo> matches = new ArrayList<>();
- matches.add(new MatchEthernetType(0x0800L));
- matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
-
- List<ActionInfo> actionsInfo = new ArrayList<>();
+ List<MatchInfo> matches = new ArrayList<>();
+ matches.add(new MatchEthernetType(0x0800L));
+ matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()),
+ MetaDataUtil.METADATA_MASK_VRFID));
- BigInteger tunnelId = BigInteger.valueOf(routerId);
- if (elanManager.isOpenStackVniSemanticsEnforced()) {
- tunnelId = NatOverVxlanUtil.getRouterVni(idManager, routerName, routerId);
+ List<ActionInfo> actionsInfo = new ArrayList<>();
+
+ Uint64 tunnelId = Uint64.valueOf(routerId);
+ if (elanManager.isOpenStackVniSemanticsEnforced()) {
+ tunnelId = natOverVxlanUtil.getRouterVni(routerName, routerId);
+ }
+
+ actionsInfo.add(new ActionSetFieldTunnelId(tunnelId));
+ LOG.debug("addSnatMissEntry : Setting the tunnel to the list of action infos {}",
+ actionsInfo);
+ actionsInfo.add(new ActionGroup(groupId.longValue()));
+ List<InstructionInfo> instructions = new ArrayList<>();
+ instructions.add(new InstructionApplyActions(actionsInfo));
+ String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
+ NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.PSNAT_TABLE, flowRef,
+ NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE,
+ matches,
+ instructions);
+ } else {
+ LOG.error("installSnatMissEntry: Unable to get groupId for router:{}", routerName);
}
-
- actionsInfo.add(new ActionSetFieldTunnelId(tunnelId));
- LOG.debug("AbstractSnatService : Setting the tunnel to the list of action infos {}", actionsInfo);
- actionsInfo.add(new ActionGroup(groupId));
- List<InstructionInfo> instructions = new ArrayList<>();
- instructions.add(new InstructionApplyActions(actionsInfo));
- String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
- addFlow(confTx, dpnId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef,
- NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
@Override
- protected void removeSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId, String routerName) {
+ protected void removeSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, String routerName)
+ throws ExecutionException, InterruptedException {
LOG.debug("installSnatMissEntry : Removing SNAT miss entry in switch {}", dpnId);
String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
- removeFlow(confTx, dpnId, NwConstants.PSNAT_TABLE, flowRef);
+ NatUtil.removeFlow(confTx, mdsalManager, dpnId, NwConstants.PSNAT_TABLE, flowRef);
}
}