use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder 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.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder in project netvirt by opendaylight.
the class ElanForwardingEntriesHandler method addElanInterfaceForwardingTableList.
public void addElanInterfaceForwardingTableList(String elanInstanceName, String interfaceName, StaticMacEntries staticMacEntries, WriteTransaction tx) {
MacEntry macEntry = new MacEntryBuilder().setIsStaticAddress(true).setMacAddress(staticMacEntries.getMacAddress()).setIpPrefix(staticMacEntries.getIpPrefix()).setInterface(interfaceName).setKey(new MacEntryKey(staticMacEntries.getMacAddress())).build();
createElanForwardingTablesList(elanInstanceName, macEntry, tx);
createElanInterfaceForwardingTablesList(interfaceName, macEntry, tx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder in project netvirt by opendaylight.
the class ElanForwardingEntriesHandler method createElanInterfaceForwardingTablesList.
public void createElanInterfaceForwardingTablesList(String interfaceName, MacEntry mac, WriteTransaction tx) {
InstanceIdentifier<MacEntry> existingMacEntryId = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, mac.getMacAddress());
MacEntry existingInterfaceMacEntry = elanUtils.getInterfaceMacEntriesOperationalDataPathFromId(existingMacEntryId);
if (existingInterfaceMacEntry == null) {
MacEntry macEntry = new MacEntryBuilder().setMacAddress(mac.getMacAddress()).setIpPrefix(mac.getIpPrefix()).setInterface(interfaceName).setIsStaticAddress(true).setKey(new MacEntryKey(mac.getMacAddress())).build();
tx.put(LogicalDatastoreType.OPERATIONAL, existingMacEntryId, macEntry, WriteTransaction.CREATE_MISSING_PARENTS);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder in project netvirt by opendaylight.
the class ElanForwardingEntriesHandler method updateElanForwardingTablesList.
public void updateElanForwardingTablesList(String elanName, String interfaceName, MacEntry mac, WriteTransaction tx) {
InstanceIdentifier<MacEntry> macEntryId = ElanUtils.getMacEntryOperationalDataPath(elanName, mac.getMacAddress());
MacEntry existingMacEntry = elanUtils.getMacEntryFromElanMacId(macEntryId);
if (existingMacEntry != null && elanUtils.getElanMacTable(elanName) != null) {
MacEntry newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setIsStaticAddress(true).setMacAddress(mac.getMacAddress()).setIpPrefix(mac.getIpPrefix()).setKey(new MacEntryKey(mac.getMacAddress())).build();
tx.put(LogicalDatastoreType.OPERATIONAL, macEntryId, newMacEntry);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder in project netvirt by opendaylight.
the class ElanInterfaceManager method removeInterfaceStaticMacEntries.
protected void removeInterfaceStaticMacEntries(String elanInstanceName, String interfaceName, PhysAddress physAddress) {
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, physAddress);
Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
if (!existingMacEntry.isPresent()) {
return;
}
MacEntry macEntry = new MacEntryBuilder().setMacAddress(physAddress).setInterface(interfaceName).setKey(new MacEntryKey(physAddress)).build();
elanForwardingEntriesHandler.deleteElanInterfaceForwardingEntries(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry);
}
Aggregations