patch-2.4.22 linux-2.4.22/net/ipv6/netfilter/ip6_tables.c
Next file: linux-2.4.22/net/ipv6/netfilter/ip6t_LOG.c
Previous file: linux-2.4.22/net/ipv6/ndisc.c
Back to the patch index
Back to the overall index
- Lines: 134
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/net/ipv6/netfilter/ip6_tables.c
- Orig date:
2002-11-28 15:53:15.000000000 -0800
diff -urN linux-2.4.21/net/ipv6/netfilter/ip6_tables.c linux-2.4.22/net/ipv6/netfilter/ip6_tables.c
@@ -101,10 +101,8 @@
unsigned int hook_entry[NF_IP6_NUMHOOKS];
unsigned int underflow[NF_IP6_NUMHOOKS];
- char padding[SMP_ALIGN((NF_IP6_NUMHOOKS*2+2)*sizeof(unsigned int))];
-
/* ip6t_entry tables: one per CPU */
- char entries[0];
+ char entries[0] ____cacheline_aligned;
};
static LIST_HEAD(ip6t_target);
@@ -1450,7 +1448,7 @@
int ret;
struct ip6t_table_info *newinfo;
static struct ip6t_table_info bootstrap
- = { 0, 0, 0, { 0 }, { 0 }, { }, { } };
+ = { 0, 0, 0, { 0 }, { 0 }, { } };
MOD_INC_USE_COUNT;
newinfo = vmalloc(sizeof(struct ip6t_table_info)
@@ -1767,14 +1765,15 @@
= { { NULL, NULL }, "icmp6", &icmp6_match, &icmp6_checkentry, NULL };
#ifdef CONFIG_PROC_FS
-static inline int print_name(const struct ip6t_table *t,
+static inline int print_name(const char *i,
off_t start_offset, char *buffer, int length,
off_t *pos, unsigned int *count)
{
if ((*count)++ >= start_offset) {
unsigned int namelen;
- namelen = sprintf(buffer + *pos, "%s\n", t->name);
+ namelen = sprintf(buffer + *pos, "%s\n",
+ i + sizeof(struct list_head));
if (*pos + namelen > length) {
/* Stop iterating */
return 1;
@@ -1792,7 +1791,7 @@
if (down_interruptible(&ip6t_mutex) != 0)
return 0;
- LIST_FIND(&ip6t_tables, print_name, struct ip6t_table *,
+ LIST_FIND(&ip6t_tables, print_name, char *,
offset, buffer, length, &pos, &count);
up(&ip6t_mutex);
@@ -1801,6 +1800,46 @@
*start=(char *)((unsigned long)count-offset);
return pos;
}
+
+static int ip6t_get_targets(char *buffer, char **start, off_t offset, int length)
+{
+ off_t pos = 0;
+ unsigned int count = 0;
+
+ if (down_interruptible(&ip6t_mutex) != 0)
+ return 0;
+
+ LIST_FIND(&ip6t_target, print_name, char *,
+ offset, buffer, length, &pos, &count);
+
+ up(&ip6t_mutex);
+
+ *start = (char *)((unsigned long)count - offset);
+ return pos;
+}
+
+static int ip6t_get_matches(char *buffer, char **start, off_t offset, int length)
+{
+ off_t pos = 0;
+ unsigned int count = 0;
+
+ if (down_interruptible(&ip6t_mutex) != 0)
+ return 0;
+
+ LIST_FIND(&ip6t_match, print_name, char *,
+ offset, buffer, length, &pos, &count);
+
+ up(&ip6t_mutex);
+
+ *start = (char *)((unsigned long)count - offset);
+ return pos;
+}
+
+static struct { char *name; get_info_t *get_info; } ip6t_proc_entry[] =
+{ { "ip6_tables_names", ip6t_get_tables },
+ { "ip6_tables_targets", ip6t_get_targets },
+ { "ip6_tables_matches", ip6t_get_matches },
+ { NULL, NULL} };
#endif /*CONFIG_PROC_FS*/
static int __init init(void)
@@ -1826,13 +1865,19 @@
#ifdef CONFIG_PROC_FS
{
struct proc_dir_entry *proc;
- proc = proc_net_create("ip6_tables_names", 0,
- ip6t_get_tables);
- if (!proc) {
- nf_unregister_sockopt(&ip6t_sockopts);
- return -ENOMEM;
+ int i;
+
+ for (i = 0; ip6t_proc_entry[i].name; i++) {
+ proc = proc_net_create(ip6t_proc_entry[i].name, 0,
+ ip6t_proc_entry[i].get_info);
+ if (!proc) {
+ while (--i >= 0)
+ proc_net_remove(ip6t_proc_entry[i].name);
+ nf_unregister_sockopt(&ip6t_sockopts);
+ return -ENOMEM;
+ }
+ proc->owner = THIS_MODULE;
}
- proc->owner = THIS_MODULE;
}
#endif
@@ -1844,7 +1889,11 @@
{
nf_unregister_sockopt(&ip6t_sockopts);
#ifdef CONFIG_PROC_FS
- proc_net_remove("ip6_tables_names");
+ {
+ int i;
+ for (i = 0; ip6t_proc_entry[i].name; i++)
+ proc_net_remove(ip6t_proc_entry[i].name);
+ }
#endif
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)