Skip to contentSkip to conversation

IPtablestng/KernelSpace - patch tables modules

PATCH In review hamid jafarian 1 participant 1 message Oct 27, 2008

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

PATCH 8/9 IPtablestng/KernelSpace - patch tables modules

change the tables register/unregister methods and other features for compatiblity.

beacause of new structurs for table register/unregister processes, table modules(filter, nat, mangle, row) are changed to work with this new structures. by this modules thay will call "pktt_table_trigger" instead of "ipt_do_table".

net/ipv4/netfilter/iptable_filter.c +14 -43
index 69f3d7e..aa56e89 100644
@@ -8,6 +8,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
+ * Changed On 2008 to work with pkt_tables, Hamid Jafarian (hm.t.) <[email protected]>
  */
 
 #include <linux/module.h>
@@ -23,42 +24,14 @@ MODULE_DESCRIPTION("iptables filter table");
 			    (1 << NF_INET_FORWARD) | \
 			    (1 << NF_INET_LOCAL_OUT))
 
-static struct
-{
-	struct ipt_replace repl;
-	struct ipt_standard entries[3];
-	struct ipt_error term;
-} initial_table __net_initdata = {
-	.repl = {
-		.name = "filter",
-		.valid_hooks = FILTER_VALID_HOOKS,
-		.num_entries = 4,
-		.size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
-		.hook_entry = {
-			[NF_INET_LOCAL_IN] = 0,
-			[NF_INET_FORWARD] = sizeof(struct ipt_standard),
-			[NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2,
-		},
-		.underflow = {
-			[NF_INET_LOCAL_IN] = 0,
-			[NF_INET_FORWARD] = sizeof(struct ipt_standard),
-			[NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2,
-		},
-	},
-	.entries = {
-		IPT_STANDARD_INIT(NF_ACCEPT),	/* LOCAL_IN */
-		IPT_STANDARD_INIT(NF_ACCEPT),	/* FORWARD */
-		IPT_STANDARD_INIT(NF_ACCEPT),	/* LOCAL_OUT */
-	},
-	.term = IPT_ERROR_INIT,			/* ERROR */
-};
-
-static struct xt_table packet_filter = {
+static struct pktt_regtable packet_filter = {
 	.name		= "filter",
 	.valid_hooks	= FILTER_VALID_HOOKS,
-	.lock		= RW_LOCK_UNLOCKED,
-	.me		= THIS_MODULE,
-	.af		= AF_INET,
+	.family		= AF_INET,
+	.owner		= THIS_MODULE,
+	.hooks_policy	= { 	[NF_INET_LOCAL_IN] = cACCEPT,
+				[NF_INET_LOCAL_OUT] = cACCEPT,
+				[NF_INET_FORWARD] = cACCEPT, },
 };
 
 /* The work comes in here from netfilter.c. */
@@ -69,7 +42,7 @@ ipt_hook(unsigned int hook,
 	 const struct net_device *out,
 	 int (*okfn)(struct sk_buff *))
 {
-	return ipt_do_table(skb, hook, in, out, init_net.ipv4.iptable_filter);
+	return pktt_table_trigger(skb, hook, in, out, &packet_filter);
 }
 
 static unsigned int
@@ -88,7 +61,7 @@ ipt_local_out_hook(unsigned int hook,
 		return NF_ACCEPT;
 	}
 
-	return ipt_do_table(skb, hook, in, out, init_net.ipv4.iptable_filter);
+	return pktt_table_trigger(skb, hook, in, out, &packet_filter);
 }
 
 static struct nf_hook_ops ipt_ops[] __read_mostly = {
@@ -122,16 +95,13 @@ module_param(forward, bool, 0000);
 static int __net_init iptable_filter_net_init(struct net *net)
 {
 	/* Register table */
-	net->ipv4.iptable_filter =
-		ipt_register_table(net, &packet_filter, &initial_table.repl);
-	if (IS_ERR(net->ipv4.iptable_filter))
-		return PTR_ERR(net->ipv4.iptable_filter);
-	return 0;
+	int ret = pktt_register_table(net, &packet_filter);
+	return ret;
 }
 
 static void __net_exit iptable_filter_net_exit(struct net *net)
 {
-	ipt_unregister_table(net->ipv4.iptable_filter);
+	pktt_unregister_table(&packet_filter);
 }
 
 static struct pernet_operations iptable_filter_net_ops = {
@@ -149,7 +119,8 @@ static int __init iptable_filter_init(void)
 	}
 
 	/* Entry 1 is the FORWARD hook */
-	initial_table.entries[1].target.verdict = -forward - 1;
+	//initial_table.entries[1].target.verdict = -forward - 1;
+	packet_filter.hooks_policy[NF_INET_FORWARD]= forward? cACCEPT:cDROP;	
 
 	ret = register_pernet_subsys(&iptable_filter_net_ops);
 	if (ret < 0)
net/ipv4/netfilter/iptable_mangle.c +18 -51

103 lines not on this page · raw message

net/ipv4/netfilter/iptable_raw.c +14 -41

89 lines not on this page · raw message

net/ipv4/netfilter/nf_nat_rule.c +16 -44

95 lines not on this page · raw message