use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class VpnInterfaceManager method processVpnInterfaceDown.
protected void processVpnInterfaceDown(Uint64 dpId, String interfaceName, int lportTag, String gwMac, VpnInterfaceOpDataEntry vpnOpInterface, boolean isInterfaceStateDown, TypedWriteTransaction<Configuration> writeConfigTxn, TypedWriteTransaction<Operational> writeOperTxn, TypedReadWriteTransaction<Configuration> writeInvTxn) throws ExecutionException, InterruptedException {
if (vpnOpInterface == null) {
LOG.error("processVpnInterfaceDown: Unable to process delete/down for interface {} on dpn {}" + " as it is not available in operational data store", interfaceName, dpId);
return;
}
final String vpnName = vpnOpInterface.getVpnInstanceName();
InstanceIdentifier<VpnInterfaceOpDataEntry> identifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
if (!isInterfaceStateDown) {
final Uint32 vpnId = vpnUtil.getVpnId(vpnName);
vpnUtil.scheduleVpnInterfaceForRemoval(interfaceName, dpId, vpnName, null);
final boolean isBgpVpnInternetVpn = vpnUtil.isBgpVpnInternet(vpnName);
removeAdjacenciesFromVpn(dpId, lportTag, interfaceName, vpnName, vpnId, gwMac, writeConfigTxn, writeOperTxn, writeInvTxn);
if (interfaceManager.isExternalInterface(interfaceName)) {
processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.DEL_FLOW);
}
if (!isBgpVpnInternetVpn) {
vpnUtil.unbindService(interfaceName, isInterfaceStateDown);
}
LOG.info("processVpnInterfaceDown: Unbound vpn service from interface {} on dpn {} for vpn {}" + " successful", interfaceName, dpId, vpnName);
} else {
// Interface is retained in the DPN, but its Link Down.
// Only withdraw the prefixes for this interface from BGP
withdrawAdjacenciesForVpnFromBgp(identifier, vpnName, interfaceName, writeConfigTxn, writeOperTxn);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class VpnInterfaceOpListener method postProcessVpnInterfaceRemoval.
private void postProcessVpnInterfaceRemoval(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, VpnInterfaceOpDataEntry del, @Nullable TypedReadWriteTransaction<Operational> operTx, @Nullable TypedReadTransaction<Configuration> confTx) throws InterruptedException {
if (confTx == null) {
txRunner.callWithNewReadOnlyTransactionAndClose(CONFIGURATION, tx -> postProcessVpnInterfaceRemoval(identifier, del, operTx, tx));
return;
}
if (operTx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> postProcessVpnInterfaceRemoval(identifier, del, tx, confTx)), LOG, "Error post-processing VPN interface removal");
return;
}
final VpnInterfaceOpDataEntryKey key = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class);
String interfaceName = key.getName();
String vpnName = del.getVpnInstanceName();
try {
LOG.info("postProcessVpnInterfaceRemoval: interface name {} vpnName {} dpn {}", interfaceName, vpnName, del.getDpnId());
// decrement the vpn interface count in Vpn Instance Op Data
Optional<VpnInstance> vpnInstance = confTx.read(VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnName)).get();
if (vpnInstance.isPresent()) {
String rd = vpnInstance.get().getVrfId();
VpnInstanceOpDataEntry vpnInstOp = vpnUtil.getVpnInstanceOpData(rd);
AdjacenciesOp adjs = del.augmentation(AdjacenciesOp.class);
Map<AdjacencyKey, Adjacency> adjMap = adjs != null ? adjs.getAdjacency() : null;
if (vpnInstOp != null && adjMap != null && adjMap.size() > 0) {
/*
* When a VPN Interface is removed by FibManager (aka VrfEntryListener and its cohorts),
* one adjacency or two adjacency (in case of dual-stack)
* for that VPN Interface will be hanging around along with that
* VPN Interface. That adjacency could be primary (or) non-primary.
* If its a primary adjacency, then a prefix-to-interface entry will be available for the
* same. If its a non-primary adjacency, then a prefix-to-interface entry will not be
* available for the same, instead we will have vpn-to-extraroutes filled in for them.
*
* Here we try to remove prefix-to-interface entry for pending adjacency in the deleted
* vpnInterface. More importantly, we also update the vpnInstanceOpData by removing this
* vpnInterface from it.
*/
List<Prefixes> prefixToInterface = new ArrayList<>();
for (Adjacency adjacency : adjs.getAdjacency().values()) {
List<Prefixes> prefixToInterfaceLocal = new ArrayList<>();
Optional<Prefixes> prefix = operTx.read(VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), VpnUtil.getIpPrefix(adjacency.getIpAddress()))).get();
if (prefix.isPresent()) {
prefixToInterfaceLocal.add(prefix.get());
}
if (prefixToInterfaceLocal.isEmpty() && adjacency.getNextHopIpList() != null) {
for (String nh : adjacency.getNextHopIpList()) {
prefix = operTx.read(VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), VpnUtil.getIpPrefix(nh))).get();
if (prefix.isPresent()) {
prefixToInterfaceLocal.add(prefix.get());
}
}
}
if (!prefixToInterfaceLocal.isEmpty()) {
prefixToInterface.addAll(prefixToInterfaceLocal);
}
}
/*
* In VPN Migration scenarios, there is a race condition where we use the new DPNID
* for the migrated VM instead of old DPNID because when we read prefix-to-interface to cleanup
* old DPNID, we actually get the new DPNID.
*
* More dangerously, we tend to alter the new prefix-to-interface which should be retained intac
* for the migration to succeed in L3VPN. As a workaround, here we are going to use the dpnId in
* the deleted vpnInterface itself instead of tinkering with the prefix-to-interface. Further we
* will tinker prefix-to-interface only when are damn sure if its value matches our
* deleted vpnInterface.
*
*/
for (Prefixes pref : prefixToInterface) {
if (VpnUtil.isMatchedPrefixToInterface(pref, del)) {
operTx.delete(VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), pref.getIpAddress()));
}
}
}
if (del.getDpnId() != null) {
vpnFootprintService.updateVpnToDpnMapping(del.getDpnId(), del.getVpnInstanceName(), rd, interfaceName, null, /*ipAddressSourceValuePair*/
false);
}
LOG.info("postProcessVpnInterfaceRemoval: Removed vpn operational data and updated vpn footprint" + " for interface {} on dpn {} vpn {}", interfaceName, del.getDpnId(), vpnName);
} else {
LOG.error("postProcessVpnInterfaceRemoval: rd not retrievable as vpninstancetovpnid for vpn {}" + " is absent, trying rd as {}. interface {} dpn {}", vpnName, vpnName, interfaceName, del.getDpnId());
}
notifyTaskIfRequired(interfaceName);
} catch (InterruptedException | ExecutionException e) {
LOG.error("postProcessVpnInterfaceRemoval: Failed to read data store for interface {} vpn {}", interfaceName, vpnName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class VpnServiceElanDpnInterfacesListener method add.
@Override
public void add(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces dpnInterfaces) {
Uint64 dpnId = dpnInterfaces.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = vpnUtil.getElanInstanceByName(elanInstanceName);
if (!VpnUtil.isVlan(elanInstance)) {
return;
}
String vpnName = vpnUtil.getVpnNameFromElanIntanceName(elanInstanceName);
if (vpnName == null) {
return;
}
vpnUtil.addRouterPortToElanForVlanInDpn(vpnName, dpnId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class FibEntriesListener method add.
@Override
public void add(InstanceIdentifier<VrfEntry> identifier, VrfEntry add) {
LOG.trace("Add Vrf Entry event - Key : {}, value : {}", identifier, add);
final VrfTablesKey key = identifier.firstKeyOf(VrfTables.class);
String rd = key.getRouteDistinguisher();
addLabelToVpnInstance(rd, new ArrayList<RoutePaths>(add.nonnullRoutePaths().values()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class SubnetRouteInterfaceStateChangeListener method add.
@Override
public void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
LOG.trace("{} add: Received interface {} up event", LOGGING_PREFIX, intrf);
if (L2vlan.class.equals(intrf.getType())) {
LOG.trace("SubnetRouteInterfaceListener add: Received interface {} up event", intrf);
if (Interface.OperStatus.Up.equals(intrf.getOperStatus())) {
List<Uuid> subnetIdList = getSubnetId(intrf);
if (subnetIdList.isEmpty()) {
LOG.trace("SubnetRouteInterfaceListener add: Port {} doesn't exist in configDS", intrf.getName());
return;
}
for (Uuid subnetId : subnetIdList) {
jobCoordinator.enqueueJob("SUBNETROUTE-" + subnetId, () -> {
String interfaceName = intrf.getName();
Uint64 dpnId = Uint64.ZERO;
LOG.info("{} add: Received port UP event for interface {} subnetId {}", LOGGING_PREFIX, interfaceName, subnetId);
try {
dpnId = InterfaceUtils.getDpIdFromInterface(intrf);
} catch (NullPointerException e) {
LOG.error("{} add: Unable to obtain dpnId for interface {} in subnet {}," + " subnetroute inclusion for this interface failed", LOGGING_PREFIX, interfaceName, subnetId, e);
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
try {
InstanceIdentifier<VpnInterface> id = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
Optional<VpnInterface> cfgVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (!cfgVpnInterface.isPresent()) {
return futures;
}
vpnSubnetRouteHandler.onInterfaceUp(dpnId, intrf.getName(), subnetId);
LOG.info("{} add: Processed interface {} up event", LOGGING_PREFIX, intrf.getName());
} catch (InterruptedException | ExecutionException e) {
LOG.error("add: Failed to read data store for interface {} dpn {}", interfaceName, dpnId);
}
return futures;
});
}
}
}
}
Aggregations