Received: with ECARTIS (v1.0.0; list netdev); Fri, 11 Mar 2005 04:58:02 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id j2BCvo92001440 for ; Fri, 11 Mar 2005 04:57:51 -0800 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j2BCvYCj004255; Fri, 11 Mar 2005 07:57:34 -0500 Received: from localhost.localdomain (hmsendeavour.rdu.redhat.com [172.16.57.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j2BCvYn06873; Fri, 11 Mar 2005 07:57:34 -0500 Received: from localhost.localdomain (hmsendeavour [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id j2BCvY0H018460; Fri, 11 Mar 2005 07:57:34 -0500 Received: (from nhorman@localhost) by localhost.localdomain (8.12.8/8.12.8/Submit) id j2BCvOAP018458; Fri, 11 Mar 2005 07:57:24 -0500 Date: Fri, 11 Mar 2005 07:57:24 -0500 From: nhorman@redhat.com To: "David S. Miller" Cc: nhorman@redhat.com, sri@us.ibm.com, netdev@oss.sgi.com, lksctp-developers@lists.sourceforge.net Subject: Re: [Patch] sctp: add receive buffer accounting to sctp (fwd) Message-ID: <20050311125724.GB18122@hmsendeavour.rdu.redhat.com> References: <20050309211632.6f70fe41.davem@davemloft.net> <20050310120803.GA6341@hmsendeavour.rdu.redhat.com> <20050310154342.GG6341@hmsendeavour.rdu.redhat.com> <20050310183856.08cb5f7b.davem@davemloft.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uZ3hkaAS1mZxFaxD" Content-Disposition: inline In-Reply-To: <20050310183856.08cb5f7b.davem@davemloft.net> User-Agent: Mutt/1.4i X-Virus-Scanned: ClamAV 0.83/760/Wed Mar 9 09:12:01 2005 on oss.sgi.com X-Virus-Status: Clean X-archive-position: 2913 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nhorman@redhat.com Precedence: bulk X-list: netdev Content-Length: 2472 Lines: 93 --uZ3hkaAS1mZxFaxD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 10, 2005 at 06:38:56PM -0800, David S. Miller wrote: > On Thu, 10 Mar 2005 10:43:42 -0500 > nhorman@redhat.com wrote: >=20 > > Repost of my ealier rcvbuf patch. No changes, but rediffed to apply cl= eanly to > > the head of the bitkeeper tree. Passes all lksctp regression tests >=20 > Applied, thanks Neil. You're quite welcome. Heres the 2.4 version of the same patch that you requested. Applies clean against the bitkeeper head. Signed-off-by: Neil Horman [nhorman@hmsendeavour kernel]$ diffstat linux-2.4-sctp.rcvbuf.patch=20 input.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+) --- linux-2.4-sctp/net/sctp/input.c.orig 2005-03-10 13:36:49.000000000 -0500 +++ linux-2.4-sctp/net/sctp/input.c 2005-03-10 13:51:25.000000000 -0500 @@ -100,6 +100,21 @@ return 0; } =20 +/* 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 =3D 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,10 @@ rcvr =3D asoc ? &asoc->base : &ep->base; sk =3D rcvr->sk; =20 + if ((sk) && (atomic_read(&sk->sk_rmem_alloc) >=3D sk->sk_rcvbuf))=20 + goto discard_release; +=20 + if (!ipsec_sk_policy(sk, skb)) goto discard_release; =20 @@ -197,6 +216,8 @@ goto discard_release; } =20 + sctp_rcv_set_owner_r(skb,sk); + /* Remember what endpoint is to handle this packet. */ chunk->rcvr =3D rcvr; =20 --=20 /*************************************************** *Neil Horman *Software Engineer *Red Hat, Inc. *nhorman@redhat.com *gpg keyid: 1024D / 0x92A74FA1 *http://pgp.mit.edu ***************************************************/ --uZ3hkaAS1mZxFaxD Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFCMZWzM+bEoZKnT6ERAru2AJ9N1Fle7qQoSZtcSXaXZJ0c9UOFnACghdoe BPoGpQWVuAI/Rimoo6zd/vo= =WO73 -----END PGP SIGNATURE----- --uZ3hkaAS1mZxFaxD--