From: Tinku Mannan Date: Fri, 8 Nov 2013 18:24:49 +0000 (-0500) Subject: SDOCM00090624:Delete Classifer API will try and delete the same ad hoc IP rule if... X-Git-Tag: DEV.NETAPI.01.00.00.10~5 X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Fnetapi.git;a=commitdiff_plain;h=6fb869e8054de42940ec139713b3bcb8465f29b6 SDOCM00090624:Delete Classifer API will try and delete the same ad hoc IP rule if it is used in multiple classifiers --- diff --git a/ti/runtime/netapi/src/netcp_cfg.c b/ti/runtime/netapi/src/netcp_cfg.c index 1e8c0ea..2b778c4 100755 --- a/ti/runtime/netapi/src/netcp_cfg.c +++ b/ti/runtime/netapi/src/netcp_cfg.c @@ -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,