All of lore.kernel.org
 help / color / mirror / Atom feed
From: Massimiliano Hofer <max@nucleus.it>
To: netfilter-devel@lists.netfilter.org
Cc: Patrick McHardy <kaber@trash.net>
Subject: Re: [PATCH] priv_data (formerly entry_data)
Date: Wed, 21 Jun 2006 02:42:26 +0200	[thread overview]
Message-ID: <200606210242.27657.max@nucleus.it> (raw)
In-Reply-To: <200606210233.55724.max@nucleus.it>

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

On Wednesday 21 June 2006 2:33 am, Massimiliano Hofer wrote:

> This is a patch against the new version of condition for kernel version
> 2.6.17 (available on the repository).

Ops. I mixed 2 versions. Disregard my previous message. This is the real diff.

-- 
Saluti,
   Massimiliano Hofer

[-- Attachment #2: condition-priv_data.patch --]
[-- Type: text/x-diff, Size: 3874 bytes --]

diff -Nru linux-2.6.17/net/netfilter/xt_condition.c linux-2.6.17-priv_data/net/netfilter/xt_condition.c
--- linux-2.6.17/net/netfilter/xt_condition.c	2006-06-21 02:38:04.000000000 +0200
+++ linux-2.6.17-priv_data/net/netfilter/xt_condition.c	2006-06-21 02:25:02.000000000 +0200
@@ -118,23 +118,14 @@
 match(const struct sk_buff *skb, const struct net_device *in,
       const struct net_device *out, const struct xt_match *match,
       const void *matchinfo, int offset,
-      unsigned int protoff, int *hotdrop)
+      unsigned int protoff, int *hotdrop, void *priv_data)
 {
 	const struct condition_info *info =
-	    (const struct condition_info *) matchinfo;
-	struct condition_variable *var;
-	int condition_status = 0;
+		(const struct condition_info *) matchinfo;
+	struct condition_variable *var=
+		*(struct condition_variable **)priv_data;
 
-	rcu_read_lock();
-	list_for_each_entry_rcu(var, &conditions_list, list) {
-		if (strcmp(info->name, var->status_proc->name) == 0) {
-			condition_status = var->enabled;
-			break;
-		}
-	}
-	rcu_read_unlock();
-
-	return condition_status ^ info->invert;
+	return var->enabled ^ info->invert;
 }
 
 
@@ -143,7 +134,7 @@
 checkentry(const char *tablename, const void *ip,
 	   const struct xt_match *match,
 	   void *matchinfo, unsigned int matchsize,
-	   unsigned int hook_mask)
+	   unsigned int hook_mask, void *priv_data)
 {
 	static const char * const forbidden_names[]={ "", ".", ".." };
 	struct condition_info *info = (struct condition_info *) matchinfo;
@@ -175,6 +166,7 @@
 		var = list_entry(pos, struct condition_variable, list);
 		if (strcmp(info->name, var->status_proc->name) == 0) {
 			var->refcount++;
+			*(struct condition_variable **)priv_data=var;
 			up(&proc_lock);
 			return 1;
 		}
@@ -212,39 +204,34 @@
 
 	up(&proc_lock);
 
+	*(struct condition_variable **)priv_data=newvar;
+
 	return 1;
 }
 
 
 static void
 destroy(const struct xt_match *match, void *matchinfo,
-	unsigned int matchsize)
+	unsigned int matchsize, void *priv_data)
 {
-	struct condition_info *info = (struct condition_info *) matchinfo;
-	struct list_head *pos;
-	struct condition_variable *var;
+	struct condition_variable *var=
+		*(struct condition_variable **)priv_data;
 
-	if (matchsize != XT_ALIGN(sizeof(struct condition_info)))
-		return;
+	BUG_ON(priv_data==NULL);
+	BUG_ON(priv_var==NULL);
 
 	down(&proc_lock);
 
-	list_for_each(pos, &conditions_list) {
-		var = list_entry(pos, struct condition_variable, list);
-		if (strcmp(info->name, var->status_proc->name) == 0) {
-			if (--var->refcount == 0) {
-				list_del_rcu(pos);
-				remove_proc_entry(var->status_proc->name, proc_net_condition);
-				up(&proc_lock);
-				/* synchronize_rcu() would be goog enough, but synchronize_net() */
-				/* guarantees that no packet will go out with the old rule after */
-				/* succesful removal.                                            */
-				synchronize_net();
-				kfree(var);
-				return;
-			}
-			break;
-		}
+	if (--var->refcount == 0) {
+		list_del_rcu(&var->list);
+		remove_proc_entry(var->status_proc->name, proc_net_condition);
+		up(&proc_lock);
+		/* synchronize_rcu() would be goog enough, but synchronize_net() */
+		/* guarantees that no packet will go out with the old rule after */
+		/* succesful removal.                                            */
+		synchronize_net();
+		kfree(var);
+		return;
 	}
 
 	up(&proc_lock);
@@ -255,6 +242,7 @@
 	.name = "condition",
 	.family = AF_INET,
 	.matchsize = sizeof(struct condition_info),
+	.priv_size = sizeof(struct condition_variable *),
 	.match = &match,
 	.checkentry = &checkentry,
 	.destroy = &destroy,
@@ -265,6 +253,7 @@
 	.name = "condition",
 	.family = AF_INET6,
 	.matchsize = sizeof(struct condition_info),
+	.priv_size = sizeof(struct condition_variable *),
 	.match = &match,
 	.checkentry = &checkentry,
 	.destroy = &destroy,

      reply	other threads:[~2006-06-21  0:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-04 22:29 [PATCH] entry_data Massimiliano Hofer
2006-06-11 23:19 ` Massimiliano Hofer
2006-06-12  9:50   ` Pablo Neira Ayuso
2006-06-12 12:45     ` Massimiliano Hofer
2006-06-13 15:19       ` Pablo Neira Ayuso
2006-06-13 20:56         ` Massimiliano Hofer
2006-06-19  0:15           ` Pablo Neira Ayuso
2006-06-19  7:02             ` Massimiliano Hofer
2006-06-19 23:37               ` Pablo Neira Ayuso
2006-06-20  1:39                 ` Patrick McHardy
2006-06-14  9:03 ` Sven Anders
2006-06-17 22:55   ` Massimiliano Hofer
2006-06-19 17:45     ` Patrick McHardy
2006-06-19 23:05       ` Massimiliano Hofer
2006-06-20  1:29         ` Patrick McHardy
2006-06-19 17:34   ` Patrick McHardy
2006-06-19 22:35     ` Massimiliano Hofer
2006-06-19 23:13       ` Patrick McHardy
2006-06-20 11:25         ` Massimiliano Hofer
2006-06-20 13:17           ` Patrick McHardy
2006-06-21  0:03             ` [PATCH] priv_data (formerly entry_data) Massimiliano Hofer
2006-06-21  0:30               ` Patrick McHardy
2006-06-21  0:45                 ` Massimiliano Hofer
2006-06-21  1:04                   ` Patrick McHardy
2006-06-21  8:31                     ` Massimiliano Hofer
2006-06-21 23:50                 ` Massimiliano Hofer
2006-06-22 15:18                   ` Patrick McHardy
2006-06-21  0:33               ` Massimiliano Hofer
2006-06-21  0:42                 ` Massimiliano Hofer [this message]

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=200606210242.27657.max@nucleus.it \
    --to=max@nucleus.it \
    --cc=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.