Stale flows in ACL tables 216/246
[netvirt.git] / qosservice / impl / src / main / java / org / opendaylight / netvirt / qosservice / QosInterfaceStateChangeListener.java
index 99167461b18ccb62c191c1cdaf68a33aa25f5f1b..e938805ae946cb75fc9c75d4716ba06c6afa584e 100644 (file)
@@ -15,10 +15,11 @@ import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
-import org.opendaylight.genius.srm.RecoverableListener;
-import org.opendaylight.genius.srm.ServiceRecoveryRegistry;
+import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
 import org.opendaylight.netvirt.qosservice.recovery.QosServiceRecoveryHandler;
+import org.opendaylight.serviceutils.srm.RecoverableListener;
+import org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -57,13 +58,13 @@ public class QosInterfaceStateChangeListener extends AsyncClusteredDataTreeChang
         this.neutronVpnManager = neutronVpnManager;
         serviceRecoveryRegistry.addRecoverableListener(qosServiceRecoveryHandler.buildServiceRegistryKey(),
                 this);
-        LOG.debug("{} created",  getClass().getSimpleName());
+        LOG.trace("{} created",  getClass().getSimpleName());
     }
 
     @PostConstruct
     public void init() {
         registerListener();
-        LOG.debug("{} init and registerListener done", getClass().getSimpleName());
+        LOG.trace("{} init and registerListener done", getClass().getSimpleName());
     }
 
     @Override
@@ -84,31 +85,27 @@ public class QosInterfaceStateChangeListener extends AsyncClusteredDataTreeChang
     @Override
     @SuppressWarnings("checkstyle:IllegalCatch")
     protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
-        try {
-            if (L2vlan.class.equals(intrf.getType())) {
-                final String interfaceName = intrf.getName();
-                getNeutronPort(interfaceName).ifPresent(port -> {
-                    Network network = qosNeutronUtils.getNeutronNetwork(port.getNetworkId());
-                    LOG.trace("Qos Service : Received interface {} PORT UP event ", interfaceName);
-                    if (port.augmentation(QosPortExtension.class) != null) {
-                        Uuid portQosUuid = port.augmentation(QosPortExtension.class).getQosPolicyId();
-                        if (portQosUuid != null) {
-                            qosNeutronUtils.addToQosPortsCache(portQosUuid, port);
-                            qosNeutronUtils.handleQosInterfaceAdd(port, portQosUuid);
-                        }
-                    } else {
-                        if (network.augmentation(QosNetworkExtension.class) != null) {
-                            Uuid networkQosUuid = network.augmentation(QosNetworkExtension.class).getQosPolicyId();
-                            if (networkQosUuid != null) {
-                                qosNeutronUtils.handleQosInterfaceAdd(port, networkQosUuid);
-                            }
+        if (L2vlan.class.equals(intrf.getType())) {
+            final String interfaceName = intrf.getName();
+            getNeutronPort(interfaceName).ifPresent(port -> {
+                Network network = qosNeutronUtils.getNeutronNetwork(port.getNetworkId());
+                LOG.debug("Qos Service : Received interface {} PORT UP event ", interfaceName);
+                if (port.augmentation(QosPortExtension.class) != null) {
+                    Uuid portQosUuid = port.augmentation(QosPortExtension.class).getQosPolicyId();
+                    if (portQosUuid != null) {
+                        qosNeutronUtils.addToQosPortsCache(portQosUuid, port);
+                        qosNeutronUtils.handleQosInterfaceAdd(port, portQosUuid);
+                    }
+                } else {
+                    if (network.augmentation(QosNetworkExtension.class) != null) {
+                        Uuid networkQosUuid = network.augmentation(QosNetworkExtension.class).getQosPolicyId();
+                        if (networkQosUuid != null) {
+                            qosNeutronUtils.handleQosInterfaceAdd(port, networkQosUuid);
                         }
                     }
-                    qosAlertManager.processInterfaceUpEvent(interfaceName);
-                });
-            }
-        } catch (Exception e) {
-            LOG.error("Qos:Exception caught in Interface Operational State Up event {}", e);
+                }
+                qosAlertManager.processInterfaceUpEvent(interfaceName);
+            });
         }
     }
 
@@ -127,7 +124,8 @@ public class QosInterfaceStateChangeListener extends AsyncClusteredDataTreeChang
                 return Optional.fromJavaUtil(uuid.toJavaUtil().map(qosNeutronUtils::getNeutronPort));
             }
             LOG.trace("Qos Service : interface {} clearing stale flow entries if any", portName);
-            qosNeutronUtils.removeStaleFlowEntry(intrf);
+            qosNeutronUtils.removeStaleFlowEntry(intrf, NwConstants.ETHTYPE_IPV4);
+            qosNeutronUtils.removeStaleFlowEntry(intrf, NwConstants.ETHTYPE_IPV6);
         }
         return Optional.absent();
     }