Patchwork [22/32] netvm: filter emergency skbs.

login
register
mail settings
Submitter Peter Zijlstra
Date Oct. 2, 2008, 1:05 p.m.
Message ID <20081002131609.278132620@chello.nl>
Download mbox | patch
Permalink /patch/2406/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Peter Zijlstra - Oct. 2, 2008, 1:05 p.m.
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 <a.p.zijlstra@chello.nl>
---
 net/core/filter.c |    3 +++
 1 file changed, 3 insertions(+)

Patch

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;