SDOCM00090624:Delete Classifer API will try and delete the same ad hoc IP rule if...
authorTinku Mannan <tmannan@ti.com>
Fri, 8 Nov 2013 18:24:49 +0000 (13:24 -0500)
committerTinku Mannan <tmannan@ti.com>
Fri, 8 Nov 2013 18:24:49 +0000 (13:24 -0500)
ti/runtime/netapi/src/netcp_cfg.c

index 1e8c0ea8214154536a2d8f985ee075d6cb23bf95..2b778c4a7dd407150d2dc5146a54bc8eb21daa96 100755 (executable)
@@ -1152,6 +1152,34 @@ NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                  h,
                                          err,
                                          1);
 }
+/***************************************************************************
+* DESCRIPTION:Netapi internal function to check reference count of IP
+***************************************************************************/
+static Bool netapip_netcpCfgCheckIpRefCount(NETAPI_HANDLE_T *p_handle,
+                                            NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                            int ip_slot)
+{
+
+    if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
+    {
+             p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
+            /* IS IP is associated with alteast 2 rules, if yes, then dont delete IP */
+            if(p->ips[ip_slot].ref_count)
+                p->ips[ip_slot].ref_count--;
+            if (p->ips[ip_slot].ref_count)
+            {
+                 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+                return FALSE;
+            }
+            else
+            {
+                p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+                return TRUE;
+            }
+    }
+    else
+        return FALSE;
+}
 
 /********************************************************************
  * FUNCTION PURPOSE:  NETAPI internal function to detach IP from MAC interface
@@ -1192,6 +1220,15 @@ static void netapip_netcpCfgDelIpInternal(NETAPI_T h,
     }
     *err =0;
 
+    /* need to check to see if this IP is attached to a classifier(s)
+       and only delete if this is last classifier */
+    if (!netapip_netcpCfgCheckIpRefCount(n,
+                                         &netapi_get_global()->nwal_context,
+                                         ip_slot))
+    {
+        return;
+    }
+
     //get a transaction id
     pTransInfo = netapip_getFreeTransInfo(n,
                                           (NETAPI_PROC_GLOBAL_T *) n->proc_global,