# # include/linux/pkt_sched.h | 5 +++-- # include/net/sch_generic.h | 15 +++++++++++++++ # net/sched/act_police.c | 4 ++-- # net/sched/sch_cbq.c | 2 +- # net/sched/sch_htb.c | 9 ++++----- # net/sched/sch_tbf.c | 4 ++-- # 6 files changed, 27 insertions(+), 12 deletions(-) # --- linux-2.6.22/include/linux/pkt_sched.h.bak 2007-07-09 21:58:23.559346000 +0300 +++ linux-2.6.22/include/linux/pkt_sched.h 2007-07-18 21:46:00.084770053 +0300 @@ -77,8 +77,9 @@ struct tc_ratespec { unsigned char cell_log; unsigned char __reserved; - unsigned short feature; - short addend; + unsigned short feature; /* Always 0 in pre-atm patch kernels */ + char cell_align; /* Always 0 in pre-atm patch kernels */ + unsigned char __reserved2; unsigned short mpu; __u32 rate; }; --- linux-2.6.22/include/net/sch_generic.h.bak 2007-07-09 02:32:17.000000000 +0300 +++ linux-2.6.22/include/net/sch_generic.h 2007-07-18 21:44:40.024580754 +0300 @@ -302,4 +302,19 @@ drop: return NET_XMIT_DROP; } +/* Lookup a qdisc_rate_table to determine how long it will take to send a + * packet given its size. + */ +static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, int pktlen) +{ + int slot = pktlen + rtab->rate.cell_align; + + if (slot < 0) + slot = 0; + slot >>= rtab->rate.cell_log; + if (slot > 255) + return rtab->data[255] + 1; + return rtab->data[slot]; +} + #endif --- linux-2.6.22/net/sched/act_police.c.bak 2007-07-09 02:32:17.000000000 +0300 +++ linux-2.6.22/net/sched/act_police.c 2007-07-18 21:42:49.275936447 +0300 @@ -32,8 +32,8 @@ #include #include -#define L2T(p,L) ((p)->tcfp_R_tab->data[(L)>>(p)->tcfp_R_tab->rate.cell_log]) -#define L2T_P(p,L) ((p)->tcfp_P_tab->data[(L)>>(p)->tcfp_P_tab->rate.cell_log]) +#define L2T(p,L) qdisc_l2t((p)->tcfp_R_tab,L) +#define L2T_P(p,L) qdisc_l2t((p)->tcfp_P_tab,L) #define POL_TAB_MASK 15 static struct tcf_common *tcf_police_ht[POL_TAB_MASK + 1]; --- linux-2.6.22/net/sched/sch_cbq.c.bak 2007-07-09 02:32:17.000000000 +0300 +++ linux-2.6.22/net/sched/sch_cbq.c 2007-07-18 21:51:12.794420373 +0300 @@ -192,7 +192,7 @@ struct cbq_sched_data }; -#define L2T(cl,len) ((cl)->R_tab->data[(len)>>(cl)->R_tab->rate.cell_log]) +#define L2T(cl,len) qdisc_l2t((cl)->R_tab,len) static __inline__ unsigned cbq_hash(u32 h) --- linux-2.6.22/net/sched/sch_htb.c.bak 2007-07-09 21:17:53.417438000 +0300 +++ linux-2.6.22/net/sched/sch_htb.c 2007-07-18 21:50:08.602465126 +0300 @@ -157,12 +157,11 @@ struct htb_class { static inline long L2T(struct htb_class *cl, struct qdisc_rate_table *rate, int size) { - int slot = size >> rate->rate.cell_log; - if (slot > 255) { + long result = qdisc_l2t(rate, size); + + if (result > rate->data[255]) cl->xstats.giants++; - slot = 255; - } - return rate->data[slot]; + return result; } struct htb_sched { --- linux-2.6.22/net/sched/sch_tbf.c.bak 2007-07-09 02:32:17.000000000 +0300 +++ linux-2.6.22/net/sched/sch_tbf.c 2007-07-18 21:52:10.665281840 +0300 @@ -132,8 +132,8 @@ struct tbf_sched_data struct qdisc_watchdog watchdog; /* Watchdog timer */ }; -#define L2T(q,L) ((q)->R_tab->data[(L)>>(q)->R_tab->rate.cell_log]) -#define L2T_P(q,L) ((q)->P_tab->data[(L)>>(q)->P_tab->rate.cell_log]) +#define L2T(q,L) qdisc_l2t((q)->R_tab,L) +#define L2T_P(q,L) qdisc_l2t((q)->P_tab,L) static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch) {