import com.google.common.base.Optional;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+
import java.math.BigInteger;
import java.net.Inet6Address;
import java.net.InetAddress;
NatUtil.removePreDnatToSnatTableEntry(removeFlowInvTx, mdsalManager, dpnId);
RemoveVpnLabelInput labelInput = new RemoveVpnLabelInputBuilder()
.setVpnName(externalVpn).setIpPrefix(externalIp).build();
- return vpnService.removeVpnLabel(labelInput);
+ Future<RpcResult<RemoveVpnLabelOutput>> labelFuture1 = vpnService.removeVpnLabel(labelInput);
+ if (labelFuture1.get() == null || !labelFuture1.get().isSuccessful()) {
+ String errMsg = String.format(
+ "ExternalRoutersListener: RPC call to remove VPN label "
+ + "on dpn %s for prefix %s failed for vpn %s - %s",
+ dpnId, externalIp, result.getErrors());
+ LOG.error(errMsg);
+ return Futures.immediateFailedFuture(new RuntimeException(errMsg));
+ }
+ return JdkFutureAdapters.listenInPoolThread(labelFuture1);
} else {
String errMsg =
String.format("RPC call to remove custom FIB entries on dpn %s for "
if (result.isSuccessful()) {
RemoveVpnLabelInput labelInput = new RemoveVpnLabelInputBuilder()
.setVpnName(vpnName).setIpPrefix(externalIp).build();
- return vpnService.removeVpnLabel(labelInput);
+ Future<RpcResult<RemoveVpnLabelOutput>> labelFuture1 = vpnService
+ .removeVpnLabel(labelInput);
+ if (labelFuture1.get() == null || !labelFuture1.get().isSuccessful()) {
+ String errMsg = String.format(
+ "RPC call to remove VPN label on dpn %s for prefix %s "
+ + "failed for vpn %s - %s", dpnId, externalIp, vpnName,
+ result.getErrors());
+ LOG.error(errMsg);
+ return Futures.immediateFailedFuture(new RuntimeException(errMsg));
+ }
+ return JdkFutureAdapters.listenInPoolThread(labelFuture1);
} else {
String errMsg =
String.format("RPC call to remove custom FIB entries on dpn %s for "
import com.google.common.base.Optional;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNull;
removeLFibTableEntry(dpnId, label, confTx);
RemoveVpnLabelInput labelInput = new RemoveVpnLabelInputBuilder()
.setVpnName(vpnName).setIpPrefix(externalIp).build();
- return vpnService.removeVpnLabel(labelInput);
+ Future<RpcResult<RemoveVpnLabelOutput>> labelFuture1 = vpnService.removeVpnLabel(labelInput);
+ if (labelFuture1.get() == null || !labelFuture1.get().isSuccessful()) {
+ String errMsg = String.format(
+ "VpnFloatingIpHandler: RPC call to remove VPN label on dpn %s "
+ + "for prefix %s failed for vpn %s - %s",
+ dpnId, externalIp, vpnName, result.getErrors());
+ LOG.error(errMsg);
+ return Futures.immediateFailedFuture(new RuntimeException(errMsg));
+ }
+ return JdkFutureAdapters.listenInPoolThread(labelFuture1);
} else {
String errMsg = String.format("onRemoveFloatingIp :RPC call to remove custom FIB entries "
+ "on dpn %s for prefix %s Failed - %s", dpnId, externalIp, result.getErrors());
Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
VpnUtil.getNextHopLabelKey(primaryRd, prefix));
-
+ if (label.longValue() == VpnConstants.INVALID_LABEL) {
+ LOG.error(
+ "createFibEntryForRouterInterface: Unable to retrieve label for vpn pool {}, "
+ + "vpninterface {}, vpn {}, rd {}",
+ VpnConstants.VPN_IDPOOL_NAME, interfaceName, vpnName, primaryRd);
+ return;
+ }
RouterInterface routerInt = new RouterInterfaceBuilder().setUuid(vpnName)
.setIpAddress(primaryInterfaceIp).setMacAddress(macAddress).build();
fibManager.addFibEntryForRouterInterface(primaryRd, prefix,
Future<RpcResult<CreateIdPoolOutput>> result = idManager.createIdPool(createPool);
if (result != null && result.get().isSuccessful()) {
LOG.info("Created IdPool for VPN Service");
+ } else {
+ LOG.error("createIdPool: Unable to create ID pool for VPNService");
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to create idPool for VPN Service", e);
.build();
try {
Future<RpcResult<CreateIdPoolOutput>> result = idManager.createIdPool(createPseudoLporTagPool);
- if (result.get().isSuccessful()) {
+ if (result != null && result.get().isSuccessful()) {
LOG.debug("Created IdPool for Pseudo Port tags");
} else {
- Collection<RpcError> errors = result.get().getErrors();
StringBuilder errMsg = new StringBuilder();
- for (RpcError err : errors) {
- errMsg.append(err.getMessage()).append("\n");
+ if (result != null && result.get() != null) {
+ Collection<RpcError> errors = result.get().getErrors();
+ for (RpcError err : errors) {
+ errMsg.append(err.getMessage()).append("\n");
+ }
}
LOG.error("IdPool creation for PseudoPort tags failed. Reasons: {}", errMsg);
}
String dstVpnRd = vpnUtil.getVpnRd(dstVpnUuid);
Uint32 newLabel = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
VpnUtil.getNextHopLabelKey(dstVpnRd, destination));
- if (newLabel.longValue() == 0) {
+ if (newLabel.longValue() == VpnConstants.INVALID_LABEL) {
LOG.error("addExtraRoute: Unable to fetch label from Id Manager. Bailing out of adding intervpnlink"
+ " route for destination {}", destination);
return;
String rd = vpnUtil.getVpnRd(vpnName);
Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnName, ipPrefix));
- if (label == null || label.longValue() == 0) {
+ if (label == null || label.longValue() == VpnConstants.INVALID_LABEL) {
futureResult.set(RpcResultBuilder.<GenerateVpnLabelOutput>failed().withError(ErrorType.APPLICATION,
formatAndLog(LOG::error, "Could not retrieve the label for prefix {} in VPN {}", ipPrefix,
vpnName)).build());
return result;
}
- if (label == null || label.longValue() == 0) {
+ if (label == null || label.longValue() == VpnConstants.INVALID_LABEL) {
label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
VpnUtil.getNextHopLabelKey(vpnInstanceName, destination));
- if (label.longValue() == 0) {
+ if (label.longValue() == VpnConstants.INVALID_LABEL) {
String message = "Unable to retrieve a new Label for the new Route";
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(RpcError.ErrorType.APPLICATION,
message).build());
+ LOG.error("addStaticRoute: Unable to retrieve label for static route with destination {}, vpninstance"
+ + " {}, nexthop {}", destination, vpnInstanceName, nexthop);
return result;
}
}
l3vni = subOpBuilder.getL3vni();
} else {
label = subOpBuilder.getLabel();
+ if (label.longValue() == VpnConstants.INVALID_LABEL) {
+ LOG.error("publishSubnetRouteToBgp: Label not found for rd {}, subnetIp {}",
+ subOpBuilder.getVrfId(), subOpBuilder.getSubnetCidr());
+ return;
+ }
}
bgpManager.advertisePrefix(subOpBuilder.getVrfId(), null /*macAddress*/, subOpBuilder.getSubnetCidr(),
Arrays.asList(nextHopIp), encapType, label, l3vni,
String rd = vpnUtil.getVpnRd(vpnInstName);
Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnInstName, ip));
- if (label.longValue() == 0) {
+ if (label.longValue() == VpnConstants.INVALID_LABEL) {
LOG.error("Unable to fetch label from Id Manager. Bailing out of adding MIP adjacency {}"
+ " to vpn interface {} for vpn {}", ip, vpnInterface, vpnInstName);
return;