use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class EvpnMacVrfUtils method addEvpnDmacFlowOnAttach.
public void addEvpnDmacFlowOnAttach(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, ElanInstance elanInstance) {
// String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanInstance == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
String elanName = elanInstance.getElanInstanceName();
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
if (checkEvpnAttachedToNet(elanName)) {
String nexthopIP = getRoutePathNexthopIp(macVrfEntry);
if (nexthopIP == null) {
LOG.debug("nexthopIP is null for iid {}", instanceIdentifier);
return;
}
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = elanInstance.getElanTag();
String dstMacAddress = macVrfEntry.getMac();
long vni = macVrfEntry.getL2vni();
jobCoordinator.enqueueJob(dstMacAddress, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
LOG.info("ADD: Build DMAC flow with dpId {}, nexthopIP {}, elanTag {}," + "vni {}, dstMacAddress {}, elanName {} ", dpId, nexthopIP, elanTag, vni, dstMacAddress, elanName);
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
futures.add(mdsalManager.installFlow(dpId, flow));
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanInterfaceManager method deleteAllRemoteMacsInADpn.
private void deleteAllRemoteMacsInADpn(String elanName, BigInteger dpId, long elanTag) {
List<DpnInterfaces> dpnInterfaces = elanUtils.getInvolvedDpnsInElan(elanName);
for (DpnInterfaces dpnInterface : dpnInterfaces) {
BigInteger currentDpId = dpnInterface.getDpId();
if (!currentDpId.equals(dpId)) {
for (String elanInterface : dpnInterface.getInterfaces()) {
ElanInterfaceMac macs = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (macs == null || macs.getMacEntry() == null) {
continue;
}
for (MacEntry mac : macs.getMacEntry()) {
removeTheMacFlowInTheDPN(dpId, elanTag, currentDpId, mac);
removeEtreeMacFlowInTheDPN(dpId, elanTag, currentDpId, mac);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanInterfaceManager method handleExternalTunnelStateEvent.
/**
* Handle external tunnel state event.
*
* @param externalTunnel
* the external tunnel
* @param intrf
* the interface
* @throws ElanException in case of issues creating the flow objects
*/
public void handleExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) throws ElanException {
if (!validateExternalTunnelStateEvent(externalTunnel, intrf)) {
return;
}
// dpId/externalNodeId will be available either in source or destination
// based on the tunnel end point
BigInteger dpId = null;
NodeId externalNodeId = null;
if (StringUtils.isNumeric(externalTunnel.getSourceDevice())) {
dpId = new BigInteger(externalTunnel.getSourceDevice());
externalNodeId = new NodeId(externalTunnel.getDestinationDevice());
} else if (StringUtils.isNumeric(externalTunnel.getDestinationDevice())) {
dpId = new BigInteger(externalTunnel.getDestinationDevice());
externalNodeId = new NodeId(externalTunnel.getSourceDevice());
}
if (dpId == null || externalNodeId == null) {
LOG.error("Dp ID / externalNodeId not found in external tunnel {}", externalTunnel);
return;
}
ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
if (dpnInterfaceLists == null) {
return;
}
List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
if (elanInfo == null || dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
continue;
}
LOG.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);
elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, dpId);
// install L2gwDevices local macs in dpn.
elanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo, intrf.getName());
// Install dpn macs on external device
installDpnMacsInL2gwDevice(elanName, new HashSet<>(dpnInterfaces.getInterfaces()), dpId, externalNodeId);
}
LOG.info("Handled ExternalTunnelStateEvent for {}", externalTunnel);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanInterfaceManager method programRemoteDmacFlow.
void programRemoteDmacFlow(ElanInstance elanInstance, InterfaceInfo interfaceInfo, WriteTransaction writeFlowGroupTx) throws ElanException {
ElanDpnInterfacesList elanDpnInterfacesList = elanUtils.getElanDpnInterfacesList(elanInstance.getElanInstanceName());
List<DpnInterfaces> dpnInterfaceLists = null;
if (elanDpnInterfacesList != null) {
dpnInterfaceLists = elanDpnInterfacesList.getDpnInterfaces();
}
if (dpnInterfaceLists == null) {
dpnInterfaceLists = new ArrayList<>();
}
for (DpnInterfaces dpnInterfaces : dpnInterfaceLists) {
BigInteger dstDpId = interfaceInfo.getDpId();
if (dpnInterfaces.getDpId().equals(dstDpId)) {
continue;
}
List<String> remoteElanInterfaces = dpnInterfaces.getInterfaces();
for (String remoteIf : remoteElanInterfaces) {
ElanInterfaceMac elanIfMac = elanUtils.getElanInterfaceMacByInterfaceName(remoteIf);
InterfaceInfo remoteInterface = interfaceManager.getInterfaceInfo(remoteIf);
if (elanIfMac == null) {
continue;
}
List<MacEntry> remoteMacEntries = elanIfMac.getMacEntry();
if (remoteMacEntries != null) {
for (MacEntry macEntry : remoteMacEntries) {
String macAddress = macEntry.getMacAddress().getValue();
LOG.info("Programming remote dmac {} on the newly added DPN {} for elan {}", macAddress, dstDpId, elanInstance.getElanInstanceName());
elanUtils.setupRemoteDmacFlow(dstDpId, remoteInterface.getDpId(), remoteInterface.getInterfaceTag(), elanInstance.getElanTag(), macAddress, elanInstance.getElanInstanceName(), writeFlowGroupTx, remoteIf, elanInstance);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanDpnInterfacesListener method remove.
@Override
protected void remove(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
final String elanName = getElanName(identifier);
BigInteger removeDpnId = dpnInterfaces.getDpId();
LOG.debug("ELAN interfaces {} removed from on DPN {} for ELAN {}", dpnInterfaces.getInterfaces(), removeDpnId, elanName);
Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
if (elanServiceChainState.isPresent()) {
List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
Long scfTag = elanToPseudoPortData.getScfTag();
Long elanLportTag = elanToPseudoPortData.getElanLportTag();
if (scfTag != null && elanLportTag != null) {
handleUpdate(removeDpnId, elanName, (short) 0, /* tableId, ignored in removals */
elanLportTag.intValue(), /*21 bit*/
0, /* scfTag, ignored in removals */
NwConstants.DEL_FLOW);
} else {
LOG.debug("One of scfTag or lPortTag is null for ELAN={}: scfTag={} lportTag={}", elanName, scfTag, elanLportTag);
}
}
}
}
Aggregations