sctp: count both sk and asoc sndbuf with skb truesize and sctp_chunk size
authorXin Long <lucien.xin@gmail.com>
Tue, 16 Oct 2018 19:07:50 +0000 (03:07 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Oct 2018 18:23:47 +0000 (11:23 -0700)
commit605c0ac182c34867bda71bfbcc74958aabbe2fe0
tree3faf0884fe9eb3899629b3c7adb895e1c695503e
parent2d0f0ca2c7b56c1df29429dd5a768fc49e79ffae
sctp: count both sk and asoc sndbuf with skb truesize and sctp_chunk size

Now it's confusing that asoc sndbuf_used is doing memory accounting with
SCTP_DATA_SNDSIZE(chunk) + sizeof(sk_buff) + sizeof(sctp_chunk) while sk
sk_wmem_alloc is doing that with skb->truesize + sizeof(sctp_chunk).

It also causes sctp_prsctp_prune to count with a wrong freed memory when
sndbuf_policy is not set.

To make this right and also keep consistent between asoc sndbuf_used, sk
sk_wmem_alloc and sk_wmem_queued, use skb->truesize + sizeof(sctp_chunk)
for them.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sctp/constants.h
net/sctp/outqueue.c
net/sctp/socket.c