use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class ElanPacketInHandler method enqueueJobForDPNSpecificTasks.
private void enqueueJobForDPNSpecificTasks(final String macAddress, final Uint32 elanTag, String interfaceName, PhysAddress physAddress, ElanInstance elanInstance, InterfaceInfo interfaceInfo, MacEntry oldMacEntry, MacEntry newMacEntry, boolean isVlanOrFlatProviderIface) {
jobCoordinator.enqueueJob(getElanMacDPNKey(elanTag, macAddress, interfaceInfo.getDpId()), () -> {
macMigrationFlowsCleanup(interfaceName, elanInstance, oldMacEntry, isVlanOrFlatProviderIface);
Uint64 dpId = interfaceManager.getDpnForInterface(interfaceName);
elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, Collections.singletonList(physAddress));
elanManagerCounters.unknownSmacPktinLearned();
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> {
elanUtils.setupMacFlows(elanInstance, interfaceInfo, elanInstance.getMacTimeout().toJava(), macAddress, !isVlanOrFlatProviderIface, tx);
InstanceIdentifier<MacEntry> macEntryId = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
operTx.mergeParentStructurePut(macEntryId, newMacEntry);
}));
}));
return futures;
});
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class ElanPacketInHandler method tryAndRemoveInvalidMacEntry.
/*
* Though this method is a little costlier because it uses try-catch
* construct, it is used only in rare scenarios like MAC movement or invalid
* Static MAC having been added on a wrong ELAN.
*/
private void tryAndRemoveInvalidMacEntry(String elanName, MacEntry macEntry) {
ElanInstance elanInfo = elanInstanceCache.get(elanName).orElse(null);
if (elanInfo == null) {
LOG.warn("MAC {} is been added (either statically or dynamically) for an invalid Elan {}. " + "Manual cleanup may be necessary", macEntry.getMacAddress(), elanName);
return;
}
InterfaceInfo oldInterfaceLport = interfaceManager.getInterfaceInfo(macEntry.getInterface());
if (oldInterfaceLport == null) {
LOG.warn("MAC {} is been added (either statically or dynamically) on an invalid Logical Port {}. " + "Manual cleanup may be necessary", macEntry.getMacAddress(), macEntry.getInterface());
return;
}
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> elanUtils.deleteMacFlows(elanInfo, oldInterfaceLport, macEntry, tx)), LOG, "Error deleting invalid MAC entry");
elanL2GatewayUtils.removeMacsFromElanExternalDevices(elanInfo, Collections.singletonList(macEntry.getMacAddress()));
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION 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));
Uint32 elanTag = elanInstance.getElanTag();
String dstMacAddress = macVrfEntry.getMac();
long vni = macVrfEntry.getL2vni().toJava();
jobCoordinator.enqueueJob(dstMacAddress, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> dpnInterfaceLists.forEach(dpnInterfaces -> {
Uint64 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.longValue()).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
mdsalManager.addFlow(tx, dpId, flow);
}))), ElanConstants.JOB_MAX_RETRIES);
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class ElanServiceProvider method addArpResponderFlow.
@Override
public void addArpResponderFlow(ArpResponderInput arpResponderInput) {
String ingressInterfaceName = arpResponderInput.getInterfaceName();
String macAddress = arpResponderInput.getSha();
String ipAddress = arpResponderInput.getSpa();
int lportTag = arpResponderInput.getLportTag();
Uint64 dpnId = Uint64.valueOf(arpResponderInput.getDpId());
LOG.info("Installing the ARP responder flow on DPN {} for Interface {} with MAC {} & IP {}", dpnId, ingressInterfaceName, macAddress, ipAddress);
Optional<ElanInterface> elanIface = elanInterfaceCache.get(ingressInterfaceName);
ElanInstance elanInstance = elanIface.isPresent() ? elanInstanceCache.get(elanIface.get().getElanInstanceName()).orElse(null) : null;
if (elanInstance == null) {
LOG.debug("addArpResponderFlow: elanInstance is null, Failed to install arp responder flow for dpnId {}" + "for Interface {} with MAC {} & IP {}", dpnId, ingressInterfaceName, macAddress, ipAddress);
return;
}
String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
Map<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> arpResponderInputInstructionsMap = new HashMap<>();
int instructionKey = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instructionObj : arpResponderInput.getInstructions()) {
arpResponderInputInstructionsMap.put(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey(++instructionKey), instructionObj);
}
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ARP_RESPONDER_TABLE, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY, flowId, 0, 0, ArpResponderUtil.generateCookie(lportTag, ipAddress), ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress), arpResponderInputInstructionsMap);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> mdsalManager.addFlow(tx, dpnId, flowEntity)), LOG, "Error adding flow {}", flowEntity);
LOG.info("Installed the ARP Responder flow for Interface {}", ingressInterfaceName);
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class L2GatewayListener method update.
@Override
public void update(InstanceIdentifier<L2gateway> identifier, L2gateway original, L2gateway update) {
LOG.info("Updating L2gateway : key: {}, original value={}, update value={}", identifier, original, update);
List<L2gatewayConnection> connections = l2gwService.getAssociatedL2GwConnections(Sets.newHashSet(update.getUuid()));
if (connections == null) {
LOG.warn("There are no connections associated with l2 gateway uuid {} name {}", update.getUuid(), update.getName());
return;
}
if (original.getDevices() == null) {
connections.forEach((connection) -> l2gwService.addL2GatewayConnection(connection));
return;
}
elanClusterUtils.runOnlyInOwnerNode("l2gw.update", () -> {
DeviceInterfaces updatedDeviceInterfaces = new DeviceInterfaces(update);
FluentFuture<?> fts = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
original.getDevices().values().stream().filter((originalDevice) -> originalDevice.getInterfaces() != null).forEach((originalDevice) -> {
String deviceName = originalDevice.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(deviceName);
NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(new NodeId(l2GwDevice.getHwvtepNodeId()), deviceName);
originalDevice.getInterfaces().values().stream().filter((intf) -> !updatedDeviceInterfaces.containsInterface(deviceName, intf.getInterfaceName())).forEach((intf) -> {
connections.forEach((connection) -> {
Integer vlanId = connection.getSegmentId();
if (intf.getSegmentationIds() != null && !intf.getSegmentationIds().isEmpty()) {
for (Integer vlan : intf.getSegmentationIds()) {
HwvtepUtils.deleteVlanBinding(tx, physicalSwitchNodeId, intf.getInterfaceName(), vlan);
}
} else {
LOG.info("Deleting vlan binding {} {} {}", physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
HwvtepUtils.deleteVlanBinding(tx, physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
}
});
});
});
});
fts.addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object success) {
LOG.info("Successfully deleted vlan bindings for l2gw update {}", update);
connections.forEach((l2GwConnection) -> l2gwService.addL2GatewayConnection(l2GwConnection, null, update));
}
@Override
public void onFailure(Throwable throwable) {
LOG.error("Failed to delete vlan bindings as part of l2gw udpate {}", update);
}
}, MoreExecutors.directExecutor());
});
}
Aggregations