import static org.opendaylight.netvirt.natservice.internal.AbstractSnatService.LOAD_START;
import static org.opendaylight.netvirt.natservice.internal.NatUtil.getGroupIdKey;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.mdsalutil.matches.MatchEthernetType;
import org.opendaylight.genius.mdsalutil.matches.MatchMetadata;
import org.opendaylight.genius.mdsalutil.matches.MatchTunnelId;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.netvirt.natservice.api.SnatServiceListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public boolean addCentralizedRouterAllSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger primarySwitchId) {
+ Routers routers, Uint64 primarySwitchId) {
String routerName = routers.getRouterName();
LOG.info("handleSnatAllSwitch : invoked for router {} with NAPTSwitch {} for {} flows",
routerName, primarySwitchId, "installing");
- List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
+ List<Uint64> switches = naptSwitchSelector.getDpnsForVpn(routerName);
/*
* Primary switch handled separately since the pseudo port created may
* not be present in the switch list on delete.
*/
addCentralizedRouter(confTx, routers, primarySwitchId, primarySwitchId);
- for (BigInteger dpnId : switches) {
+ for (Uint64 dpnId : switches) {
if (!Objects.equals(primarySwitchId, dpnId)) {
addCentralizedRouter(confTx, routers, primarySwitchId, dpnId);
}
@Override
public boolean addCentralizedRouter(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger primarySwitchId, BigInteger dpnId) {
- Long routerId = NatUtil.getVpnId(dataBroker, routers.getRouterName());
- BigInteger routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId);
+ Routers routers, Uint64 primarySwitchId, Uint64 dpnId) {
+ Uint32 routerId = NatUtil.getVpnId(dataBroker, routers.getRouterName());
+ Uint64 routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId.longValue());
if (!dpnId.equals(primarySwitchId)) {
LOG.info("handleSnat (non-NAPTSwitch) : {} flows on switch {} for router {}",
addIpv6NaptPfibInboundFlow(confTx, dpnId, routerId, routerMetadata);
// Now installing flows that use SubnetInfo
- ipv6SubnetFlowProgrammer. addSubnetSpecificFlows(confTx, dpnId, routerId, routers, routerMetadata);
+ ipv6SubnetFlowProgrammer.addSubnetSpecificFlows(confTx, dpnId, routerId, routers, routerMetadata);
}
return true;
}
@Override
public boolean removeCentralizedRouterAllSwitch(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger primarySwitchId) throws ExecutionException, InterruptedException {
+ Routers routers, Uint64 primarySwitchId) throws ExecutionException, InterruptedException {
String routerName = routers.getRouterName();
LOG.info("handleSnatAllSwitch : invoked for router {} with NAPTSwitch {} for {} flows",
routerName, primarySwitchId, "removing");
- List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
+ List<Uint64> switches = naptSwitchSelector.getDpnsForVpn(routerName);
/*
* Primary switch handled separately since the pseudo port created may
* not be present in the switch list on delete.
*/
removeCentralizedRouter(confTx, routers, primarySwitchId, primarySwitchId);
- for (BigInteger dpnId : switches) {
+ for (Uint64 dpnId : switches) {
if (!Objects.equals(primarySwitchId, dpnId)) {
removeCentralizedRouter(confTx, routers, primarySwitchId, dpnId);
}
@Override
public boolean removeCentralizedRouter(TypedReadWriteTransaction<Configuration> confTx,
- Routers routers, BigInteger primarySwitchId, BigInteger dpnId)
+ Routers routers, Uint64 primarySwitchId, Uint64 dpnId)
throws ExecutionException, InterruptedException {
- Long routerId = NatUtil.getVpnId(dataBroker, routers.getRouterName());
- BigInteger routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId);
+ Uint32 routerId = NatUtil.getVpnId(dataBroker, routers.getRouterName());
+ Uint64 routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId.longValue());
if (!dpnId.equals(primarySwitchId)) {
LOG.info("handleSnat (non-NAPTSwitch) : {} flows on switch {} for router {}",
Routers origRouter, Routers updatedRouter) throws ExecutionException, InterruptedException {
LOG.info("handleRouterUpdate : originalRouter {}, updatedRouter {}", origRouter, updatedRouter);
String routerName = origRouter.getRouterName();
- BigInteger primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
- Long routerId = NatUtil.getVpnId(dataBroker, routerName);
- BigInteger routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId);
+ Uint64 primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
+ Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
+ Uint64 routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId.longValue());
// If the external network is updated with an IPv6Subnet, program the necessary flows on non-NAPTSwitch
if (!routerHasIpv6ExtSubnet(origRouter) && routerHasIpv6ExtSubnet(updatedRouter)) {
- List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
- for (BigInteger dpnId : switches) {
+ List<Uint64> switches = naptSwitchSelector.getDpnsForVpn(routerName);
+ for (Uint64 dpnId : switches) {
if (!Objects.equals(primarySwitchId, dpnId)) {
LOG.info("handleRouterUpdate (non-NAPTSwitch) : Installing flows on switch {} for router {}",
dpnId, routerName);
@Override
public boolean addSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) {
+ Uint64 primarySwitchId) {
return true;
}
@Override
public boolean addSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) {
+ Uint64 primarySwitchId, Uint64 dpnId) {
return true;
}
@Override
public boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId) throws ExecutionException, InterruptedException {
+ Uint64 primarySwitchId) throws ExecutionException, InterruptedException {
return true;
}
@Override
public boolean removeSnat(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
- BigInteger primarySwitchId, BigInteger dpnId) throws ExecutionException, InterruptedException {
+ Uint64 primarySwitchId, Uint64 dpnId) throws ExecutionException, InterruptedException {
return true;
}
- protected void addIpv6DefaultFibRoute(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId, BigInteger routerMetadata) {
+ protected void addIpv6DefaultFibRoute(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, Uint64 routerMetadata) {
LOG.debug("installIpv6DefaultFibRoute : Installing default FIB route to PSNAT_TABLE on {}", dpnId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
- protected void removeIpv6DefaultFibRoute(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- Long routerId) throws ExecutionException, InterruptedException {
+ protected void removeIpv6DefaultFibRoute(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId) throws ExecutionException, InterruptedException {
LOG.debug("installIpv6DefaultFibRoute : Installing default FIB route to PSNAT_TABLE on {}", dpnId);
String flowRef = NatUtil.getIpv6FlowRef(dpnId, NwConstants.L3_FIB_TABLE, routerId);
flowRef += ".Outbound";
}
protected void addIpv6PsNatMissEntryNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId, String routerName, BigInteger primarySwitchId) {
+ Uint64 dpnId, Uint32 routerId, String routerName, Uint64 primarySwitchId) {
LOG.debug("installIpv6PsNatMissEntryNonNaptSwitch : On Non-Napt Switch, installing SNAT miss entry in"
+ " switch {} for router {}", dpnId, routerName);
List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
mdsalManager.addGroup(confTx, groupEntity);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
- matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
+ matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()),
+ MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfo = new ArrayList<>();
- actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(routerId)));
+ actionsInfo.add(new ActionSetFieldTunnelId(Uint64.valueOf(routerId)));
actionsInfo.add(new ActionGroup(groupId));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfo));
}
protected void addIpv6SnatMissEntryForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId, BigInteger routerMetadata) {
+ Uint64 dpnId, Uint32 routerId, Uint64 routerMetadata) {
LOG.debug("installIpv6SnatMissEntryForNaptSwitch {} called for routerId {}", dpnId, routerId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
}
protected void removeIpv6SnatMissEntryForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId)
+ Uint64 dpnId, Uint32 routerId)
throws ExecutionException, InterruptedException {
LOG.debug("installIpv6SnatMissEntryForNaptSwitch {} called for routerId {}", dpnId, routerId);
String flowRef = NatUtil.getIpv6FlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
}
protected void addIpv6TerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId, BigInteger routerMetadata) {
+ Uint64 dpnId, Uint32 routerId, Uint64 routerMetadata) {
LOG.debug("installIpv6TerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
- matches.add(new MatchTunnelId(BigInteger.valueOf(routerId)));
+ matches.add(new MatchTunnelId(Uint64.valueOf(routerId)));
List<ActionInfo> actionsInfos = new ArrayList<>();
ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(routerMetadata, LOAD_START, LOAD_END);
}
protected void removeIpv6TerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx,
- BigInteger dpnId, Long routerId) throws ExecutionException, InterruptedException {
+ Uint64 dpnId, Uint32 routerId) throws ExecutionException, InterruptedException {
LOG.debug("installIpv6TerminatingServiceTblEntry : creating entry for Terminating Service Table "
+ "for switch {}, routerId {}", dpnId, routerId);
String flowRef = NatUtil.getIpv6FlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId);
}
- protected void addIpv6NaptPfibInboundFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId, BigInteger routerMetadata) {
+ protected void addIpv6NaptPfibInboundFlow(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId, Uint64 routerMetadata) {
LOG.debug("installIpv6NaptPfibInboundFlow : called for dpnId {} and routerId {} ", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
- listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
+ listActionInfo.add(new ActionNxLoadInPort(Uint64.ZERO));
listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
instructionInfo.add(new InstructionApplyActions(listActionInfo));
matches, instructionInfo);
}
- protected void removeIpv6NaptPfibInboundFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
- long routerId)
+ protected void removeIpv6NaptPfibInboundFlow(TypedReadWriteTransaction<Configuration> confTx, Uint64 dpnId,
+ Uint32 routerId)
throws ExecutionException, InterruptedException {
LOG.debug("installIpv6NaptPfibInboundFlow : called for dpnId {} and routerId {} ", dpnId, routerId);
String flowRef = NatUtil.getIpv6FlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
- return rpcResult.getResult().getIdValue();
+ return rpcResult.getResult().getIdValue().toJava();
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("createGroupIdForIPv6Router: Exception while creating group with key : {}", groupIdKey, e);
}
}
protected boolean routerHasIpv6ExtSubnet(Routers routers) {
- for (ExternalIps externalIp : routers.getExternalIps()) {
+ for (ExternalIps externalIp : routers.getExternalIps().values()) {
if (!NWUtil.isIpv4Address(externalIp.getIpAddress())) {
LOG.debug("router {}, has an external IPv6 subnet {}",
routers.getRouterName(), externalIp.getIpAddress());