use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.
the class ElanUtils method deleteSmacAndDmacFlows.
private void deleteSmacAndDmacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
String elanInstanceName = elanInfo.getElanInstanceName();
Uint64 srcdpId = interfaceInfo.getDpId();
Uint32 elanTag = elanInfo.getElanTag();
if (deleteSmac) {
LOG.debug("Deleting SMAC flow with id {}", getKnownDynamicmacFlowRef(elanTag, macAddress));
mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
}
mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.
the class ElanUtils method getParticipatingDpnsInElanInstance.
/**
* This method is useful get all ELAN participating CSS dpIds to install
* program remote dmac entries and updating remote bc groups for tor
* integration.
*
* @param elanInstanceName
* the elan instance name
* @return list of dpIds
*/
@NonNull
public List<Uint64> getParticipatingDpnsInElanInstance(String elanInstanceName) {
List<Uint64> dpIds = new ArrayList<>();
InstanceIdentifier<ElanDpnInterfacesList> elanDpnInterfaceId = getElanDpnOperationDataPath(elanInstanceName);
Optional<ElanDpnInterfacesList> existingElanDpnInterfaces = read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
if (!existingElanDpnInterfaces.isPresent()) {
return dpIds;
}
Map<DpnInterfacesKey, DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().nonnullDpnInterfaces();
for (DpnInterfaces dpnInterface : dpnInterfaces.values()) {
dpIds.add(dpnInterface.getDpId());
}
return dpIds;
}
use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.
the class BaseVrfEntryHandler method makeConnectedRoute.
// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
protected void makeConnectedRoute(Uint64 dpId, Uint32 vpnId, VrfEntry vrfEntry, String rd, @Nullable List<InstructionInfo> instructions, int addOrRemove, WriteTransaction tx, @Nullable List<SubTransaction> subTxns) {
if (tx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, newTx -> makeConnectedRoute(dpId, vpnId, vrfEntry, rd, instructions, addOrRemove, TransactionAdapter.toWriteTransaction(newTx), subTxns)), LOG, "Error making connected route");
return;
}
LOG.trace("makeConnectedRoute: vrfEntry {}", vrfEntry);
String[] values = vrfEntry.getDestPrefix().split("/");
String ipAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
if (addOrRemove == NwConstants.ADD_FLOW) {
LOG.debug("Adding route to DPN {} for rd {} prefix {} ", dpId, rd, vrfEntry.getDestPrefix());
} else {
LOG.debug("Removing route from DPN {} for rd {} prefix {}", dpId, rd, vrfEntry.getDestPrefix());
}
InetAddress destPrefix;
try {
destPrefix = InetAddress.getByName(ipAddress);
} catch (UnknownHostException e) {
LOG.error("Failed to get destPrefix for prefix {} rd {} VpnId {} DPN {}", vrfEntry.getDestPrefix(), rd, vpnId, dpId, e);
return;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId.longValue()), MetaDataUtil.METADATA_MASK_VRFID));
if (destPrefix instanceof Inet4Address) {
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
}
} else {
matches.add(MatchEthernetType.IPV6);
if (prefixLength != 0) {
matches.add(new MatchIpv6Destination(destPrefix.getHostAddress() + "/" + prefixLength));
}
}
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
String flowRef = FibUtil.getFlowRef(dpId, NwConstants.L3_FIB_TABLE, rd, priority, destPrefix);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, COOKIE_VM_FIB_TABLE, matches, instructions);
Flow flow = flowEntity.getFlowBuilder().build();
String flowId = flowEntity.getFlowId();
FlowKey flowKey = new FlowKey(new FlowId(flowId));
Node nodeDpn = FibUtil.buildDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
SubTransaction subTransaction = new SubTransactionImpl();
if (addOrRemove == NwConstants.ADD_FLOW) {
subTransaction.setInstanceIdentifier(flowInstanceId);
subTransaction.setInstance(flow);
subTransaction.setAction(SubTransaction.CREATE);
} else {
subTransaction.setInstanceIdentifier(flowInstanceId);
subTransaction.setAction(SubTransaction.DELETE);
}
subTxns.add(subTransaction);
}
if (addOrRemove == NwConstants.ADD_FLOW) {
tx.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
} else {
tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
}
use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.
the class BaseVrfEntryHandler method deleteRemoteRoute.
// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
public void deleteRemoteRoute(@Nullable final Uint64 localDpnId, final Uint64 remoteDpnId, final Uint32 vpnId, final VrfTablesKey vrfTableKey, final VrfEntry vrfEntry, Optional<Routes> extraRouteOptional, @Nullable WriteTransaction tx) {
if (tx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, newTx -> deleteRemoteRoute(localDpnId, remoteDpnId, vpnId, vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(newTx))), LOG, "Error deleting remote route");
return;
}
LOG.debug("deleting remote route: prefix={}, vpnId={} localDpnId {} remoteDpnId {}", vrfEntry.getDestPrefix(), vpnId, localDpnId, remoteDpnId);
String rd = vrfTableKey.getRouteDistinguisher();
if (localDpnId != null && !Uint64.ZERO.equals(localDpnId)) {
// localDpnId is not known when clean up happens for last vm for a vpn on a dpn
if (extraRouteOptional.isPresent()) {
nextHopManager.deleteLoadBalancingNextHop(vpnId, remoteDpnId, vrfEntry.getDestPrefix());
}
makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW, tx, null);
LOG.debug("Successfully delete FIB entry: vrfEntry={}, vpnId={}", vrfEntry.getDestPrefix(), vpnId);
return;
}
// below two reads are kept as is, until best way is found to identify dpnID
VpnNexthop localNextHopInfo = nextHopManager.getVpnNexthop(vpnId, vrfEntry.getDestPrefix());
if (extraRouteOptional.isPresent()) {
nextHopManager.deleteLoadBalancingNextHop(vpnId, remoteDpnId, vrfEntry.getDestPrefix());
} else {
checkDpnDeleteFibEntry(localNextHopInfo, remoteDpnId, vpnId, vrfEntry, rd, tx, null);
}
}
use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.
the class BaseVrfEntryHandler method programRemoteFib.
// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
public void programRemoteFib(final Uint64 remoteDpnId, final Uint32 vpnId, final VrfEntry vrfEntry, WriteTransaction tx, String rd, List<AdjacencyResult> adjacencyResults, @Nullable List<SubTransaction> subTxns) {
if (upgradeState.isUpgradeInProgress()) {
InstanceIdentifier<Interface> absentInterfaceStateIid = getFirstAbsentInterfaceStateIid(adjacencyResults);
if (absentInterfaceStateIid != null) {
LOG.info("programRemoteFib: interface state for {} not yet present, waiting...", absentInterfaceStateIid);
eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, absentInterfaceStateIid, (before, after) -> {
LOG.info("programRemoteFib: waited for and got interface state {}", absentInterfaceStateIid);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, (wtx) -> programRemoteFib(remoteDpnId, vpnId, vrfEntry, TransactionAdapter.toWriteTransaction(wtx), rd, adjacencyResults, null)), LOG, "Failed to program remote FIB {}", absentInterfaceStateIid);
return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
}, Duration.of(15, ChronoUnit.MINUTES), (iid) -> {
LOG.error("programRemoteFib: timed out waiting for {}", absentInterfaceStateIid);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, (wtx) -> programRemoteFib(remoteDpnId, vpnId, vrfEntry, TransactionAdapter.toWriteTransaction(wtx), rd, adjacencyResults, null)), LOG, "Failed to program timed-out remote FIB {}", absentInterfaceStateIid);
});
return;
}
}
List<InstructionInfo> instructions = new ArrayList<>();
for (AdjacencyResult adjacencyResult : adjacencyResults) {
List<ActionInfo> actionInfos = new ArrayList<>();
String egressInterface = adjacencyResult.getInterfaceName();
if (FibUtil.isTunnelInterface(adjacencyResult)) {
addTunnelInterfaceActions(adjacencyResult, vpnId, vrfEntry, actionInfos, rd);
} else {
addRewriteDstMacAction(vpnId, vrfEntry, null, actionInfos);
}
List<ActionInfo> egressActions = nextHopManager.getEgressActionsForInterface(egressInterface, actionInfos.size(), true, vpnId, vrfEntry.getDestPrefix());
if (egressActions.isEmpty()) {
LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}. " + "Aborting remote FIB entry creation.", vrfEntry.getDestPrefix(), new ArrayList<RoutePaths>(vrfEntry.nonnullRoutePaths().values()), egressInterface);
return;
}
actionInfos.addAll(egressActions);
instructions.add(new InstructionApplyActions(actionInfos));
}
makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
}
Aggregations