All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] netfilter: allow hooks to pass error code back up the stack
@ 2010-11-16 21:52 ` Eric Paris
  0 siblings, 0 replies; 15+ messages in thread
From: Eric Paris @ 2010-11-16 21:52 UTC (permalink / raw)
  To: netdev, linux-kernel, selinux, netfilter-devel
  Cc: eparis, equinox, eric.dumazet, davem, hzhong, jmorris, kaber,
	kuznet, paul.moore, pekkas, sds, yoshfuji

SELinux would like to pass certain fatal errors back up the stack.  This patch
implements the generic netfilter support for this functionality.

Based-on-patch-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Eric Paris <eparis@redhat.com>
---

 include/linux/netfilter.h |    2 ++
 net/netfilter/core.c      |    6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 03317c8..1893837 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -33,6 +33,8 @@
 
 #define NF_QUEUE_NR(x) ((((x) << NF_VERDICT_BITS) & NF_VERDICT_QMASK) | NF_QUEUE)
 
+#define NF_DROP_ERR(x) (((-x) << NF_VERDICT_BITS) | NF_DROP)
+
 /* only for userspace compatibility */
 #ifndef __KERNEL__
 /* Generic cache responses from hook functions.
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 85dabb8..32fcbe2 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -173,9 +173,11 @@ next_hook:
 			     outdev, &elem, okfn, hook_thresh);
 	if (verdict == NF_ACCEPT || verdict == NF_STOP) {
 		ret = 1;
-	} else if (verdict == NF_DROP) {
+	} else if ((verdict & NF_VERDICT_MASK) == NF_DROP) {
 		kfree_skb(skb);
-		ret = -EPERM;
+		ret = -(verdict >> NF_VERDICT_BITS);
+		if (ret == 0)
+			ret = -EPERM;
 	} else if ((verdict & NF_VERDICT_MASK) == NF_QUEUE) {
 		if (!nf_queue(skb, elem, pf, hook, indev, outdev, okfn,
 			      verdict >> NF_VERDICT_BITS))

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-11-19 15:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-16 21:52 [PATCH 1/3] netfilter: allow hooks to pass error code back up the stack Eric Paris
2010-11-16 21:52 ` Eric Paris
2010-11-16 21:52 ` [PATCH 2/3] network: tcp_connect should return certain errors " Eric Paris
2010-11-16 21:52   ` Eric Paris
2010-11-17 18:56   ` David Miller
2010-11-16 21:52 ` [PATCH 3/3] SELinux: return -ECONNREFUSED from ip_postroute to signal fatal error Eric Paris
2010-11-16 21:52   ` Eric Paris
2010-11-17 11:43   ` Patrick McHardy
2010-11-17 14:38     ` Eric Paris
2010-11-17 14:38       ` Eric Paris
2010-11-17 18:55       ` David Miller
2010-11-17 18:56   ` David Miller
2010-11-19 15:11   ` Paul Moore
2010-11-19 15:11     ` Paul Moore
2010-11-17 18:55 ` [PATCH 1/3] netfilter: allow hooks to pass error code back up the stack David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.