aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/outqueue.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2018-10-16 15:07:50 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-18 14:23:47 -0400
commit605c0ac182c34867bda71bfbcc74958aabbe2fe0 (patch)
tree3faf0884fe9eb3899629b3c7adb895e1c695503e /net/sctp/outqueue.c
parent2d0f0ca2c7b56c1df29429dd5a768fc49e79ffae (diff)
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>
Diffstat (limited to 'net/sctp/outqueue.c')
-rw-r--r--net/sctp/outqueue.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 42191ed9902b..9cb854b05342 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -385,9 +385,7 @@ static int sctp_prsctp_prune_sent(struct sctp_association *asoc,
385 asoc->outqueue.outstanding_bytes -= sctp_data_size(chk); 385 asoc->outqueue.outstanding_bytes -= sctp_data_size(chk);
386 } 386 }
387 387
388 msg_len -= SCTP_DATA_SNDSIZE(chk) + 388 msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
389 sizeof(struct sk_buff) +
390 sizeof(struct sctp_chunk);
391 if (msg_len <= 0) 389 if (msg_len <= 0)
392 break; 390 break;
393 } 391 }
@@ -421,9 +419,7 @@ static int sctp_prsctp_prune_unsent(struct sctp_association *asoc,
421 streamout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++; 419 streamout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
422 } 420 }
423 421
424 msg_len -= SCTP_DATA_SNDSIZE(chk) + 422 msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
425 sizeof(struct sk_buff) +
426 sizeof(struct sctp_chunk);
427 sctp_chunk_free(chk); 423 sctp_chunk_free(chk);
428 if (msg_len <= 0) 424 if (msg_len <= 0)
429 break; 425 break;