use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class VrfEntryListener method manageRemoteRouteOnDPN.
public void manageRemoteRouteOnDPN(final boolean action, final Uint64 localDpnId, final Uint32 vpnId, final String rd, final String destPrefix, final String destTepIp, final Uint32 label) {
final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
if (vpnInstance == null) {
LOG.error("VpnInstance for rd {} not present for prefix {}", rd, destPrefix);
return;
}
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, localDpnId), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
final ReentrantLock lock = lockFor(vpnInstance);
lock.lock();
try {
VrfTablesKey vrfTablesKey = new VrfTablesKey(rd);
VrfEntry vrfEntry = getVrfEntry(dataBroker, rd, destPrefix);
if (vrfEntry == null) {
return;
}
LOG.trace("manageRemoteRouteOnDPN :: action {}, DpnId {}, vpnId {}, rd {}, destPfx {}", action, localDpnId, vpnId, rd, destPrefix);
Map<RoutePathsKey, RoutePaths> keyRoutePathsMap = vrfEntry.getRoutePaths();
VrfEntry modVrfEntry;
if (keyRoutePathsMap == null || keyRoutePathsMap.isEmpty()) {
modVrfEntry = FibHelper.getVrfEntryBuilder(vrfEntry, label, Collections.singletonList(destTepIp), RouteOrigin.value(vrfEntry.getOrigin()), null).build();
} else {
modVrfEntry = vrfEntry;
}
if (action) {
LOG.trace("manageRemoteRouteOnDPN updated(add) vrfEntry :: {}", modVrfEntry);
createRemoteFibEntry(localDpnId, vpnId, vrfTablesKey.getRouteDistinguisher(), modVrfEntry, tx);
} else {
LOG.trace("manageRemoteRouteOnDPN updated(remove) vrfEntry :: {}", modVrfEntry);
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
if (usedRds.size() > 1) {
LOG.debug("The extra route prefix is still present in some DPNs");
return;
}
// Is this fib route an extra route? If yes, get the nexthop which would be
// an adjacency in the vpn
Optional<Routes> extraRouteOptional = Optional.empty();
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.STATIC && usedRds.size() != 0) {
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, fibUtil.getVpnNameFromId(vpnInstance.getVpnId()), usedRds.get(0), vrfEntry.getDestPrefix());
}
baseVrfEntryHandler.deleteRemoteRoute(null, localDpnId, vpnId, vrfTablesKey, modVrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
}
} finally {
lock.unlock();
}
})));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method removeFlows.
void removeFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(vrfTableKey.getRouteDistinguisher()).get();
if (vpnInstance == null) {
LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
}
VpnNexthop localNextHopInfo = nexthopManager.getVpnNexthop(vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
List<Uint64> localDpnId = checkDeleteLocalEvpnFLows(vpnInstance.getVpnId(), rd, vrfEntry, localNextHopInfo);
deleteRemoteEvpnFlows(rd, vrfEntry, vpnInstance, vrfTableKey, localDpnId);
vrfEntryListener.cleanUpOpDataForFib(vpnInstance.getVpnId(), rd, vrfEntry);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class BgpRouteVrfEntryHandler method deleteFibEntries.
/*
Please note that the following deleteFibEntries will be invoked only for BGP Imported Routes.
The invocation of the following method is via delete() callback from the MDSAL Batching Infrastructure
provided by ResourceBatchingManager
*/
private void deleteFibEntries(WriteTransaction writeTx, final InstanceIdentifier<VrfEntry> identifier, final VrfEntry vrfEntry, List<SubTransaction> subTxns) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
String rd = vrfTableKey.getRouteDistinguisher();
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(vrfTableKey.getRouteDistinguisher());
if (vpnInstance == null) {
LOG.debug("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
}
String vpnName = getFibUtil().getVpnNameFromId(vpnInstance.getVpnId());
final Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap = vpnInstance.nonnullVpnToDpnList();
if (keyVpnToDpnListMap != null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
Optional<Routes> extraRouteOptional;
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
if (usedRds != null && !usedRds.isEmpty()) {
if (usedRds.size() > 1) {
LOG.error("The extra route prefix is still present in some DPNs");
return;
} else {
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRds.get(0), vrfEntry.getDestPrefix());
}
} else {
extraRouteOptional = Optional.empty();
}
for (VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
deleteRemoteRoute(Uint64.ZERO, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, writeTx, subTxns);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class FibUtil method updateUsedRdAndVpnToExtraRoute.
public void updateUsedRdAndVpnToExtraRoute(TypedReadWriteTransaction<Configuration> confTx, TypedReadWriteTransaction<Operational> operTx, String tunnelIpRemoved, String primaryRd, String prefix) throws ExecutionException, InterruptedException {
Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(operTx, primaryRd);
if (!optVpnInstance.isPresent()) {
return;
}
VpnInstanceOpDataEntry vpnInstance = optVpnInstance.get();
String vpnName = vpnInstance.getVpnInstanceName();
Uint32 vpnId = vpnInstance.getVpnId();
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(confTx, vpnId, prefix);
// which rd is allocated for the particular OVS.
for (String usedRd : usedRds) {
Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getVpnExtraroutes(operTx, vpnName, usedRd, prefix);
if (vpnExtraRoutes.isPresent()) {
// Since all the nexthops under one OVS will be present under one rd, only 1 nexthop is read
// to identify the OVS
String nextHopRemoved = vpnExtraRoutes.get().getNexthopIpList().get(0);
Prefixes prefixToInterface = getPrefixToInterface(operTx, vpnId, getIpPrefix(nextHopRemoved));
if (prefixToInterface != null && tunnelIpRemoved.equals(getEndpointIpAddressForDPN(prefixToInterface.getDpnId()))) {
LOG.info("updating data-stores for prefix {} with primaryRd {} for interface {} on vpn {} ", prefix, primaryRd, prefixToInterface.getVpnInterfaceName(), vpnName);
operTx.delete(FibUtil.getAdjacencyIdentifierOp(prefixToInterface.getVpnInterfaceName(), vpnName, prefix));
operTx.delete(VpnExtraRouteHelper.getVpnToExtrarouteVrfIdIdentifier(vpnName, usedRd, prefix));
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, prefix, nextHopRemoved));
break;
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method deleteRemoteEvpnFlows.
// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
private void deleteRemoteEvpnFlows(String rd, VrfEntry vrfEntry, VpnInstanceOpDataEntry vpnInstance, VrfTablesKey vrfTableKey, List<Uint64> localDpnIdList) {
Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap = vpnInstance.nonnullVpnToDpnList();
List<SubTransaction> subTxns = new ArrayList<>();
if (keyVpnToDpnListMap != null) {
jobCoordinator.enqueueJob("FIB" + rd + vrfEntry.getDestPrefix(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
final Optional<Routes> extraRouteOptional = Optional.empty();
if (localDpnIdList.size() <= 0) {
for (VpnToDpnList curDpn1 : keyVpnToDpnListMap.values()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
if (curDpn1.getDpnState() == VpnToDpnList.DpnState.Active) {
bgpRouteVrfEntryHandler.deleteRemoteRoute(Uint64.ZERO, curDpn1.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx), subTxns);
}
} else {
deleteRemoteRoute(Uint64.ZERO, curDpn1.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
}
}
} else {
for (Uint64 localDpnId : localDpnIdList) {
for (VpnToDpnList curDpn2 : keyVpnToDpnListMap.values()) {
if (!Objects.equals(curDpn2.getDpnId(), localDpnId)) {
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
if (curDpn2.getDpnState() == VpnToDpnList.DpnState.Active) {
bgpRouteVrfEntryHandler.deleteRemoteRoute(localDpnId, curDpn2.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx), subTxns);
}
} else {
deleteRemoteRoute(localDpnId, curDpn2.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
}
}
}
}
}
})));
}
}
Aggregations