From: Abhinav Gupta Date: Thu, 25 Jun 2015 13:04:01 +0000 (+0530) Subject: Fix for Bug 3428 - table0 tunnel entry not deleted X-Git-Tag: release/beryllium~111 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=3e8d84165e187dd885ff3bf1339e3d64b3d36d72;hp=52c17b5579cf896ed425604ee744190fc710540e;p=vpnservice.git Fix for Bug 3428 - table0 tunnel entry not deleted Change-Id: I14cf648026a1a66e1e7014e7c97511d395a76dec Signed-off-by: Abhinav Gupta --- diff --git a/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/InterfaceChangeListener.java b/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/InterfaceChangeListener.java index 7e054145..b1ace260 100644 --- a/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/InterfaceChangeListener.java +++ b/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/InterfaceChangeListener.java @@ -1,12 +1,15 @@ package org.opendaylight.vpnservice; +import java.math.BigInteger; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager; +import org.opendaylight.vpnservice.mdsalutil.NwConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.L3tunnel; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface; @@ -19,6 +22,7 @@ public class InterfaceChangeListener extends AbstractDataChangeListener listenerRegistration; private final DataBroker broker; private VpnInterfaceManager vpnInterfaceManager; + private IInterfaceManager interfaceManager; public InterfaceChangeListener(final DataBroker db, VpnInterfaceManager vpnInterfaceManager) { @@ -28,6 +32,10 @@ public class InterfaceChangeListener extends AbstractDataChangeListener identifier, Interface intrf) { LOG.trace("Remove interface event - key: {}, value: {}", identifier, intrf ); + if (intrf.getType().equals(L3tunnel.class)) { + BigInteger dpnId = interfaceManager.getDpnForInterface(intrf); + String ifName = intrf.getName(); + LOG.debug("Removing tunnel interface associated with Interface {}", intrf.getName()); + vpnInterfaceManager.makeTunnelIngressFlow(dpnId, ifName, NwConstants.DEL_FLOW); + } + else { VpnInterface vpnInterface = vpnInterfaceManager.getVpnInterface(intrf.getName()); - InstanceIdentifier id = VpnUtil.getVpnInterfaceIdentifier(intrf.getName()); - LOG.debug("Removing VPN Interface associated with Interface {}", intrf.getName()); - vpnInterfaceManager.remove(id, vpnInterface); + if (vpnInterface !=null) { + InstanceIdentifier id = VpnUtil.getVpnInterfaceIdentifier(intrf.getName()); + LOG.debug("Removing VPN Interface associated with Interface {}", intrf.getName()); + vpnInterfaceManager.remove(id, vpnInterface); + } + else { + LOG.debug("No VPN Interface associated with Interface {}", intrf.getName()); + } + } } @Override diff --git a/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java b/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java index 02d77ad4..3585a6f1 100644 --- a/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java +++ b/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java @@ -564,7 +564,7 @@ public class VpnInterfaceManager extends AbstractDataChangeListener