Commit 208b7d48 authored by Neil Horman's avatar Neil Horman Committed by David S. Miller

[SCTP]: Add receive buffer accounting.

Signed-off-by: default avatarNeil Horman <nhorman@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 981428f3
......@@ -100,6 +100,21 @@ static inline int sctp_rcv_checksum(struct sk_buff *skb)
return 0;
}
/* The free routine for skbuffs that sctp receives */
static void sctp_rfree(struct sk_buff *skb)
{
atomic_sub(sizeof(struct sctp_chunk),&skb->sk->sk_rmem_alloc);
sock_rfree(skb);
}
/* The ownership wrapper routine to do receive buffer accounting */
static void sctp_rcv_set_owner_r(struct sk_buff *skb, struct sock *sk)
{
skb_set_owner_r(skb,sk);
skb->destructor = sctp_rfree;
atomic_add(sizeof(struct sctp_chunk),&sk->sk_rmem_alloc);
}
/*
* This is the routine which IP calls when receiving an SCTP packet.
*/
......@@ -183,6 +198,11 @@ int sctp_rcv(struct sk_buff *skb)
rcvr = asoc ? &asoc->base : &ep->base;
sk = rcvr->sk;
if ((sk) && (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)) {
goto discard_release;
}
/* SCTP seems to always need a timestamp right now (FIXME) */
if (skb->stamp.tv_sec == 0) {
do_gettimeofday(&skb->stamp);
......@@ -203,6 +223,8 @@ int sctp_rcv(struct sk_buff *skb)
goto discard_release;
}
sctp_rcv_set_owner_r(skb,sk);
/* Remember what endpoint is to handle this packet. */
chunk->rcvr = rcvr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment