use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project netvirt by opendaylight.
the class ElanInterfaceManager method addElanInterface.
List<ListenableFuture<Void>> addElanInterface(ElanInterface elanInterface, InterfaceInfo interfaceInfo, ElanInstance elanInstance) throws ElanException {
Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
Preconditions.checkNotNull(elanInterface, "elanInterface cannot be null");
String interfaceName = elanInterface.getName();
String elanInstanceName = elanInterface.getElanInstanceName();
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
WriteTransaction tx = broker.newWriteOnlyTransaction();
if (elanInfo == null) {
List<String> elanInterfaces = new ArrayList<>();
elanInterfaces.add(interfaceName);
ElanUtils.updateOperationalDataStore(idManager, elanInstance, elanInterfaces, tx);
} else {
createElanStateList(elanInstanceName, interfaceName, tx);
}
boolean isFirstInterfaceInDpn = false;
// Specific actions to the DPN where the ElanInterface has been added,
// for example, programming the
// External tunnel table if needed or adding the ElanInterface to the
// DpnInterfaces in the operational DS.
BigInteger dpId = interfaceInfo.getDpId();
DpnInterfaces dpnInterfaces = null;
if (dpId != null && !dpId.equals(ElanConstants.INVALID_DPN)) {
InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
if (!existingElanDpnInterfaces.isPresent()) {
isFirstInterfaceInDpn = true;
// ELAN's 1st ElanInterface added to this DPN
dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
// table, but only if Elan has VNI
if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
setExternalTunnelTable(dpId, elanInstance);
}
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
} else {
List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
elanInterfaces.add(interfaceName);
if (elanInterfaces.size() == 1) {
// 1st dpn interface
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
}
dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, dpId, elanInterfaces, tx);
}
}
// add code to install Local/Remote BC group, unknow DMAC entry,
// terminating service table flow entry
// call bindservice of interfacemanager to create ingress table flow
// enty.
// Add interface to the ElanInterfaceForwardingEntires Container
createElanInterfaceTablesList(interfaceName, tx);
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(ElanUtils.waitForTransactionToComplete(tx));
installEntriesForFirstInterfaceonDpn(elanInstance, interfaceInfo, dpnInterfaces, isFirstInterfaceInDpn);
// for internal vlan networks
if (ElanUtils.isVlan(elanInstance) && !elanInstance.isExternal()) {
if (interfaceManager.isExternalInterface(interfaceName)) {
LOG.debug("adding vlan prv intf {} to elan {} BC group", interfaceName, elanInstanceName);
handleExternalInterfaceEvent(elanInstance, dpnInterfaces, dpId);
}
}
if (isFirstInterfaceInDpn && isVxlanNetworkOrVxlanSegment(elanInstance)) {
// update the remote-DPNs remoteBC group entry with Tunnels
LOG.trace("update remote bc group for elan {} on other DPNs for newly added dpn {}", elanInstance, dpId);
setElanAndEtreeBCGrouponOtherDpns(elanInstance, dpId);
}
String jobKey = ElanUtils.getElanInterfaceJobKey(interfaceName);
InterfaceAddWorkerOnElanInterface addWorker = new InterfaceAddWorkerOnElanInterface(jobKey, elanInterface, interfaceInfo, elanInstance, isFirstInterfaceInDpn, this);
jobCoordinator.enqueueJob(jobKey, addWorker, ElanConstants.JOB_MAX_RETRIES);
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project netvirt by opendaylight.
the class ElanNodeListener method createL2ControlProtocolDropFlows.
private void createL2ControlProtocolDropFlows(BigInteger dpId) {
List<MatchInfo> mkMatches = new ArrayList<>();
MatchEthernetDestination matchEthDst = new MatchEthernetDestination(new MacAddress(ElanConstants.L2_CONTROL_PACKETS_DMAC), new MacAddress(ElanConstants.L2_CONTROL_PACKETS_DMAC_MASK));
mkMatches.add(matchEthDst);
List<ActionInfo> listActionInfo = new ArrayList<>();
listActionInfo.add(new ActionDrop());
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionApplyActions(listActionInfo));
String flowId = dpId.toString() + NwConstants.ELAN_DMAC_TABLE + "l2control" + ElanConstants.L2_CONTROL_PACKETS_DMAC + ElanConstants.L2_CONTROL_PACKETS_DMAC_MASK;
FlowEntity flow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_DMAC_TABLE, flowId, 15, "L2 control packets dMac Table Flow", 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC, mkMatches, mkInstructions);
mdsalManager.installFlow(flow);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project netvirt by opendaylight.
the class ElanNodeListener method addSmacLearnedTableFlow.
private void addSmacLearnedTableFlow(BigInteger dpId) {
// T50 - match on Reg4 and goto T51
List<MatchInfoBase> mkMatches = new ArrayList<>();
mkMatches.add(new NxMatchRegister(NxmNxReg4.class, LEARN_MATCH_REG4_VALUE));
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionGotoTable(NwConstants.ELAN_DMAC_TABLE));
String flowRef = new StringBuffer().append(NwConstants.ELAN_SMAC_TABLE).append(NwConstants.FLOWID_SEPARATOR).append(LEARN_MATCH_REG4_VALUE).toString();
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_SMAC_TABLE, flowRef, 10, "ELAN sMac Table Reg4 Flow", 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(BigInteger.valueOf(LEARN_MATCH_REG4_VALUE)), mkMatches, mkInstructions);
mdsalManager.installFlow(flowEntity);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project netvirt by opendaylight.
the class EvpnUtils method programEvpnL2vniDemuxTable.
public void programEvpnL2vniDemuxTable(String elanName, final BiConsumer<String, String> serviceHandler, BiConsumer<BigInteger, FlowEntity> flowHandler) {
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
List<String> tunnelInterfaceNameList = getDcGatewayTunnelInterfaceNameList();
if (tunnelInterfaceNameList.isEmpty()) {
LOG.info("No DC gateways tunnels while programming l2vni table for elan {}.", elanName);
return;
}
tunnelInterfaceNameList.forEach(tunnelInterfaceName -> {
serviceHandler.accept(elanName, tunnelInterfaceName);
});
programEvpnL2vniFlow(elanInfo, flowHandler);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project netvirt by opendaylight.
the class ElanInterfaceManager method removeElanInterface.
public List<ListenableFuture<Void>> removeElanInterface(ElanInstance elanInfo, String interfaceName, InterfaceInfo interfaceInfo) {
String elanName = elanInfo.getElanInstanceName();
boolean isLastElanInterface = false;
boolean isLastInterfaceOnDpn = false;
BigInteger dpId = null;
long elanTag = elanInfo.getElanTag();
// We use two transaction so we don't suffer on multiple shards (interfaces and flows)
WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
if (elanState == null) {
interfaceTx.cancel();
return Collections.emptyList();
}
WriteTransaction flowTx = broker.newWriteOnlyTransaction();
List<String> elanInterfaces = elanState.getElanInterfaces();
if (elanInterfaces.isEmpty()) {
isLastElanInterface = true;
}
if (interfaceInfo != null) {
dpId = interfaceInfo.getDpId();
DpnInterfaces dpnInterfaces = removeElanDpnInterfaceFromOperationalDataStore(elanName, dpId, interfaceName, elanTag, interfaceTx);
/*
* If there are not elan ports, remove the unknown dmac, terminating
* service table flows, remote/local bc group
*/
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
// No more Elan Interfaces in this DPN
LOG.debug("deleting the elan: {} present on dpId: {}", elanInfo.getElanInstanceName(), dpId);
if (!elanUtils.isOpenstackVniSemanticsEnforced()) {
removeDefaultTermFlow(dpId, elanInfo.getElanTag());
}
removeUnknownDmacFlow(dpId, elanInfo, flowTx, elanInfo.getElanTag());
removeEtreeUnknownDmacFlow(dpId, elanInfo, flowTx);
removeElanBroadcastGroup(elanInfo, interfaceInfo, flowTx);
removeLocalBroadcastGroup(elanInfo, interfaceInfo, flowTx);
removeEtreeBroadcastGrups(elanInfo, interfaceInfo, flowTx);
if (isVxlanNetworkOrVxlanSegment(elanInfo)) {
if (elanUtils.isOpenstackVniSemanticsEnforced()) {
elanUtils.removeTerminatingServiceAction(dpId, elanUtils.getVxlanSegmentationId(elanInfo).intValue());
}
unsetExternalTunnelTable(dpId, elanInfo);
}
isLastInterfaceOnDpn = true;
} else {
setupLocalBroadcastGroups(elanInfo, dpnInterfaces, interfaceInfo);
}
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(ElanUtils.waitForTransactionToComplete(interfaceTx));
futures.add(ElanUtils.waitForTransactionToComplete(flowTx));
if (isLastInterfaceOnDpn && dpId != null && isVxlanNetworkOrVxlanSegment(elanInfo)) {
setElanAndEtreeBCGrouponOtherDpns(elanInfo, dpId);
}
InterfaceRemoveWorkerOnElanInterface removeInterfaceWorker = new InterfaceRemoveWorkerOnElanInterface(interfaceName, elanInfo, interfaceInfo, this, isLastElanInterface);
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), removeInterfaceWorker, ElanConstants.JOB_MAX_RETRIES);
return futures;
}
Aggregations