Skip to contentSkip to conversation

secmark: Add xtables SECMARK target

PATCH Applied [email protected] 2 participants 2 messages Jun 9, 2006

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 6/9 secmark: Add xtables SECMARK target

From: James Morris <[email protected]>

Add a SECMARK target to xtables, allowing the admin to apply security marks to packets via both iptables and ip6tables.

The target currently handles SELinux security marking, but can be extended for other purposes as needed.

---

 include/linux/netfilter/xt_SECMARK.h |   26 ++++
 net/netfilter/Kconfig                |    9 +
 net/netfilter/Makefile               |    1 
 net/netfilter/xt_SECMARK.c           |  156 +++++++++++++++++++++++++
 4 files changed, 192 insertions(+)
include/linux/netfilter/xt_SECMARK.h new file +26 -0
diff -puN /dev/null include/linux/netfilter/xt_SECMARK.h
@@ -0,0 +1,26 @@
+#ifndef _XT_SECMARK_H_target
+#define _XT_SECMARK_H_target
+
+/*
+ * This is intended for use by various security subsystems (but not
+ * at the same time).
+ *
+ * 'mode' refers to the specific security subsystem which the
+ * packets are being marked for.
+ */
+#define SECMARK_MODE_SEL	0x01		/* SELinux */
+#define SECMARK_SELCTX_MAX	256
+
+struct xt_secmark_target_selinux_info {
+	u_int32_t selsid;
+	char selctx[SECMARK_SELCTX_MAX];
+};
+
+struct xt_secmark_target_info {
+	u_int8_t mode;
+	union {
+		struct xt_secmark_target_selinux_info sel;
+	} u;
+};
+
+#endif /*_XT_SECMARK_H_target */
net/netfilter/Kconfig renamed from net/netfilter/Kconfig~secmark-add-xtables-secmark-target +9 -0
diff -puN net/netfilter/Kconfig~secmark-add-xtables-secmark-target net/netfilter/Kconfig
@@ -174,6 +174,15 @@ config NETFILTER_XT_TARGET_NOTRACK
 	  If you want to compile it as a module, say M here and read
 	  <file:Documentation/modules.txt>.  If unsure, say `N'.
 
+config NETFILTER_XT_TARGET_SECMARK
+	tristate '"SECMARK" target support'
+	depends on NETFILTER_XTABLES && NETWORK_SECMARK
+	help
+	  The SECMARK target allows security marking of network
+	  packets, for use with security subsystems.
+
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 config NETFILTER_XT_MATCH_COMMENT
 	tristate  '"comment" match support'
 	depends on NETFILTER_XTABLES
net/netfilter/Makefile renamed from net/netfilter/Makefile~secmark-add-xtables-secmark-target +1 -0
diff -puN net/netfilter/Makefile~secmark-add-xtables-secmark-target net/netfilter/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMAR
 obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o
+obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o
 
 # matches
 obj-$(CONFIG_NETFILTER_XT_MATCH_COMMENT) += xt_comment.o
net/netfilter/xt_SECMARK.c new file +156 -0

156 lines not on this page · raw message

_