Don't use GFP_KERNEL in netfilter hook (softirq)
According to this email
http://lists.netfilter.org/pipermail/netfilter-devel/2005-December/022720.html
netfilter hooks might be called from softirq context. Therefore, we must
not sleep and must avoid GFP_KERNEL.
Call kmem_cache_alloc() with GFP_NOWAIT instead of GFP_KERNEL. We could
use GFP_ATOMIC but that implies GFP_HIGH which might not be necessary
here because it's acceptable for this call to fail.
We previously saw this error message: "BUG: scheduling while atomic"
Change-Id: I770ba9b82ba3a6f192b92c035383adb4d7c34e8d
diff --git a/auto_bridge/auto_bridge.c b/auto_bridge/auto_bridge.c
index acb8ffd..8f993aa 100644
--- a/auto_bridge/auto_bridge.c
+++ b/auto_bridge/auto_bridge.c
@@ -714,7 +714,8 @@
key_src_mac = abm_l2flow_hash_mac(l2flowtmp->saddr);
key_dst_mac = abm_l2flow_hash_mac(l2flowtmp->daddr);
- l2flow_entry = kmem_cache_alloc(l2flow_cache, GFP_KERNEL); // Can be IRQ CTX ?? Atomic ?
+ /* We must not use GFP_KERNEL because we might be in softirq context. */
+ l2flow_entry = kmem_cache_alloc(l2flow_cache, GFP_NOWAIT);
if(!l2flow_entry){
printk(KERN_ERR "Automatic bridging module error l2flow_cache OOM\n");
goto out;