All of lore.kernel.org
 help / color / mirror / Atom feed
* Memory leak with dev_add_pack()
@ 2011-01-21 20:54 Spiro Trikaliotis
  2011-01-22  7:18 ` Michael Blizek
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Spiro Trikaliotis @ 2011-01-21 20:54 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I have been tasked with writing a kernel module to handle an own
protocol (with an own EtherType) in the Linux kernel.

While I am not a complete newbie in the Linux kernel, having to handle
Ethernet traffic there is new to me.

I have looked at several tutorials and also at sample code (for example
http://www.phrack.org/archives/55/p55_0x0c_Building%20Into%20The%20Linux%20Network%20Layer_by_lifeline%20&%20kossak.txt,
and some tutorials I cannot find at the moment...) and tried to cut it
down to the bare essentials.

I came up with the following code utilising Linux Protocol Module:

   http://www.trikaliotis.net/testmodule/test_kernel.c

   the correspondig Makefile is in
   http://www.trikaliotis.net/testmodule/Makefile

Note: This is a cut-down version of the actual code which shows the
problem. Additionally, I register for ETH_P_ALL so the problem occurs as
fast as possible.

While it essentially works as I want it to, I found that I am leaking
memory this way. Having this module in a highly loaded network, 
"head -n5 /proc/meminfo" shows that MemFree is steadily falling, until
the kernel OOPS with an out of memory condition.

"Of course", if I undefine DO_MEMLEAK, the memory leak does not occur
anymore.

I tried for almost two weeks now to look at different tutorials, and I
also looked in working code (for example, the IP LPM) and tried to
compare with my code, but I could not find out what I am doing wrong
here. I am sure it must be something obvious, and very silly -
unfortunaely, for me, it is not obvious at the moment.

Can anyone help me here, please?

Best regards,
Spiro.

-- 
Spiro R. Trikaliotis                              http://opencbm.sf.net/
http://www.trikaliotis.net/                     http://www.viceteam.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-01-25  3:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21 20:54 Memory leak with dev_add_pack() Spiro Trikaliotis
2011-01-22  7:18 ` Michael Blizek
2011-01-23 10:40   ` Spiro Trikaliotis
2011-01-23 12:49     ` Michael Blizek
2011-01-23 15:52       ` anish kumar
2011-01-23 16:20         ` Michael Blizek
2011-01-23 17:29           ` anish kumar
2011-01-24 16:08             ` Michael Blizek
2011-01-25  3:12               ` anish singh
     [not found] ` <F272513BE9F24B28A764C7CA5982EDA4@your6c359a3bdc>
2011-01-23 10:45   ` Spiro Trikaliotis
2011-01-23 13:03 ` Daniel Baluta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.