Unbind Service not removing the ingress flow entry 60/31760/1
authorFaseela K <faseela.k@ericsson.com>
Tue, 22 Dec 2015 07:48:25 +0000 (13:18 +0530)
committerFaseela K <faseela.k@ericsson.com>
Tue, 22 Dec 2015 07:48:25 +0000 (13:18 +0530)
Change-Id: I8d600c6c85d4f436e2878d0db4488e27a846559e
Signed-off-by: Faseela K <faseela.k@ericsson.com>
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/confighelpers/FlowBasedServicesConfigBindHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/confighelpers/FlowBasedServicesConfigUnbindHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/statehelpers/FlowBasedServicesStateBindHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java

index 0ea2819743f357c6e88ee081fd7cdba51ccb05d1..1b02e87266bbbce07f2a8a2d55a2ea32ffa9ac75 100644 (file)
@@ -47,11 +47,12 @@ public class FlowBasedServicesConfigBindHelper {
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
                 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
         if (ifState == null || ifState.getOperStatus() == OperStatus.Down) {
-            LOG.info("Not Binding Service since for Interface: {}", interfaceName);
+            LOG.warn("Interface not up, not Binding Service for Interface: {}", interfaceName);
             return futures;
         }
 
         // Get the Parent ServiceInfo
+
         ServicesInfo servicesInfo = FlowBasedServicesUtils.getServicesInfoForInterface(interfaceName, dataBroker);
         if (servicesInfo == null) {
             LOG.error("Reached Impossible part 1 in the code during bind service for: {}", boundServiceNew);
@@ -87,7 +88,7 @@ public class FlowBasedServicesConfigBindHelper {
             }
 
             if (matches != null) {
-                FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, vlanId, boundServiceNew,
+                FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, boundServiceNew,
                         dataBroker, t, matches, lportTag.intValue(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
             }
 
@@ -133,7 +134,7 @@ public class FlowBasedServicesConfigBindHelper {
 
             if (matches != null) {
                 FlowBasedServicesUtils.removeIngressFlow(iface, serviceToReplace, dpId, dataBroker, t);
-                FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, vlanId, boundServiceNew, dataBroker, t,
+                FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, boundServiceNew, dataBroker, t,
                         matches, lportTag.intValue(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
             }
         }
index 824169e3af6799eb42cfb5de067da5b1d45780e1..45222b5a0051de5bdefc9cb51d672db1506e1b0b 100644 (file)
@@ -67,7 +67,10 @@ public class FlowBasedServicesConfigUnbindHelper {
         Long lportTag = FlowBasedServicesUtils.getLPortTag(iface, dataBroker);
         int vlanId = 0;
         if (iface.getType().isAssignableFrom(L2vlan.class)) {
-            vlanId = iface.getAugmentation(IfL2vlan.class).getVlanId().getValue();
+            IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
+            if(l2vlan != null) {
+                vlanId = iface.getAugmentation(IfL2vlan.class).getVlanId().getValue();
+            }
         }
         List<BoundServices> boundServices = servicesInfo.getBoundServices();
         if (boundServices.isEmpty()) {
@@ -105,7 +108,7 @@ public class FlowBasedServicesConfigUnbindHelper {
 
         BoundServices toBeMoved = tmpServicesMap.get(highestPriority);
         FlowBasedServicesUtils.removeIngressFlow(iface, boundServiceOld, dpId, dataBroker, t);
-        FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, vlanId, toBeMoved, dataBroker, t,
+        FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, toBeMoved, dataBroker, t,
                 matches, lportTag.intValue(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
         FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, toBeMoved, dataBroker, t);
 
index 0e067c4ea794782eadf04c856c97dfac5826ff26..916fc11a5cf2de797507878a2b760d2ebb9d7e21 100644 (file)
@@ -68,14 +68,17 @@ public class FlowBasedServicesStateBindHelper {
         int vlanId = 0;
         List<MatchInfo> matches = null;
         if (iface.getType().isAssignableFrom(L2vlan.class)) {
-            vlanId = iface.getAugmentation(IfL2vlan.class).getVlanId().getValue();
+            IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
+            if(l2vlan != null) {
+                vlanId = l2vlan.getVlanId().getValue();
+            }
             matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, vlanId);
         } else if (iface.getType().isAssignableFrom(Tunnel.class)){
             matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable (dpId, portNo, iface);
         }
 
         if (matches != null) {
-            FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, vlanId, highestPriorityBoundService,
+            FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, highestPriorityBoundService,
                     dataBroker, t, matches, lportTag.intValue(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
         }
 
index a48f71dbd1671e6b6924a4d435747b9a910d44a1..539fa78cfb71d01e0e751c06727b4c05e7fe8b67 100644 (file)
@@ -14,10 +14,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
-import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
-import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
-import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
-import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
+import org.opendaylight.vpnservice.mdsalutil.*;
 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.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
@@ -116,7 +113,7 @@ public class FlowBasedServicesUtils {
         return 0L;
     }
 
-    public static void installInterfaceIngressFlow(BigInteger dpId, int vlanId,
+    public static void installInterfaceIngressFlow(BigInteger dpId, String interfaceName, int vlanId,
                                                    BoundServices boundServiceNew,
                                                    DataBroker dataBroker, WriteTransaction t,
                                                    List<MatchInfo> matches, int lportTag, short tableId) {
@@ -153,8 +150,9 @@ public class FlowBasedServicesUtils {
         }
 
         String serviceRef = boundServiceNew.getServiceName();
+        String flowRef = getFlowRef(dpId, interfaceName, boundServiceNew);
         StypeOpenflow stypeOpenflow = boundServiceNew.getAugmentation(StypeOpenflow.class);
-        Flow ingressFlow = MDSALUtil.buildFlowNew(tableId, serviceRef,
+        Flow ingressFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
                 stypeOpenflow.getFlowPriority(), serviceRef, 0, 0,
                 stypeOpenflow.getFlowCookie(), matches, instructionSet);
         installFlow(dpId, ingressFlow, dataBroker, t);
@@ -208,7 +206,8 @@ public class FlowBasedServicesUtils {
         }
 
         // build the flow and install it
-        Flow ingressFlow = MDSALUtil.buildFlowNew(stypeOpenFlow.getDispatcherTableId(), serviceRef,
+        String flowRef = getFlowRef(dpId, iface.getName(), boundService);
+        Flow ingressFlow = MDSALUtil.buildFlowNew(stypeOpenFlow.getDispatcherTableId(), flowRef,
                 boundService.getServicePriority(), serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), matches, instructions);
         installFlow(dpId, ingressFlow, dataBroker, t);
     }
@@ -216,8 +215,7 @@ public class FlowBasedServicesUtils {
     public static void removeIngressFlow(Interface iface, BoundServices serviceOld, BigInteger dpId,
                                          DataBroker dataBroker, WriteTransaction t) {
         LOG.debug("Removing Ingress Flows");
-        String flowKeyStr = iface.getName() + serviceOld.getServicePriority() +
-                serviceOld.getServiceName() + IfmConstants.VLAN_INTERFACE_INGRESS_TABLE;
+        String flowKeyStr = getFlowRef(dpId, iface.getName(), serviceOld);
         FlowKey flowKey = new FlowKey(new FlowId(flowKeyStr));
         Node nodeDpn = buildInventoryDpnNode(dpId);
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
@@ -244,12 +242,9 @@ public class FlowBasedServicesUtils {
         t.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
     }
 
-    public static String getInterfaceRefInfo(String dpId, String portName) {
-        String portRefInfo = "";
-        if (!"".equals(dpId)) {
-            portRefInfo = dpId.toString() + ":";
-        }
-        portRefInfo = portRefInfo + portName;
-        return portRefInfo;
+    private static String getFlowRef(BigInteger dpnId, String iface, BoundServices service) {
+        return new StringBuffer().append(dpnId).append(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE).append(NwConstants.FLOWID_SEPARATOR)
+                .append(iface).append(NwConstants.FLOWID_SEPARATOR).append(service.getServiceName()).append(NwConstants.FLOWID_SEPARATOR)
+                .append(service.getServicePriority()).toString();
     }
 }
\ No newline at end of file