patch-2.4.22 linux-2.4.22/net/ipv4/netfilter/ip_tables.c
Next file: linux-2.4.22/net/ipv4/netfilter/ipt_MIRROR.c
Previous file: linux-2.4.22/net/ipv4/netfilter/ip_nat_snmp_basic.c
Back to the patch index
Back to the overall index
- Lines: 112
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/net/ipv4/netfilter/ip_tables.c
- Orig date:
2003-06-13 07:51:39.000000000 -0700
diff -urN linux-2.4.21/net/ipv4/netfilter/ip_tables.c linux-2.4.22/net/ipv4/netfilter/ip_tables.c
@@ -1698,14 +1698,15 @@
= { { NULL, NULL }, "icmp", &icmp_match, &icmp_checkentry, NULL };
#ifdef CONFIG_PROC_FS
-static inline int print_name(const struct ipt_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;
@@ -1723,7 +1724,7 @@
if (down_interruptible(&ipt_mutex) != 0)
return 0;
- LIST_FIND(&ipt_tables, print_name, struct ipt_table *,
+ LIST_FIND(&ipt_tables, print_name, void *,
offset, buffer, length, &pos, &count);
up(&ipt_mutex);
@@ -1732,6 +1733,46 @@
*start=(char *)((unsigned long)count-offset);
return pos;
}
+
+static int ipt_get_targets(char *buffer, char **start, off_t offset, int length)
+{
+ off_t pos = 0;
+ unsigned int count = 0;
+
+ if (down_interruptible(&ipt_mutex) != 0)
+ return 0;
+
+ LIST_FIND(&ipt_target, print_name, void *,
+ offset, buffer, length, &pos, &count);
+
+ up(&ipt_mutex);
+
+ *start = (char *)((unsigned long)count - offset);
+ return pos;
+}
+
+static int ipt_get_matches(char *buffer, char **start, off_t offset, int length)
+{
+ off_t pos = 0;
+ unsigned int count = 0;
+
+ if (down_interruptible(&ipt_mutex) != 0)
+ return 0;
+
+ LIST_FIND(&ipt_match, print_name, void *,
+ offset, buffer, length, &pos, &count);
+
+ up(&ipt_mutex);
+
+ *start = (char *)((unsigned long)count - offset);
+ return pos;
+}
+
+static struct { char *name; get_info_t *get_info; } ipt_proc_entry[] =
+{ { "ip_tables_names", ipt_get_tables },
+ { "ip_tables_targets", ipt_get_targets },
+ { "ip_tables_matches", ipt_get_matches },
+ { NULL, NULL} };
#endif /*CONFIG_PROC_FS*/
static int __init init(void)
@@ -1757,13 +1798,19 @@
#ifdef CONFIG_PROC_FS
{
struct proc_dir_entry *proc;
+ int i;
- proc = proc_net_create("ip_tables_names", 0, ipt_get_tables);
- if (!proc) {
- nf_unregister_sockopt(&ipt_sockopts);
- return -ENOMEM;
+ for (i = 0; ipt_proc_entry[i].name; i++) {
+ proc = proc_net_create(ipt_proc_entry[i].name, 0,
+ ipt_proc_entry[i].get_info);
+ if (!proc) {
+ while (--i >= 0)
+ proc_net_remove(ipt_proc_entry[i].name);
+ nf_unregister_sockopt(&ipt_sockopts);
+ return -ENOMEM;
+ }
+ proc->owner = THIS_MODULE;
}
- proc->owner = THIS_MODULE;
}
#endif
@@ -1775,7 +1822,11 @@
{
nf_unregister_sockopt(&ipt_sockopts);
#ifdef CONFIG_PROC_FS
- proc_net_remove("ip_tables_names");
+ {
+ int i;
+ for (i = 0; ipt_proc_entry[i].name; i++)
+ proc_net_remove(ipt_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)