From: Olaf Rempel <razzor@kopf-tisch.de>
To: netfilter-devel@lists.netfilter.org
Subject: [iptables 1.3.0 / libiptc patch] sort chains by hooknum/names
Date: Fri, 4 Mar 2005 21:21:14 +0100 [thread overview]
Message-ID: <20050304212114.130e2a7c@coruscant> (raw)
hi list
>From 1.3.0 all chain names were alphabetically sorted when listing tables.
A user-defined chain 'AAA' is listed before the buildin chain "INPUT", and
"FORWARD" is listed before "INPUT".
I've created two patches to revert it to the "old" behavior:
first buildin chains, sorted by hooknum, than userdefined chains, sorted by name.
OK, why two patches?
The first one need some preconditions:
*all* buildin chains need to be "in order" and in front of *any* user chain
when parsing the kernel-list.
I was not sure about this, so I made a second patch, that does not need these
preconditions.
Olaf
diff -uNr iptables-1.3.0.org/libiptc/libiptc.c iptables-1.3.0/libiptc/libiptc.c
--- iptables-1.3.0.org/libiptc/libiptc.c 2005-02-12 21:05:32.000000000 +0100
+++ iptables-1.3.0/libiptc/libiptc.c 2005-03-04 17:12:17.909906736 +0100
@@ -396,10 +396,13 @@
{
struct chain_head *tmp;
- list_for_each_entry(tmp, &h->chains, list) {
- if (strcmp(c->name, tmp->name) <= 0) {
- list_add(&c->list, tmp->list.prev);
- return;
+ /* sort only user defined chains */
+ if (!c->hooknum) {
+ list_for_each_entry(tmp, &h->chains, list) {
+ if (strcmp(c->name, tmp->name) <= 0) {
+ list_add(&c->list, tmp->list.prev);
+ return;
+ }
}
}
diff -uNr iptables-1.3.0.org/libiptc/libiptc.c iptables-1.3.0/libiptc/libiptc.c
--- iptables-1.3.0.org/libiptc/libiptc.c 2005-02-12 21:05:32.000000000 +0100
+++ iptables-1.3.0/libiptc/libiptc.c 2005-03-04 17:20:12.720724520 +0100
@@ -396,10 +396,23 @@
{
struct chain_head *tmp;
- list_for_each_entry(tmp, &h->chains, list) {
- if (strcmp(c->name, tmp->name) <= 0) {
- list_add(&c->list, tmp->list.prev);
- return;
+ /* sort only user defined chains */
+ if (!c->hooknum) {
+ /* sort user-defined by name and after builtins */
+ list_for_each_entry(tmp, &h->chains, list) {
+ if (!tmp->hooknum && strcmp(c->name, tmp->name) <= 0) {
+ list_add(&c->list, tmp->list.prev);
+ return;
+ }
+ }
+
+ } else {
+ /* sort builtins by hooknum and before user-defined */
+ list_for_each_entry(tmp, &h->chains, list) {
+ if (!tmp->hooknum || tmp->hooknum > c->hooknum) {
+ list_add(&c->list, tmp->list.prev);
+ return;
+ }
}
}
next reply other threads:[~2005-03-04 20:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-04 20:21 Olaf Rempel [this message]
2005-03-04 22:08 ` [iptables 1.3.0 / libiptc patch] sort chains by hooknum/names Phil Oester
2005-03-04 22:38 ` Patrick McHardy
2005-03-04 23:15 ` Olaf Rempel
2005-03-04 23:04 ` Patrick McHardy
2005-04-19 14:51 ` Jonas Berlin
2005-03-05 2:07 ` Herve Eychenne
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=20050304212114.130e2a7c@coruscant \
--to=razzor@kopf-tisch.de \
--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.