[LARTC] iproute2-051007 TC static linked Makefile how to

2006-08-02 Thread Mark Chao
Hi All

I'm the newbie in iproute2. For some reason, I have to
use static linked instead of dynamic. My kernel is
2.4.18-14 (Redhat 8.0). After patching 
htb3.6_tc.diff, still comes out Unknown qdisc
htb... by tc qdisc add dev eth0 root handle 1: htb
default 20 command. Or any examples/web link discuss
about iproute2 static linked? Please advise!

BR
Mark

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


[LARTC] iptables u32 kernel 2.6.17

2006-08-02 Thread gerald HUET
hi everybody,

I used to test this rules on my gateway :
iptables -I FORWARD -p udp -m length --length 39 -m
u32 --u32 '270x8f=7' --u32 '31=0x527c4833' -j DROP

This was working with a 2.6.16 kernel but now i
upgraded to 2.6.17 it give me the following message :
[ 5333.87] ip_tables: u32 match: invalid size 0 !=
2028
iptables: Unknown error -1


I tried to do some modifications on ipt_u32.c
following  modifications which work for ipp2p
(http://www.sieglitzhof.net/~doc/ipp2p/) without any
succes. 

Does anyone have an explication why the problem occurs
whith the new kernel and how to solve it ?

Thanks in advance






___ 
Découvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet 
! 
Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et vos 
expériences. 
http://fr.answers.yahoo.com 

___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


Re: [LARTC] FWMark routing trouble

2006-08-02 Thread Markus Schulz
Am Samstag, 29. Juli 2006 17:33 schrieb former03 | Baltasar Cevc:
 Hi everybody,

 I'm trying to set up routing for 2 links to the internet on a box
 which produces traffic itself (e.g. DNS) and will route all our local
 traffic.

 AS one route is quick and expensive and the other one slow and cheap,
 I want to be able to route packets for some high-level protocols to
 the second link.

 If I correctly understood table 3-2 in
 http://www.faqs.org/docs/iptables/traversingoftables.html that is not
 possible as the routing decision is taken even before the packet
 touches netfilter for the first time.


 Is that correct? Does anybody have some hints about how to work
 around?

It's possible with Policy Routing. Look at 
http://www.policyrouting.org/PolicyRoutingBook/ONLINE/TOC.html for 
documentation about it.

(Simplest?) way to do it: (only short excerpt)

- Mark the specific application packets with iptables in PREROUTING 
chain
...
- add rules for routing fwmarked packets to seperate routing tables
ip rule add fwmark your fwmark #1 table routing table for slow apps
ip rule add fwmark your fwmark #2 table routing table for fast apps

- build both routing tables
ip route add default via $PTP1 dev device #1 src $IP1 proto static 
table routing table for slow apps
ip route add default via $PTP2 dev device #2 src $IP2 proto static 
table routing table for fast apps

(Proto static needs kernel patches, but you don't really need this)


-- 
Markus Schulz 
___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


Re: [LARTC] iptables u32 kernel 2.6.17

2006-08-02 Thread Torsten Luettgert
On Wed, 2006-08-02 at 10:55 +0200, gerald HUET wrote:
 [ 5333.87] ip_tables: u32 match: invalid size 0 !=
 2028
 iptables: Unknown error -1
 
 I tried to do some modifications on ipt_u32.c
 following  modifications which work for ipp2p
 (http://www.sieglitzhof.net/~doc/ipp2p/) without any
 succes. 

Hm, that should have worked - it's the same problem for
all the little-maintained stuff in patch-o-matic.

 Does anyone have an explication why the problem occurs
 whith the new kernel and how to solve it ?

The parameters to checkentry() and match() changed
incompatibly between 2.6.16 and 2.6.17.

The u32 match in current SVN works with 2.6.17
(but not with 2.6.16 or earlier).

You need to
svn co http://svn.netfilter.org/netfilter/trunk/patch-o-matic-ng

then patch your kernel and recompile.

Regards,
Torsten

___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


Re: [LARTC] iptables u32 kernel 2.6.17

2006-08-02 Thread Piotr Chytla
On Wed, Aug 02, 2006 at 03:52:39PM +0200, Torsten Luettgert wrote:
 On Wed, 2006-08-02 at 10:55 +0200, gerald HUET wrote:
  [ 5333.87] ip_tables: u32 match: invalid size 0 !=
  2028
  iptables: Unknown error -1
  
  I tried to do some modifications on ipt_u32.c
  following  modifications which work for ipp2p
  (http://www.sieglitzhof.net/~doc/ipp2p/) without any
  succes. 
 
 Hm, that should have worked - it's the same problem for
 all the little-maintained stuff in patch-o-matic.
 
  Does anyone have an explication why the problem occurs
  whith the new kernel and how to solve it ?
 
 The parameters to checkentry() and match() changed
 incompatibly between 2.6.16 and 2.6.17.
 
 The u32 match in current SVN works with 2.6.17
 (but not with 2.6.16 or earlier).
 
 You need to
 svn co http://svn.netfilter.org/netfilter/trunk/patch-o-matic-ng
 
 then patch your kernel and recompile.

apply also patch from attachment. 2.6.17 needs matchsize in ipt_match struct.

triss:~# iptables -I FORWARD -p udp -m length --length 39 -m u32 --u32 
'270x8f=7' --u32 '31=0x527c4833' -j DROP

triss:~# iptables -L FORWARD -vn
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target prot opt in out source destination 
0 0 DROP   udp  --  *  *   0.0.0.0/0 0.0.0.0/0   
length 39 u32 0x1f=0x527c4833 

seems working.

/pch



-- 
Dyslexia bug unpatched since 1977 ...
exploit has been leaked to the underground.
--- ipt_u32.c   2006-08-02 22:34:29.0 +0200
+++ /usr/src/linux-2.6.17.6/net/ipv4/netfilter/ipt_u32.c2006-08-02 
22:45:43.0 +0200
@@ -217,6 +217,7 @@
 static struct ipt_match u32_match = { 
.name   = u32,
.match  = match,
+   .matchsize  = sizeof(struct ipt_u32),
.checkentry = checkentry,
.me = THIS_MODULE
 };
___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


[LARTC] [PATCH 0/6] htb: cleanup

2006-08-02 Thread Stephen Hemminger
The HTB scheduler code is a mess, this patch set does some basic
house cleaning.  The first four should cause no code change, but the
last two need more testing.

-- 
Stephen Hemminger [EMAIL PROTECTED]
And in the Packet there writ down that doome
___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


[LARTC] [PATCH 5/6] htb: use hlist for hash lists.

2006-08-02 Thread Stephen Hemminger
Use hlist instead of list for the hash list. This saves
space, and we can check for double delete better.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
---
 net/sched/sch_htb.c |   49 +++--
 1 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 528d5c5..7853c6f 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -104,7 +104,7 @@ #endif
/* topology */
int level;  /* our level (see above) */
struct htb_class *parent;   /* parent class */
-   struct list_head hlist; /* classid hash list item */
+   struct hlist_node hlist;/* classid hash list item */
struct list_head sibling;   /* sibling list item */
struct list_head children;  /* children list */
 
@@ -163,8 +163,8 @@ static inline long L2T(struct htb_class 
 
 struct htb_sched {
struct list_head root;  /* root classes list */
-   struct list_head hash[HTB_HSIZE];   /* hashed by classid */
-   struct list_head drops[TC_HTB_NUMPRIO]; /* active leaves (for drops) */
+   struct hlist_head hash[HTB_HSIZE];  /* hashed by classid */
+   struct list_head drops[TC_HTB_NUMPRIO];/* active leaves (for drops) */
 
/* self list - roots of self generating tree */
struct rb_root row[TC_HTB_MAXDEPTH][TC_HTB_NUMPRIO];
@@ -220,12 +220,13 @@ #endif
 static inline struct htb_class *htb_find(u32 handle, struct Qdisc *sch)
 {
struct htb_sched *q = qdisc_priv(sch);
-   struct list_head *p;
+   struct hlist_node *p;
+   struct htb_class *cl;
+
if (TC_H_MAJ(handle) != sch-handle)
return NULL;
 
-   list_for_each(p, q-hash + htb_hash(handle)) {
-   struct htb_class *cl = list_entry(p, struct htb_class, hlist);
+   hlist_for_each_entry(cl, p, q-hash + htb_hash(handle), hlist) {
if (cl-classid == handle)
return cl;
}
@@ -675,7 +676,9 @@ static void htb_rate_timer(unsigned long
 {
struct Qdisc *sch = (struct Qdisc *)arg;
struct htb_sched *q = qdisc_priv(sch);
-   struct list_head *p;
+   struct hlist_node *p;
+   struct htb_class *cl;
+
 
/* lock queue so that we can muck with it */
spin_lock_bh(sch-dev-queue_lock);
@@ -686,9 +689,8 @@ static void htb_rate_timer(unsigned long
/* scan and recompute one bucket at time */
if (++q-recmp_bucket = HTB_HSIZE)
q-recmp_bucket = 0;
-   list_for_each(p, q-hash + q-recmp_bucket) {
-   struct htb_class *cl = list_entry(p, struct htb_class, hlist);
 
+   hlist_for_each_entry(cl,p, q-hash + q-recmp_bucket, hlist) {
RT_GEN(cl-sum_bytes, cl-rate_bytes);
RT_GEN(cl-sum_packets, cl-rate_packets);
}
@@ -1041,10 +1043,10 @@ static void htb_reset(struct Qdisc *sch)
int i;
 
for (i = 0; i  HTB_HSIZE; i++) {
-   struct list_head *p;
-   list_for_each(p, q-hash + i) {
-   struct htb_class *cl =
-   list_entry(p, struct htb_class, hlist);
+   struct hlist_node *p;
+   struct htb_class *cl;
+
+   hlist_for_each_entry(cl, p, q-hash + i, hlist) {
if (cl-level)
memset(cl-un.inner, 0, sizeof(cl-un.inner));
else {
@@ -1091,7 +1093,7 @@ static int htb_init(struct Qdisc *sch, s
 
INIT_LIST_HEAD(q-root);
for (i = 0; i  HTB_HSIZE; i++)
-   INIT_LIST_HEAD(q-hash + i);
+   INIT_HLIST_HEAD(q-hash + i);
for (i = 0; i  TC_HTB_NUMPRIO; i++)
INIT_LIST_HEAD(q-drops + i);
 
@@ -1269,7 +1271,8 @@ static void htb_destroy_class(struct Qdi
  struct htb_class, sibling));
 
/* note: this delete may happen twice (see htb_delete) */
-   list_del(cl-hlist);
+   if (!hlist_unhashed(cl-hlist))
+   hlist_del(cl-hlist);
list_del(cl-sibling);
 
if (cl-prio_activity)
@@ -1317,7 +1320,9 @@ static int htb_delete(struct Qdisc *sch,
sch_tree_lock(sch);
 
/* delete from hash and active; remainder in destroy_class */
-   list_del_init(cl-hlist);
+   if (!hlist_unhashed(cl-hlist))
+   hlist_del(cl-hlist);
+
if (cl-prio_activity)
htb_deactivate(q, cl);
 
@@ -1381,7 +1386,7 @@ static int htb_change_class(struct Qdisc
 
cl-refcnt = 1;
INIT_LIST_HEAD(cl-sibling);
-   INIT_LIST_HEAD(cl-hlist);
+   INIT_HLIST_NODE(cl-hlist);
INIT_LIST_HEAD(cl-children);
INIT_LIST_HEAD(cl-un.leaf.drop_list);
 
@@ -1420,7 +1425,7 @@ static int htb_change_class(struct Qdisc
cl-cmode = HTB_CAN_SEND;
 
/* attach to 

[LARTC] [PATCH 6/6] htb: rbtree cleanup

2006-08-02 Thread Stephen Hemminger
Add code to initialize rb tree nodes, and check for double deletion.
This is not a real fix, but I can make it trap sometimes and may
be a bandaid for: http://bugzilla.kernel.org/show_bug.cgi?id=6681

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
---
 net/sched/sch_htb.c |   34 +++---
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 7853c6f..3f3e9df 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -366,7 +366,7 @@ static void htb_add_to_wait_tree(struct 
  * When we are past last key we return NULL.
  * Average complexity is 2 steps per call.
  */
-static void htb_next_rb_node(struct rb_node **n)
+static inline void htb_next_rb_node(struct rb_node **n)
 {
*n = rb_next(*n);
 }
@@ -388,6 +388,18 @@ static inline void htb_add_class_to_row(
}
 }
 
+/* If this triggers, it is a bug in this code, but it need not be fatal */
+static void htb_safe_rb_erase(struct rb_node *rb, struct rb_root *root)
+{
+   if (RB_EMPTY_NODE(rb)) {
+   WARN_ON(1);
+   } else {
+   rb_erase(rb, root);
+   RB_CLEAR_NODE(rb);
+   }
+}
+
+
 /**
  * htb_remove_class_from_row - removes class from its row
  *
@@ -401,10 +413,12 @@ static inline void htb_remove_class_from
 
while (mask) {
int prio = ffz(~mask);
+
mask = ~(1  prio);
if (q-ptr[cl-level][prio] == cl-node + prio)
htb_next_rb_node(q-ptr[cl-level] + prio);
-   rb_erase(cl-node + prio, q-row[cl-level] + prio);
+
+   htb_safe_rb_erase(cl-node + prio, q-row[cl-level] + prio);
if (!q-row[cl-level][prio].rb_node)
m |= 1  prio;
}
@@ -472,7 +486,7 @@ static void htb_deactivate_prios(struct 
p-un.inner.ptr[prio] = NULL;
}
 
-   rb_erase(cl-node + prio, p-un.inner.feed + prio);
+   htb_safe_rb_erase(cl-node + prio, p-un.inner.feed + 
prio);
 
if (!p-un.inner.feed[prio].rb_node)
mask |= 1  prio;
@@ -739,7 +753,7 @@ #define HTB_ACCNT(T,B,R) toks = diff + c
htb_change_class_mode(q, cl, diff);
if (old_mode != cl-cmode) {
if (old_mode != HTB_CAN_SEND)
-   rb_erase(cl-pq_node, q-wait_pq + cl-level);
+   htb_safe_rb_erase(cl-pq_node, q-wait_pq + 
cl-level);
if (cl-cmode != HTB_CAN_SEND)
htb_add_to_wait_tree(q, cl, diff);
}
@@ -782,7 +796,7 @@ static long htb_do_events(struct htb_sch
if (time_after(cl-pq_key, q-jiffies)) {
return cl-pq_key - q-jiffies;
}
-   rb_erase(p, q-wait_pq + level);
+   htb_safe_rb_erase(p, q-wait_pq + level);
diff = PSCHED_TDIFF_SAFE(q-now, cl-t_c, (u32) cl-mbuffer);
htb_change_class_mode(q, cl, diff);
if (cl-cmode != HTB_CAN_SEND)
@@ -1279,7 +1293,7 @@ static void htb_destroy_class(struct Qdi
htb_deactivate(q, cl);
 
if (cl-cmode != HTB_CAN_SEND)
-   rb_erase(cl-pq_node, q-wait_pq + cl-level);
+   htb_safe_rb_erase(cl-pq_node, q-wait_pq + cl-level);
 
kfree(cl);
 }
@@ -1370,6 +1384,8 @@ static int htb_change_class(struct Qdisc
 
if (!cl) {  /* new class */
struct Qdisc *new_q;
+   int prio;
+
/* check for valid classid */
if (!classid || TC_H_MAJ(classid ^ sch-handle)
|| htb_find(classid, sch))
@@ -1389,6 +1405,10 @@ static int htb_change_class(struct Qdisc
INIT_HLIST_NODE(cl-hlist);
INIT_LIST_HEAD(cl-children);
INIT_LIST_HEAD(cl-un.leaf.drop_list);
+   RB_CLEAR_NODE(cl-pq_node);
+
+   for (prio = 0; prio  TC_HTB_NUMPRIO; prio++)
+   RB_CLEAR_NODE(cl-node[prio]);
 
/* create leaf qdisc early because it uses kmalloc(GFP_KERNEL)
   so that can't be used inside of sch_tree_lock
@@ -1404,7 +1424,7 @@ static int htb_change_class(struct Qdisc
 
/* remove from evt list because of level change */
if (parent-cmode != HTB_CAN_SEND) {
-   rb_erase(parent-pq_node, q-wait_pq);
+   htb_safe_rb_erase(parent-pq_node, q-wait_pq);
parent-cmode = HTB_CAN_SEND;
}
parent-level = (parent-parent ? parent-parent-level
-- 
1.4.0

___
LARTC mailing list
LARTC@mailman.ds9a.nl

[LARTC] [PATCH 3/6] htb: if HTB_HYSTERIS cleanup

2006-08-02 Thread Stephen Hemminger
Change the conditional compilation around HTB_HYSTERSIS
since code was splitting mid expression.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
---
 net/sched/sch_htb.c |   27 +--
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index c0b80b7..d8c1a6b 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -483,6 +483,20 @@ static void htb_deactivate_prios(struct 
htb_remove_class_from_row(q,cl,mask);
 }
 
+#if HTB_HYSTERESIS
+static inline long htb_lowater(const struct htb_class *cl)
+{
+   return cl-cmode != HTB_CANT_SEND ? -cl-cbuffer : 0;
+}
+static inline long htb_hiwater(const struct htb_class *cl)
+{
+   return cl-cmode == HTB_CAN_SEND ? -cl-buffer : 0;
+}
+#else
+#define htb_lowater(cl)(0)
+#define htb_hiwater(cl)(0)
+#endif
+
 /**
  * htb_class_mode - computes and returns current class mode
  *
@@ -499,19 +513,12 @@ htb_class_mode(struct htb_class *cl,long
 {
 long toks;
 
-if ((toks = (cl-ctokens + *diff))  (
-#if HTB_HYSTERESIS
-   cl-cmode != HTB_CANT_SEND ? -cl-cbuffer :
-#endif
-   0)) {
+if ((toks = (cl-ctokens + *diff))  htb_lowater(cl)) {
*diff = -toks;
return HTB_CANT_SEND;
 }
-if ((toks = (cl-tokens + *diff)) = (
-#if HTB_HYSTERESIS
-   cl-cmode == HTB_CAN_SEND ? -cl-buffer :
-#endif
-   0))
+
+if ((toks = (cl-tokens + *diff)) = htb_hiwater(cl))
return HTB_CAN_SEND;
 
 *diff = -toks;
-- 
1.4.0

___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc


[LARTC] [PATCH 1/6] htb: remove broken debug code

2006-08-02 Thread Stephen Hemminger

The HTB network scheduler had debug code that wouldn't compile
and confused and obfuscated the code, remove it.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
---
 net/sched/sch_htb.c |  302 ++-
 1 files changed, 34 insertions(+), 268 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 880a339..73094e7 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -70,7 +70,6 @@ #include linux/rbtree.h
 
 #define HTB_HSIZE 16   /* classid hash size */
 #define HTB_EWMAC 2/* rate average over HTB_EWMAC*HTB_HSIZE sec */
-#undef HTB_DEBUG   /* compile debugging support (activated by tc tool) */
 #define HTB_RATECM 1/* whether to use rate computer */
 #define HTB_HYSTERESIS 1/* whether to use mode hysteresis for speedup */
 #define HTB_QLOCK(S) spin_lock_bh((S)-dev-queue_lock)
@@ -81,51 +80,6 @@ #if HTB_VER  16 != TC_HTB_PROTOVER
 #error Mismatched sch_htb.c and pkt_sch.h
 #endif
 
-/* debugging support; S is subsystem, these are defined:
-  0 - netlink messages
-  1 - enqueue
-  2 - drop  requeue
-  3 - dequeue main
-  4 - dequeue one prio DRR part
-  5 - dequeue class accounting
-  6 - class overlimit status computation
-  7 - hint tree
-  8 - event queue
- 10 - rate estimator
- 11 - classifier 
- 12 - fast dequeue cache
-
- L is level; 0 = none, 1 = basic info, 2 = detailed, 3 = full
- q-debug uint32 contains 16 2-bit fields one for subsystem starting
- from LSB
- */
-#ifdef HTB_DEBUG
-#define HTB_DBG_COND(S,L) (((q-debug(2*S))3) = L)
-#define HTB_DBG(S,L,FMT,ARG...) if (HTB_DBG_COND(S,L)) \
-   printk(KERN_DEBUG FMT,##ARG)
-#define HTB_CHCL(cl) BUG_TRAP((cl)-magic == HTB_CMAGIC)
-#define HTB_PASSQ q,
-#define HTB_ARGQ struct htb_sched *q,
-#define static
-#undef __inline__
-#define __inline__
-#undef inline
-#define inline
-#define HTB_CMAGIC 0xFEFAFEF1
-#define htb_safe_rb_erase(N,R) do { BUG_TRAP((N)-rb_color != -1); \
-   if ((N)-rb_color == -1) break; \
-   rb_erase(N,R); \
-   (N)-rb_color = -1; } while (0)
-#else
-#define HTB_DBG_COND(S,L) (0)
-#define HTB_DBG(S,L,FMT,ARG...)
-#define HTB_PASSQ
-#define HTB_ARGQ
-#define HTB_CHCL(cl)
-#define htb_safe_rb_erase(N,R) rb_erase(N,R)
-#endif
-
-
 /* used internaly to keep status of single class */
 enum htb_cmode {
 HTB_CANT_SEND, /* class can't send and can't borrow */
@@ -136,9 +90,6 @@ enum htb_cmode {
 /* interior  leaf nodes; props specific to leaves are marked L: */
 struct htb_class
 {
-#ifdef HTB_DEBUG
-   unsigned magic;
-#endif
 /* general class parameters */
 u32 classid;
 struct gnet_stats_basic bstats;
@@ -238,7 +189,6 @@ struct htb_sched
 int nwc_hit;   /* this to disable mindelay complaint in dequeue */
 
 int defcls;/* class where unclassified flows go to */
-u32 debug; /* subsystem debug levels */
 
 /* filters for qdisc itself */
 struct tcf_proto *filter_list;
@@ -354,75 +304,21 @@ #endif
return cl;
 }
 
-#ifdef HTB_DEBUG
-static void htb_next_rb_node(struct rb_node **n);
-#define HTB_DUMTREE(root,memb) if(root) { \
-   struct rb_node *n = (root)-rb_node; \
-   while (n-rb_left) n = n-rb_left; \
-   while (n) { \
-   struct htb_class *cl = rb_entry(n, struct htb_class, memb); \
-   printk( %x,cl-classid); htb_next_rb_node (n); \
-   } }
-
-static void htb_debug_dump (struct htb_sched *q)
-{
-   int i,p;
-   printk(KERN_DEBUG htb*g j=%lu lj=%lu\n,jiffies,q-jiffies);
-   /* rows */
-   for (i=TC_HTB_MAXDEPTH-1;i=0;i--) {
-   printk(KERN_DEBUG htb*r%d m=%x,i,q-row_mask[i]);
-   for (p=0;pTC_HTB_NUMPRIO;p++) {
-   if (!q-row[i][p].rb_node) continue;
-   printk( p%d:,p);
-   HTB_DUMTREE(q-row[i]+p,node[p]);
-   }
-   printk(\n);
-   }
-   /* classes */
-   for (i = 0; i  HTB_HSIZE; i++) {
-   struct list_head *l;
-   list_for_each (l,q-hash+i) {
-   struct htb_class *cl = list_entry(l,struct 
htb_class,hlist);
-   long diff = PSCHED_TDIFF_SAFE(q-now, cl-t_c, 
(u32)cl-mbuffer);
-   printk(KERN_DEBUG htb*c%x m=%d t=%ld c=%ld pq=%lu 
df=%ld ql=%d 
-   pa=%x f:,
-   cl-classid,cl-cmode,cl-tokens,cl-ctokens,
-   cl-pq_node.rb_color==-1?0:cl-pq_key,diff,
-   
cl-level?0:cl-un.leaf.q-q.qlen,cl-prio_activity);
-   if (cl-level)
-   for (p=0;pTC_HTB_NUMPRIO;p++) {
-   if (!cl-un.inner.feed[p].rb_node) continue;
-   printk( p%d 
a=%x:,p,cl-un.inner.ptr[p]?rb_entry(cl-un.inner.ptr[p], struct 
htb_class,node[p])-classid:0);
-   

[LARTC] [PATCH 6/6] htb: rbtree cleanup

2006-08-02 Thread Stephen Hemminger
Add code to initialize rb tree nodes, and check for double deletion.
This is not a real fix, but I can make it trap sometimes and may
be a bandaid for: http://bugzilla.kernel.org/show_bug.cgi?id=6681

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
---
 net/sched/sch_htb.c |   34 +++---
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 7853c6f..3f3e9df 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -366,7 +366,7 @@ static void htb_add_to_wait_tree(struct 
  * When we are past last key we return NULL.
  * Average complexity is 2 steps per call.
  */
-static void htb_next_rb_node(struct rb_node **n)
+static inline void htb_next_rb_node(struct rb_node **n)
 {
*n = rb_next(*n);
 }
@@ -388,6 +388,18 @@ static inline void htb_add_class_to_row(
}
 }
 
+/* If this triggers, it is a bug in this code, but it need not be fatal */
+static void htb_safe_rb_erase(struct rb_node *rb, struct rb_root *root)
+{
+   if (RB_EMPTY_NODE(rb)) {
+   WARN_ON(1);
+   } else {
+   rb_erase(rb, root);
+   RB_CLEAR_NODE(rb);
+   }
+}
+
+
 /**
  * htb_remove_class_from_row - removes class from its row
  *
@@ -401,10 +413,12 @@ static inline void htb_remove_class_from
 
while (mask) {
int prio = ffz(~mask);
+
mask = ~(1  prio);
if (q-ptr[cl-level][prio] == cl-node + prio)
htb_next_rb_node(q-ptr[cl-level] + prio);
-   rb_erase(cl-node + prio, q-row[cl-level] + prio);
+
+   htb_safe_rb_erase(cl-node + prio, q-row[cl-level] + prio);
if (!q-row[cl-level][prio].rb_node)
m |= 1  prio;
}
@@ -472,7 +486,7 @@ static void htb_deactivate_prios(struct 
p-un.inner.ptr[prio] = NULL;
}
 
-   rb_erase(cl-node + prio, p-un.inner.feed + prio);
+   htb_safe_rb_erase(cl-node + prio, p-un.inner.feed + 
prio);
 
if (!p-un.inner.feed[prio].rb_node)
mask |= 1  prio;
@@ -739,7 +753,7 @@ #define HTB_ACCNT(T,B,R) toks = diff + c
htb_change_class_mode(q, cl, diff);
if (old_mode != cl-cmode) {
if (old_mode != HTB_CAN_SEND)
-   rb_erase(cl-pq_node, q-wait_pq + cl-level);
+   htb_safe_rb_erase(cl-pq_node, q-wait_pq + 
cl-level);
if (cl-cmode != HTB_CAN_SEND)
htb_add_to_wait_tree(q, cl, diff);
}
@@ -782,7 +796,7 @@ static long htb_do_events(struct htb_sch
if (time_after(cl-pq_key, q-jiffies)) {
return cl-pq_key - q-jiffies;
}
-   rb_erase(p, q-wait_pq + level);
+   htb_safe_rb_erase(p, q-wait_pq + level);
diff = PSCHED_TDIFF_SAFE(q-now, cl-t_c, (u32) cl-mbuffer);
htb_change_class_mode(q, cl, diff);
if (cl-cmode != HTB_CAN_SEND)
@@ -1279,7 +1293,7 @@ static void htb_destroy_class(struct Qdi
htb_deactivate(q, cl);
 
if (cl-cmode != HTB_CAN_SEND)
-   rb_erase(cl-pq_node, q-wait_pq + cl-level);
+   htb_safe_rb_erase(cl-pq_node, q-wait_pq + cl-level);
 
kfree(cl);
 }
@@ -1370,6 +1384,8 @@ static int htb_change_class(struct Qdisc
 
if (!cl) {  /* new class */
struct Qdisc *new_q;
+   int prio;
+
/* check for valid classid */
if (!classid || TC_H_MAJ(classid ^ sch-handle)
|| htb_find(classid, sch))
@@ -1389,6 +1405,10 @@ static int htb_change_class(struct Qdisc
INIT_HLIST_NODE(cl-hlist);
INIT_LIST_HEAD(cl-children);
INIT_LIST_HEAD(cl-un.leaf.drop_list);
+   RB_CLEAR_NODE(cl-pq_node);
+
+   for (prio = 0; prio  TC_HTB_NUMPRIO; prio++)
+   RB_CLEAR_NODE(cl-node[prio]);
 
/* create leaf qdisc early because it uses kmalloc(GFP_KERNEL)
   so that can't be used inside of sch_tree_lock
@@ -1404,7 +1424,7 @@ static int htb_change_class(struct Qdisc
 
/* remove from evt list because of level change */
if (parent-cmode != HTB_CAN_SEND) {
-   rb_erase(parent-pq_node, q-wait_pq);
+   htb_safe_rb_erase(parent-pq_node, q-wait_pq);
parent-cmode = HTB_CAN_SEND;
}
parent-level = (parent-parent ? parent-parent-level
-- 
1.4.0

___
LARTC mailing list
LARTC@mailman.ds9a.nl

Re: [LARTC] iptables u32 kernel 2.6.17

2006-08-02 Thread Torsten Luettgert
On Wed, 2006-08-02 at 23:30 +0200, Piotr Chytla wrote:

 apply also patch from attachment. 2.6.17 needs matchsize in ipt_match struct.

Whoopsie. I missed that in the patch I sent to netfilter-devel a while
ago.
Thanks for doing it yourself.

Regards,
Torsten

___
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc