Skip to contentSkip to conversation

C99 patches for net/bridge/netfilter

PATCH In review Art Haas 3 participants 3 messages Feb 27, 2003 – Mar 3, 2003

Subsystems (3)
lore
Share & tools
lore

Art Haas

author
#0 lore raw

PATCH 1/1 C99 patches for net/bridge/netfilter

Hi.

Here are three patches for converting files in net/bridget/netfilter to use C99 initializers. The patches at first were just going to be adding an '=' to array initializers, but then I decided to add named initializers to the structures as I thought it would make them easier to read.

Art Haas

===== net/bridge/netfilter/ebtable_filter.c 1.1 vs edited =====

net/bridge/netfilter/ebtable_filter.c +44 -14
@@ -16,16 +16,31 @@
 
 static struct ebt_entries initial_chains[] =
 {
-  {0, "INPUT", 0, EBT_ACCEPT, 0},
-  {0, "FORWARD", 0, EBT_ACCEPT, 0},
-  {0, "OUTPUT", 0, EBT_ACCEPT, 0}
+	{
+		.name	= "INPUT",
+		.policy	= EBT_ACCEPT,
+	},
+	{
+		.name	= "FORWARD",
+		.policy	= EBT_ACCEPT,
+	},
+	{
+		.name	= "OUTPUT",
+		.policy	= EBT_ACCEPT,
+	}
 };
 
 static struct ebt_replace initial_table =
 {
-  "filter", FILTER_VALID_HOOKS, 0, 3 * sizeof(struct ebt_entries),
-  { [NF_BR_LOCAL_IN]&initial_chains[0], [NF_BR_FORWARD]&initial_chains[1],
-    [NF_BR_LOCAL_OUT]&initial_chains[2] }, 0, NULL, (char *)initial_chains
+	.name		= "filter",
+	.valid_hooks	= FILTER_VALID_HOOKS,
+	.entries_size	= 3 * sizeof(struct ebt_entries),
+  	.hook_entry	= {
+		[NF_BR_LOCAL_IN]	= &initial_chains[0],
+		[NF_BR_FORWARD]		= &initial_chains[1],
+    		[NF_BR_LOCAL_OUT]	= &initial_chains[2],
+	},
+	.entries	= (char *)initial_chains
 };
 
 static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
@@ -37,8 +52,11 @@
 
 static struct ebt_table frame_filter =
 { 
-  {NULL, NULL}, "filter", &initial_table, FILTER_VALID_HOOKS, 
-  RW_LOCK_UNLOCKED, check, NULL
+	.name		= "filter",
+	.table		= &initial_table,
+	.valid_hooks	= FILTER_VALID_HOOKS, 
+	.lock		= RW_LOCK_UNLOCKED,
+	.check		= check,
 };
 
 static unsigned int
@@ -49,12 +67,24 @@
 }
 
 static struct nf_hook_ops ebt_ops_filter[] = {
-	{ { NULL, NULL }, ebt_hook, PF_BRIDGE, NF_BR_LOCAL_IN,
-	   NF_BR_PRI_FILTER_BRIDGED},
-	{ { NULL, NULL }, ebt_hook, PF_BRIDGE, NF_BR_FORWARD,
-	   NF_BR_PRI_FILTER_BRIDGED},
-	{ { NULL, NULL }, ebt_hook, PF_BRIDGE, NF_BR_LOCAL_OUT,
-	   NF_BR_PRI_FILTER_OTHER}
+	{
+		.hook		= ebt_hook,
+		.pf		= PF_BRIDGE,
+		.hooknum	= NF_BR_LOCAL_IN,
+		.priority	= NF_BR_PRI_FILTER_BRIDGED,
+	},
+	{
+		.hook		= ebt_hook,
+		.pf		= PF_BRIDGE,
+		.hooknum	= NF_BR_FORWARD,
+		.priority	= NF_BR_PRI_FILTER_BRIDGED
+	},
+	{
+		.hook		= ebt_hook,
+		.pf		= PF_BRIDGE,
+		.hooknum	= NF_BR_LOCAL_OUT,
+		.priority	= NF_BR_PRI_FILTER_OTHER
+	}
 };
 
 static int __init init(void)

===== net/bridge/netfilter/ebtable_nat.c 1.1 vs edited =====

net/bridge/netfilter/ebtable_nat.c +44 -14

80 lines not on this page · raw message

===== net/bridge/netfilter/ebtable_broute.c 1.1 vs edited =====

net/bridge/netfilter/ebtable_broute.c +16 -6
@@ -18,13 +18,20 @@
 
 // EBT_ACCEPT means the frame will be bridged
 // EBT_DROP means the frame will be routed
-static struct ebt_entries initial_chain =
-  {0, "BROUTING", 0, EBT_ACCEPT, 0};
+static struct ebt_entries initial_chain = {
+	.name	= "BROUTING",
+	.policy	= EBT_ACCEPT,
+};
 
 static struct ebt_replace initial_table =
 {
-  "broute", 1 << NF_BR_BROUTING, 0, sizeof(struct ebt_entries),
-  { [NF_BR_BROUTING]&initial_chain}, 0, NULL, (char *)&initial_chain
+	.name		= "broute",
+	.valid_hooks	= 1 << NF_BR_BROUTING,
+	.entries_size	= sizeof(struct ebt_entries),
+	.hook_entry	= {
+		[NF_BR_BROUTING]	= &initial_chain,
+	},
+	.entries	= (char *)&initial_chain
 };
 
 static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
@@ -36,8 +43,11 @@
 
 static struct ebt_table broute_table =
 {
-  {NULL, NULL}, "broute", &initial_table, 1 << NF_BR_BROUTING,
-  RW_LOCK_UNLOCKED, check, NULL
+	.name		= "broute",
+	.table		= &initial_table,
+	.valid_hooks	= 1 << NF_BR_BROUTING,
+	.lock		= RW_LOCK_UNLOCKED,
+	.check		= check,
 };
 
 static int ebt_broute(struct sk_buff **pskb)
Signature · 3 lines
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
#1 lore raw
Quoted 5 lines

Here are three patches for converting files in net/bridget/netfilter to use C99 initializers. The patches at first were just going to be adding an '=' to array initializers, but then I decided to add named initializers to the structures as I thought it would make them easier to read.

Thanks, I'll send it through to Dave later. In the future, please send ebtables patches to [email protected] or me.

Signature · 2 lines
cheers,
Bart
#2 lore raw
In reply to Art Haas

From: Art Haas <[email protected]>
Date: Thu, 27 Feb 2003 11:25:25 -0600

Here are three patches for converting files in net/bridget/netfilter to use C99 initializers. The patches at first were just going to be adding an '=' to array initializers, but then I decided to add named initializers to the structures as I thought it would make them easier to read.

Thanks Art, patch applied.