diff options
author | Denys Fedorysychenko <nuclearcat@nuclearcat.com> | 2010-07-09 23:48:06 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-10-13 11:24:25 (GMT) |
commit | 86b6f6f6291eaaec542a2f4028087fa823122082 (patch) | |
tree | de16523380275b43c31fb1ad642f4f0eac732981 /lib | |
parent | 018c297274348acba1e123a3e84471c75a215efb (diff) | |
download | libnl-86b6f6f6291eaaec542a2f4028087fa823122082.zip libnl-86b6f6f6291eaaec542a2f4028087fa823122082.tar.gz libnl-86b6f6f6291eaaec542a2f4028087fa823122082.tar.bz2 |
Trivial fix for TBF memleak
Without this patch, running alloc / free cache loop will lead to huge memory
leaks on machine with 3000 interfaces with tbf qdiscs.
Here was valgrind output:
==5580== 18,070,728 bytes in 347,514 blocks are definitely lost in loss record
32 of 32
==5580== at 0x4025485: calloc (in /lib/valgrind/vgpreload_memcheck-x86-
linux.so)
==5580== by 0x405F410: tbf_msg_parser (tbf.c:46)
==5580== by 0x405302B: qdisc_msg_parser (qdisc.c:119)
==5580== by 0x4033DC9: nl_cache_parse (cache.c:643)
==5580== by 0x4033E7C: update_msg_parser (cache.c:460)
==5580== by 0x4038A11: nl_recvmsgs (netlink-local.h:112)
==5580== by 0x4034175: __cache_pickup (cache.c:483)
==5580== by 0x40343FF: nl_cache_pickup (cache.c:516)
==5580== by 0x403447D: nl_cache_refill (cache.c:698)
==5580== by 0x4034AB7: nl_cache_alloc_and_fill (cache.c:198)
==5580== by 0x4053216: rtnl_qdisc_alloc_cache (qdisc.c:388)
==5580== by 0x80489DB: main (in /home/root/nltest)
Patch complied and tested for same test case, no more leaks anymore.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/route/sch/tbf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/route/sch/tbf.c b/lib/route/sch/tbf.c index 29453e3..eccaf70 100644 --- a/lib/route/sch/tbf.c +++ b/lib/route/sch/tbf.c @@ -93,6 +93,11 @@ static int tbf_msg_parser(struct rtnl_qdisc *q) return 0; } +static void tbf_free_data(struct rtnl_qdisc *qdisc) +{ + free(qdisc->q_subdata); +} + static void tbf_dump_line(struct rtnl_qdisc *qdisc, struct nl_dump_params *p) { double r, rbit, lim; @@ -517,6 +522,7 @@ static struct rtnl_qdisc_ops tbf_qdisc_ops = { [NL_DUMP_LINE] = tbf_dump_line, [NL_DUMP_DETAILS] = tbf_dump_details, }, + .qo_free_data = tbf_free_data, .qo_get_opts = tbf_get_opts, }; |