public void deleteElanInterfaceForwardingEntries(ElanInstance elanInfo, InterfaceInfo interfaceInfo, MacEntry macEntry) {
InstanceIdentifier<MacEntry> macEntryId = ElanUtils.getMacEntryOperationalDataPath(elanInfo.getElanInstanceName(), macEntry.getMacAddress());
ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, macEntryId);
+ deleteElanInterfaceForwardingTablesList(interfaceInfo.getInterfaceName(), macEntry);
ElanUtils.deleteMacFlows(elanInfo, interfaceInfo, macEntry);
}
InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
Optional<ElanInterfaceMac> existingElanInterface = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanInterfaceId);
if(existingElanInterface.isPresent()) {
- List<MacEntry> macEntries = existingElanInterface.get().getMacEntry();
+ List<MacEntry> macEntries = new ArrayList<>(existingElanInterface.get().getMacEntry());
if(macEntries != null && !macEntries.isEmpty()) {
for (MacEntry macEntry : macEntries) {
logger.debug("removing the mac-entry:{} present on elanInterface:{}", macEntry.getMacAddress().getValue(), interfaceName);
*/
package org.opendaylight.vpnservice.elan.internal;
+import java.math.BigInteger;
+
+import org.opendaylight.controller.liblldp.NetUtils;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.elan.utils.ElanConstants;
import org.opendaylight.vpnservice.elan.utils.ElanUtils;
-//import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
import org.opendaylight.vpnservice.mdsalutil.NWUtil;
-import org.opendaylight.controller.liblldp.NetUtils;
import org.opendaylight.vpnservice.mdsalutil.packet.Ethernet;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
+import com.google.common.base.Optional;
+@SuppressWarnings("deprecation")
public class ElanPacketInHandler implements PacketProcessingListener {
private final DataBroker broker;
long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
- IfIndexInterface interfaceInfo = ElanUtils.getInterfaceInfoByInterfaceTag(portTag);
- if (interfaceInfo == null) {
+ Optional<IfIndexInterface> interfaceInfoOp = ElanUtils.getInterfaceInfoByInterfaceTag(portTag);
+ if (!interfaceInfoOp.isPresent()) {
logger.warn("There is no interface for given portTag {}", portTag);
return;
}
- String interfaceName = interfaceInfo.getInterfaceName();
+ String interfaceName = interfaceInfoOp.get().getInterfaceName();
ElanTagName elanTagName = ElanUtils.getElanInfoByElanTag(elanTag);
String elanName = elanTagName.getName();
Elan elanInfo = ElanUtils.getElanByName(elanName);
*/
package org.opendaylight.vpnservice.elan.internal;
+import java.math.BigInteger;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.elan.utils.ElanConstants;
import org.opendaylight.vpnservice.elan.utils.ElanUtils;
import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
-import org.opendaylight.vpnservice.itm.api.IITMProvider;
import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.LivenessState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.tag.name.map.ElanTagName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.forwarding.entries.MacEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterface;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331._if.indexes._interface.map.IfIndexInterface;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-
-
-import java.math.BigInteger;
+@SuppressWarnings("deprecation")
public class ElanSmacFlowEventListener implements SalFlowListener {
private final DataBroker broker;
- private IMdsalApiManager mdsalManager;
private IInterfaceManager interfaceManager;
private static final Logger logger = LoggerFactory.getLogger(ElanSmacFlowEventListener.class);
public void setMdSalApiManager(IMdsalApiManager mdsalManager) {
- this.mdsalManager = mdsalManager;
}
@Override
public void onFlowAdded(FlowAdded arg0) {
if (elanTagInfo == null) {
return;
}
- String srcMacAddress = switchFlowRemoved.getMatch().getEthernetMatch()
+ final String srcMacAddress = switchFlowRemoved.getMatch().getEthernetMatch()
.getEthernetSource().getAddress().getValue().toUpperCase();
int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
if (portTag == 0) {
logger.debug(String.format("Flow removed event on SMAC flow entry. But having port Tag as 0 "));
return;
}
- IfIndexInterface existingInterfaceInfo = ElanUtils.getInterfaceInfoByInterfaceTag(portTag);
- String interfaceName = existingInterfaceInfo.getInterfaceName();
+ Optional<IfIndexInterface> existingInterfaceInfo = ElanUtils.getInterfaceInfoByInterfaceTag(portTag);
+ if (!existingInterfaceInfo.isPresent()) {
+ logger.debug("Interface is not available for port Tag {}", portTag);
+ return;
+ }
+ String interfaceName = existingInterfaceInfo.get().getInterfaceName();
PhysAddress physAddress = new PhysAddress(srcMacAddress);
if (interfaceName == null) {
logger.error(String.format("LPort record not found for tag %d", portTag));
Futures.addCallback(writeResult, new FutureCallback<Void>() {
@Override
public void onSuccess(Void noarg) {
- logger.debug("Successfully removed macEntries from Operational Datastore");
+ logger.debug("Successfully removed macEntry {} from Operational Datastore", srcMacAddress);
}
@Override
public void onFailure(Throwable error) {
- logger.debug("Error while removing macEntries from Operational Datastore", error);
+ logger.debug("Error {} while removing macEntry {} from Operational Datastore", error, srcMacAddress);
}
});
}
}
// interface-index-tag operational container
- public static IfIndexInterface getInterfaceInfoByInterfaceTag(long interfaceTag) {
+ public static Optional<IfIndexInterface> getInterfaceInfoByInterfaceTag(long interfaceTag) {
DataBroker broker = elanServiceProvider.getBroker();
InstanceIdentifier<IfIndexInterface> interfaceId = getInterfaceInfoEntriesOperationalDataPath(interfaceTag);
- Optional<IfIndexInterface> existingInterfaceInfo = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, interfaceId);
- if(existingInterfaceInfo.isPresent()) {
- return existingInterfaceInfo.get();
- }
- return null;
+ return ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, interfaceId);
}
public static InstanceIdentifier<IfIndexInterface> getInterfaceInfoEntriesOperationalDataPath(long interfaceTag) {
public static void deleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, boolean deleteSmac) {
String elanInstanceName = elanInfo.getElanInstanceName();
- String ifName = interfaceInfo.getInterfaceName();
long ifTag = interfaceInfo.getInterfaceTag();
List<DpnInterfaces> remoteFEs = getInvolvedDpnsInElan(elanInstanceName);
IMdsalApiManager mdsalApiManager = elanServiceProvider.getMdsalManager();
ItmRpcService itmRpcService = elanServiceProvider.getItmRpcService();
BigInteger srcdpId = interfaceInfo.getDpId();
- String displayName = elanInstanceName;
- long groupId = interfaceInfo.getGroupId();
for (DpnInterfaces dpnInterface: remoteFEs) {
Long elanTag = elanInfo.getElanTag();
- if (dpnInterface.getDpId().equals(srcdpId)) {
+ BigInteger dstDpId = dpnInterface.getDpId();
+ if (dstDpId.equals(srcdpId)) {
if(deleteSmac) {
- mdsalApiManager.removeFlow(getKnownSmacFlowEntity(elanInfo, interfaceInfo, 0, macAddress));
+ mdsalApiManager.removeFlow(srcdpId, MDSALUtil.buildFlow(ElanConstants.ELAN_SMAC_TABLE,
+ getKnownDynamicmacFlowRef(ElanConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
}
- mdsalApiManager.removeFlow(dpnInterface.getDpId(), getLocalDmacFlowEntry(elanTag, dpnInterface.getDpId(), ifName, macAddress, displayName, ifTag));
- RemoveTerminatingServiceActionsInput removeTerminatingServiceActionsInput = new RemoveTerminatingServiceActionsInputBuilder().setServiceId(interfaceInfo.getInterfaceTag()).setDpnId(dpnInterface.getDpId()).build();
+ mdsalApiManager.removeFlow(srcdpId, MDSALUtil.buildFlow(ElanConstants.ELAN_DMAC_TABLE,
+ getKnownDynamicmacFlowRef(ElanConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+ RemoveTerminatingServiceActionsInput removeTerminatingServiceActionsInput = new RemoveTerminatingServiceActionsInputBuilder().setServiceId(interfaceInfo.getInterfaceTag()).setDpnId(srcdpId).build();
itmRpcService.removeTerminatingServiceActions(removeTerminatingServiceActionsInput);
if (logger.isDebugEnabled()) {
- logger.debug("All the required flows deleted for elan:{}, logical Interface port:{} and mac address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, dpnInterface.getDpId());
+ logger.debug("All the required flows deleted for elan:{}, logical Interface port:{} and mac address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
- } else if (isDpnPresent(dpnInterface.getDpId())) {
- mdsalApiManager.removeFlow(dpnInterface.getDpId(),
- getRemoteDmacFlowEntry(dpnInterface.getDpId(), srcdpId, interfaceInfo.getInterfaceTag(), elanTag, macAddress,
- displayName));
+ } else if (isDpnPresent(dstDpId)) {
+ mdsalApiManager.removeFlow(dstDpId, MDSALUtil.buildFlow(ElanConstants.ELAN_DMAC_TABLE,
+ getKnownDynamicmacFlowRef(ElanConstants.ELAN_DMAC_TABLE, srcdpId, dstDpId, macAddress, elanTag)));
if (logger.isDebugEnabled()) {
- logger.debug("Dmac flow entry deleted for elan:{}, logical interface port:{} and mac address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, dpnInterface.getDpId());
+ logger.debug("Dmac flow entry deleted for elan:{}, logical interface port:{} and mac address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, dstDpId);
}
}
}
.setCookie(new FlowCookie(cookie)).build();
}
+ public static Flow buildFlow(short tableId, String flowId) {
+ return new FlowBuilder().setTableId(tableId).setId(new FlowId(flowId)).build();
+ }
+
public static Flow buildFlowNew(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo, List<Instruction> listInstructionInfo) {
return MDSALUtil.buildFlowNew(tableId, flowId, priority, flowName, idleTimeOut, hardTimeOut, cookie,