atish bhowmick(deleted)
|
io-pkt pfil hook memory leak
|
atish bhowmick(deleted)
11/19/2014 1:26 AM
post112370
|
io-pkt pfil hook memory leak
I have written a packet filter shared library using the pfil interface which I am mounting inside io-pkt-v4-hc : mount -
T io-pkt /home/libPacketfilter.so
I have a outbound_hook which registers to the pfil interface and blocks any traffic on outbound port 80 to stop any http
traffic . I am testing this with a script which repeatedly does http traffic by using the command : curl www.google.com
. I see if my filter keeps on blocking the http traffic by returning value 1 back to io-pkt asking it to drop the
packet , io-pkt memory constantly keeps on increasing ( heap memory information shown on the Momentics IDE) .
If however packets are allowed , there is no memory leak . I am using the devn-pcnet.so driver to launch io-pkt-v4-hc on
a Qnx 6.6 x86 Vm .
Here is how my outgoing hook looks like :
struct pfil_head *pfh_inet = NULL;
pfh_inet = pfil_head_get(PFIL_TYPE_AF, AF_INET);
pfil_add_hook(output_hook, NULL, PFIL_OUT | PFIL_WAITOK,pfh_inet);
static int output_hook(void *arg, struct mbuf **m,
struct ifnet *ifp, int dir)
{
int block = 0; // don't block by default
in_bytes += (*m)->m_len;
struct mbuf* packet_buf = (*m);
if(parse_mbuf(packet_buf,&outbound))
{
if(outbound.portremote == 80)
block = 1;
}
return block; // 0 means allow, 1 means block
}
I see that if i keep on blocking any tcp traffic such at http , io-pkt heap memory constantly rises .
If after processing the packet filter hook returns back 0 to io-pkt to allow the packet , no memory leak occurs.
Is there any memory clean up required when I return back any non zero value from the pfil hook to io-pkt since I am
asking io-pkt to drop the packet . Any help would be helpful .
|
|
|