From patchwork Thu Oct 2 13:05:26 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 2406 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 422DADDFB4 for ; Thu, 2 Oct 2008 23:21:20 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754608AbYJBNUs (ORCPT ); Thu, 2 Oct 2008 09:20:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754882AbYJBNUr (ORCPT ); Thu, 2 Oct 2008 09:20:47 -0400 Received: from casper.infradead.org ([85.118.1.10]:54767 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754116AbYJBNSs (ORCPT ); Thu, 2 Oct 2008 09:18:48 -0400 Received: from d9244.upc-d.chello.nl ([213.46.9.244] helo=twins) by casper.infradead.org with esmtpsa (Exim 4.69 #1 (Red Hat Linux)) id 1KlO4e-0000Eo-4c; Thu, 02 Oct 2008 13:18:32 +0000 Received: by twins (Postfix, from userid 0) id 6F9BD181EBCB6; Thu, 2 Oct 2008 15:18:30 +0200 (CEST) Message-Id: <20081002131609.278132620@chello.nl> References: <20081002130504.927878499@chello.nl> User-Agent: quilt/0.46-1 Date: Thu, 02 Oct 2008 15:05:26 +0200 From: Peter Zijlstra To: Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, trond.myklebust@fys.uio.no, Daniel Lezcano , Pekka Enberg , Peter Zijlstra , Neil Brown , David Miller Subject: [PATCH 22/32] netvm: filter emergency skbs. Content-Disposition: inline; filename=netvm-sk_filter.patch X-Bad-Reply: References but no 'Re:' in Subject. Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Toss all emergency packets not for a SOCK_MEMALLOC socket. This ensures our precious memory reserve doesn't get stuck waiting for user-space. The correctness of this approach relies on the fact that networks must be assumed lossy. Signed-off-by: Peter Zijlstra --- net/core/filter.c | 3 +++ 1 file changed, 3 insertions(+) Index: linux-2.6/net/core/filter.c =================================================================== --- linux-2.6.orig/net/core/filter.c +++ linux-2.6/net/core/filter.c @@ -81,6 +81,9 @@ int sk_filter(struct sock *sk, struct sk int err; struct sk_filter *filter; + if (skb_emergency(skb) && !sk_has_memalloc(sk)) + return -ENOMEM; + err = security_sock_rcv_skb(sk, skb); if (err) return err;