PATCH [2/2] ebtables-initial userspace

Jon Anderson <janderson-PLjm5N+tXOMV+D8aMU/[email protected]>
Newsgroups gmane.linux.network.bridge.ebtables.devel
Message-ID <[email protected]>
This isn't exactly as clean as it should be...Here it is though. Applies
to v2.0.6.

jon
ebtables-initial-userspace-v2.patch (text/x-patch, 3.2 KB)
diff -urN ebtables-v2.0.6.orig/ebtables.c ebtables-v2.0.6/ebtables.c
--- ebtables-v2.0.6.orig/ebtables.c	2003-11-02 13:22:56.000000000 -0500
+++ ebtables-v2.0.6/ebtables.c	2005-05-24 12:26:48.490878296 -0400
@@ -62,7 +62,8 @@
 	[NF_BR_FORWARD]"FORWARD",
 	[NF_BR_LOCAL_OUT]"OUTPUT",
 	[NF_BR_POST_ROUTING]"POSTROUTING",
-	[NF_BR_BROUTING]"BROUTING"
+	[NF_BR_BROUTING]"BROUTING",
+	[NF_BR_INITIAL_IN]"INITIAL"
 };
 
 /*
@@ -2063,10 +2064,10 @@
 			if (c == 'i') {
 				check_option(&replace.flags, OPT_IN);
 				if (replace.selected_hook > 2 &&
-				   replace.selected_hook < NF_BR_BROUTING)
+				   replace.selected_hook < NF_BR_INITIAL_IN)
 					print_error("Use in-interface only in "
-					   "INPUT, FORWARD, PREROUTING and"
-					   "BROUTING chains");
+					   "INPUT, FORWARD, PREROUTING,"
+					   "BROUTING and INITIAL chains");
 				if (check_inverse(optarg))
 					new_entry->invflags |= EBT_IIN;
 
@@ -2081,10 +2082,11 @@
 			if (c == 2) {
 				check_option(&replace.flags, OPT_LOGICALIN);
 				if (replace.selected_hook > 2 &&
-				   replace.selected_hook < NF_BR_BROUTING)
+				   replace.selected_hook < NF_BR_INITIAL_IN)
 					print_error("Use logical in-interface "
 					   "only in INPUT, FORWARD, "
-					   "PREROUTING and BROUTING chains");
+					   "PREROUTING, BROUTING, and INITIAL"
+					   " chains");
 				if (check_inverse(optarg))
 					new_entry->invflags |= EBT_ILOGICALIN;
 
diff -urN ebtables-v2.0.6.orig/extensions/Makefile ebtables-v2.0.6/extensions/Makefile
--- ebtables-v2.0.6.orig/extensions/Makefile	2003-11-02 13:22:56.000000000 -0500
+++ ebtables-v2.0.6/extensions/Makefile	2005-05-24 12:28:23.416447416 -0400
@@ -2,7 +2,7 @@
 
 EXT_FUNC+=802_3 nat arp arpreply ip standard log redirect vlan mark_m mark \
           pkttype stp among limit
-EXT_TABLES+=filter nat broute
+EXT_TABLES+=filter nat broute initial
 EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/ebt_$(T).o)
 EXT_OBJS+=$(foreach T,$(EXT_TABLES), extensions/ebtable_$(T).o)
 
diff -urN ebtables-v2.0.6.orig/extensions/ebtable_initial.c ebtables-v2.0.6/extensions/ebtable_initial.c
--- ebtables-v2.0.6.orig/extensions/ebtable_initial.c	1969-12-31 19:00:00.000000000 -0500
+++ ebtables-v2.0.6/extensions/ebtable_initial.c	2005-05-24 12:21:21.640567096 -0400
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include "../include/ebtables_u.h"
+
+
+static void print_help(char **hn)
+{
+	printf("Supported chain for the initial table:\n");
+	printf("%s\n",hn[NF_BR_INITIAL_IN]);
+}
+
+static struct
+ebt_u_table table =
+{
+	.name		= "initial",
+	.help		= print_help,
+};
+
+static void _init(void) __attribute__ ((constructor));
+static void _init(void)
+{
+	register_table(&table);
+}
diff -urN ebtables-v2.0.6.orig/include/linux/netfilter_bridge.h ebtables-v2.0.6/include/linux/netfilter_bridge.h
--- ebtables-v2.0.6.orig/include/linux/netfilter_bridge.h	2003-11-02 13:22:56.000000000 -0500
+++ ebtables-v2.0.6/include/linux/netfilter_bridge.h	2005-05-24 12:12:29.933398872 -0400
@@ -26,7 +26,9 @@
 #define NF_BR_POST_ROUTING	4
 /* Not really a hook, but used for the ebtables broute table */
 #define NF_BR_BROUTING		5
-#define NF_BR_NUMHOOKS		6
+/* Also not really a hook, used for initial filtering. */
+#define NF_BR_INITIAL_IN        6
+#define NF_BR_NUMHOOKS          7
 
 #ifdef __KERNEL__
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.