All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Netfilter Development Mailinglist <netfilter-devel@lists.netfilter.org>
Subject: [PATCH] list register ip6tables targets/matches in /proc/net
Date: Tue, 08 Apr 2003 17:59:14 +0200	[thread overview]
Message-ID: <3E92F1D2.4070902@trash.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

This patch lists registered ip6tables matches/targets in /proc/net,
the equivalent patch to iptables is already included in pom. I sent
this patch multiple times before, hopefully this time it won't be
overseen.

Bye
Patrick

[-- Attachment #2: ip6tables-proc-pom.diff --]
[-- Type: text/plain, Size: 3941 bytes --]

diff -urN a/extra/ip6_tables-proc.patch.ipv6 b/extra/ip6_tables-proc.patch.ipv6
--- a/extra/ip6_tables-proc.patch.ipv6	1970-01-01 01:00:00.000000000 +0100
+++ b/extra/ip6_tables-proc.patch.ipv6	2003-04-07 23:54:02.000000000 +0200
@@ -0,0 +1,116 @@
+===== net/ipv6/netfilter/ip6_tables.c 1.12 vs edited =====
+--- 1.12/net/ipv6/netfilter/ip6_tables.c	Sun Sep 22 08:22:57 2002
++++ edited/net/ipv6/netfilter/ip6_tables.c	Mon Apr  7 23:49:45 2003
+@@ -1767,14 +1767,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 +1793,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 +1802,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 +1867,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 +1891,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
+ }
+ 
diff -urN a/extra/ip6_tables-proc.patch.ipv6.help b/extra/ip6_tables-proc.patch.ipv6.help
--- a/extra/ip6_tables-proc.patch.ipv6.help	1970-01-01 01:00:00.000000000 +0100
+++ b/extra/ip6_tables-proc.patch.ipv6.help	2003-04-07 23:48:33.000000000 +0200
@@ -0,0 +1,6 @@
+Author: Patrick McHardy
+Status: Working
+
+This patch creates two new files in /proc/net, "ip6_tables_matches" and 
+"ip6tables_targets" which contain the names of all loaded matches/targets
+like the file ip6_tables_names already does with loaded tables.

             reply	other threads:[~2003-04-08 15:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08 15:59 Patrick McHardy [this message]
2003-04-11  9:48 ` [PATCH] list register ip6tables targets/matches in /proc/net Jozsef Kadlecsik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E92F1D2.4070902@trash.net \
    --to=kaber@trash.net \
    --cc=netfilter-devel@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.