use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project netvirt by opendaylight.
the class ElanInterfaceManager method installDpnMacsInL2gwDevice.
/**
* Installs dpn macs in external device. first it checks if the physical
* locator towards this dpn tep is present or not if the physical locator is
* present go ahead and add the ucast macs otherwise update the mcast mac
* entry to include this dpn tep ip and schedule the job to put ucast macs
* once the physical locator is programmed in device
*
* @param elanName
* the elan name
* @param lstElanInterfaceNames
* the lst Elan interface names
* @param dpnId
* the dpn id
* @param externalNodeId
* the external node id
*/
private void installDpnMacsInL2gwDevice(String elanName, Set<String> lstElanInterfaceNames, BigInteger dpnId, NodeId externalNodeId) {
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, externalNodeId.getValue());
if (elanL2GwDevice == null) {
LOG.debug("L2 gw device not found in elan cache for device name {}", externalNodeId);
return;
}
IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, externalNodeId);
if (dpnTepIp == null) {
LOG.warn("Could not install dpn macs in l2gw device , dpnTepIp not found dpn : {} , nodeid : {}", dpnId, externalNodeId);
return;
}
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
RemoteMcastMacs remoteMcastMac = elanL2GatewayUtils.readRemoteMcastMac(externalNodeId, logicalSwitchName, LogicalDatastoreType.OPERATIONAL);
boolean phyLocAlreadyExists = ElanL2GatewayUtils.checkIfPhyLocatorAlreadyExistsInRemoteMcastEntry(externalNodeId, remoteMcastMac, dpnTepIp);
LOG.debug("phyLocAlreadyExists = {} for locator [{}] in remote mcast entry for elan [{}], nodeId [{}]", phyLocAlreadyExists, String.valueOf(dpnTepIp.getValue()), elanName, externalNodeId.getValue());
List<PhysAddress> staticMacs = elanL2GatewayUtils.getElanDpnMacsFromInterfaces(lstElanInterfaceNames);
if (phyLocAlreadyExists) {
elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
return;
}
elanL2GatewayMulticastUtils.scheduleMcastMacUpdateJob(elanName, elanL2GwDevice);
elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project netvirt by opendaylight.
the class ElanPacketInHandler method onPacketReceived.
@Override
public void onPacketReceived(PacketReceived notification) {
Class<? extends PacketInReason> pktInReason = notification.getPacketInReason();
short tableId = notification.getTableId().getValue();
if (pktInReason == NoMatch.class && tableId == NwConstants.ELAN_SMAC_TABLE) {
ElanManagerCounters.unknown_smac_pktin_rcv.inc();
try {
byte[] data = notification.getPayload();
Ethernet res = new Ethernet();
res.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
byte[] srcMac = res.getSourceMACAddress();
final String macAddress = NWUtil.toStringMacAddress(srcMac);
final BigInteger metadata = notification.getMatch().getMetadata().getMetadata();
final long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
Optional<IfIndexInterface> interfaceInfoOp = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
if (!interfaceInfoOp.isPresent()) {
LOG.warn("There is no interface for given portTag {}", portTag);
return;
}
String interfaceName = interfaceInfoOp.get().getInterfaceName();
LOG.debug("Received a packet with srcMac: {} ElanTag: {} PortTag: {} InterfaceName: {}", macAddress, elanTag, portTag, interfaceName);
ElanTagName elanTagName = elanUtils.getElanInfoByElanTag(elanTag);
if (elanTagName == null) {
LOG.warn("not able to find elanTagName in elan-tag-name-map for elan tag {}", elanTag);
return;
}
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName);
if (elanInterfaceMac == null) {
LOG.info("There is no ElanInterfaceForwardingEntryDS created for interface :{}", interfaceName);
return;
}
String elanName = elanTagName.getName();
PhysAddress physAddress = new PhysAddress(macAddress);
MacEntry oldMacEntry = elanUtils.getMacEntryForElanInstance(elanName, physAddress).orNull();
boolean isVlanOrFlatProviderIface = interfaceManager.isExternalInterface(interfaceName);
Optional<IpAddress> srcIpAddress = elanUtils.getSourceIpAddress(res);
MacEntry newMacEntry = null;
BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
if (!srcIpAddress.isPresent()) {
newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
} else {
newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setIpPrefix(srcIpAddress.get()).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
}
if (srcIpAddress.isPresent()) {
String prefix = srcIpAddress.get().getIpv4Address().getValue();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
evpnUtils.advertisePrefix(elanInstance, macAddress, prefix, interfaceName, interfaceInfo.getDpId());
}
enqueueJobForMacSpecificTasks(macAddress, elanTag, interfaceName, elanName, physAddress, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
if (interfaceInfo == null) {
LOG.trace("Interface:{} is not present under Config DS", interfaceName);
return;
}
enqueueJobForDPNSpecificTasks(macAddress, elanTag, interfaceName, physAddress, elanInstance, interfaceInfo, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
} catch (PacketException e) {
LOG.error("Failed to decode packet: {}", notification, e);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project netvirt by opendaylight.
the class EvpnMacVrfUtils method addEvpnDmacFlow.
public void addEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanName == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
if (checkEvpnAttachedToNet(elanName)) {
// TODO(Riyaz) : Check if accessing first nexthop address is right solution
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
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.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project netvirt by opendaylight.
the class EvpnMacVrfUtils method removeEvpnDmacFlowOnDetach.
public void removeEvpnDmacFlowOnDetach(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, ElanInstance elanInstance) {
// String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanInstance == null) {
LOG.error("Error : elanInstance is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
// 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 macToRemove = macVrfEntry.getMac();
jobCoordinator.enqueueJob(macToRemove, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setDstMacAddress(macToRemove);
LOG.info("REMOVE: Deleting DMAC Flows for external MAC. elanTag {}, dpId {}," + "nexthopIP {}, macToRemove {}", elanTag, dpId, nexthopIP, macToRemove);
elanEvpnFlowUtils.evpnDeleteDmacFlowsToExternalMac(dmacFlowBuilder.build());
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project netvirt by opendaylight.
the class EvpnMacVrfUtils method removeEvpnDmacFlow.
public void removeEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanName == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
// if (checkEvpnAttachedToNet(elanName)) {
// TODO(Riyaz) : Check if accessing first nexthop address is right
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
String macToRemove = macVrfEntry.getMac();
jobCoordinator.enqueueJob(macToRemove, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setDstMacAddress(macToRemove);
LOG.info("REMOVE: Deleting DMAC Flows for external MAC. elanTag {}, dpId {}," + "nexthopIP {}, macToRemove {}", elanTag, dpId, nexthopIP, macToRemove);
futures.addAll(elanEvpnFlowUtils.evpnDeleteDmacFlowsToExternalMac(dmacFlowBuilder.build()));
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
Aggregations