All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <jdb@comx.dk>
To: Netfilter Developers <netfilter-devel@vger.kernel.org>
Cc: Patrick McHardy <kaber@trash.net>,
	Harald Welte <laforge@netfilter.org>,
	Martin Josefsson <gandalf@netfilter.org>
Subject: [PATCH 2/3] Introduce a counter for number of user defined chains.
Date: Fri, 21 Dec 2007 14:47:57 +0100	[thread overview]
Message-ID: <1198244877.23885.13.camel@localhost.localdomain> (raw)
In-Reply-To: <1198244659.23885.8.camel@localhost.localdomain>

Introduce a counter for number of user defined chains.

Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
---
 libiptc/libiptc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index 5afaf40..b4d865e 100644
--- a/libiptc/libiptc.c
+++ b/libiptc/libiptc.c
@@ -132,6 +132,8 @@ STRUCT_TC_HANDLE
 	struct chain_head *chain_iterator_cur;
 	struct rule_head *rule_iterator_cur;
 
+	unsigned int num_chains;         /* number of user defined chains */
+
 	STRUCT_GETINFO info;
 	STRUCT_GET_ENTRIES *entries;
 };
@@ -475,6 +477,7 @@ static int cache_add_entry(STRUCT_ENTRY *e,
 			errno = -ENOMEM;
 			return -1;
 		}
+		h->num_chains++; /* New user defined chain */
 
 		__iptcc_p_add_chain(h, c, offset, num);
 
@@ -1801,6 +1804,7 @@ TC_CREATE_CHAIN(const IPT_CHAINLABEL chain, TC_HANDLE_T *handle)
 		return 0;
 
 	}
+	(*handle)->num_chains++; /* New user defined chain */
 
 	DEBUGP("Creating chain `%s'\n", chain);
 	iptc_insert_chain(*handle, c); /* Insert sorted */
@@ -1867,13 +1871,15 @@ TC_DELETE_CHAIN(const IPT_CHAINLABEL chain, TC_HANDLE_T *handle)
 	}
 
 	/* If we are about to delete the chain that is the current
-	 * iterator, move chain iterator firward. */
+	 * iterator, move chain iterator forward. */
 	if (c == (*handle)->chain_iterator_cur)
 		iptcc_chain_iterator_advance(*handle);
 
 	list_del(&c->list);
 	free(c);
 
+	(*handle)->num_chains--; /* One user defined chain deleted */
+
 	DEBUGP("chain `%s' deleted\n", chain);
 
 	set_changed(*handle);
-- 
1.5.3



  parent reply	other threads:[~2007-12-21 13:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-21 13:44 [PATCH 0/3] Solve scalability issue for chain list "name" searching Jesper Dangaard Brouer
2007-12-21 13:46 ` [PATCH 1/3] Inline functions iptcc_is_builtin() and set_changed() Jesper Dangaard Brouer
2008-01-15 17:01   ` Patrick McHardy
2007-12-21 13:47 ` Jesper Dangaard Brouer [this message]
2008-01-15 17:06   ` [PATCH 2/3] Introduce a counter for number of user defined chains Patrick McHardy
2007-12-21 13:50 ` [PATCH 3/3] Solving scalability issue: for chain list "name" searching Jesper Dangaard Brouer
2008-01-15 17:18   ` Patrick McHardy

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=1198244877.23885.13.camel@localhost.localdomain \
    --to=jdb@comx.dk \
    --cc=gandalf@netfilter.org \
    --cc=kaber@trash.net \
    --cc=laforge@netfilter.org \
    --cc=netfilter-devel@vger.kernel.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.