sctp: refactor sctp_packet_append_chunk and clenup some memory leaks
authorNeil Horman <nhorman@tuxdriver.com>
Mon, 2 Jul 2012 09:59:24 +0000 (09:59 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 Jul 2012 06:56:16 +0000 (23:56 -0700)
commited1062772531b6e1029fa4ca62dc8d61f6d53d1c
tree2b1854d347f77cfd71a145b3976ebecc1dabf02c
parent12aba9e7974c5aabf0f4b8e90a5943bfa17fadf4
sctp: refactor sctp_packet_append_chunk and clenup some memory leaks

While doing some recent work on sctp sack bundling I noted that
sctp_packet_append_chunk was pretty inefficient.  Specifially, it was called
recursively while trying to bundle auth and sack chunks.  Because of that we
call sctp_packet_bundle_sack and sctp_packet_bundle_auth a total of 4 times for
every call to sctp_packet_append_chunk, knowing that at least 3 of those calls
will do nothing.

So lets refactor sctp_packet_bundle_auth to have an outer part that does the
attempted bundling, and an inner part that just does the chunk appends.  This
saves us several calls per iteration that we just don't need.

Also, noticed that the auth and sack bundling fail to free the chunks they
allocate if the append fails, so make sure we add that in

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Vlad Yasevich <vyasevich@gmail.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: linux-sctp@vger.kernel.org
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/output.c