hi every body i wrote a new qdisc called epd as you can seen in the following the code of the two patch i applied the two patch fir linux2.4.17 and tc2.4.17 i recompiled the kernel,the the tc tool when i taped in the consol ''tc qdisc add dev eth0 root handle 1: epd limit 1000 threshold 100'' it work (no error mesage) but when i try to print the stats with ''tc -d qdisc ls dev eth0'' i obtain this ''qdisc epd 1:'' but i have to obtain ''qdisc epd 1: limit 1000 threshold 100'' i don''t understant where the problem is in the sch_epd.c or q_epd.c please, would you like to try it and in there is any suggestion you can send me a mail i thank you in advance -------file epd2-2.4.17.diff-------------------- --- linux-2.4orig/net/sched/Config.in Sun Jan 13 15:10:25 2002 +++ linux-2.4/net/sched/Config.in Sun Jan 13 14:54:48 2002 @@ -2,6 +2,7 @@ # Traffic control configuration. # tristate '' CBQ packet scheduler'' CONFIG_NET_SCH_CBQ +tristate '' EPD packet scheduler'' CONFIG_NET_SCH_EPD tristate '' CSZ packet scheduler'' CONFIG_NET_SCH_CSZ #tristate '' H-PFQ packet scheduler'' CONFIG_NET_SCH_HPFQ #tristate '' H-FSC packet scheduler'' CONFIG_NET_SCH_HFCS --- linux-2.4orig/net/sched/Makefile Mon Oct 15 16:26:22 2001 +++ linux-2.4/net/sched/Makefile Wed Nov 14 13:54:44 2001 @@ -16,6 +16,7 @@ obj-$(CONFIG_NET_SCH_CBQ) +sch_cbq.o obj-$(CONFIG_NET_SCH_CSZ) += sch_csz.o obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o +obj-$(CONFIG_NET_SCH_EPD) += sch_epd.o obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o obj-$(CONFIG_NET_SCH_RED) += sch_red.o obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o --- linux-2.4orig/net/sched/sch_epd.c Sun Oct 21 22:11:45 2001 +++ linux-2.4/net/sched/sch_epd.c Sun Jan 13 15:07:13 2002 @@ -0,0 +1,239 @@ +/* + * net/sched/sch_epd.c Early packet discart +(adaptation for multimedia stream.) + * + * This program is free software; you can redistribute it and/or + * modify it + * Authors: Alouini khalifa <k.alouini@voila.fr> +<powerdr1@yahoo.fr> + */ +#include <linux/config.h> +#include <linux/module.h> +#include <asm/uaccess.h> +#include <asm/system.h> +#include <asm/bitops.h> +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/string.h> +#include <linux/mm.h> +#include <linux/socket.h> +#include <linux/sockios.h> +#include <linux/in.h> +#include <linux/errno.h> +#include <linux/interrupt.h> +#include <linux/if_ether.h> +#include <linux/inet.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/notifier.h> +#include <net/ip.h> +#include <net/route.h> +#include <linux/skbuff.h> +#include <net/sock.h> +#include <net/pkt_sched.h> +#include <net/inet_ecn.h> + +/*Early packet discart (EPD) algorithm. Version 1.0 + ======================================+This discipline is taken from ATM world,this version +is the simplest mode of EPD +In ATM, a packet is divided in many cells,if a new +packet arrive and we reach a +threshold then we have to drop all new data unit +(witch may be divided into many cells) for the reason +that one packet has no signification if some of its +data(cells) are dropped so if we have to reject one +cell of a packet we have +to reject all sells that belongs to this packet (a +packet=data unit) +To adaptate this discipline for multimedia stream, we +market the IP packet +into the IP-OPION field (or TOS field) the number of +data unit at which it belongs then we only have to +extract this information from the IP_OPTION + field (or from TOS fields) + +Short description. +------------------ + +When a new packet arrives we look at the queue length: + + +if (length <threshold) -> packet passed. +if (length >threshold) ->tow possibilitties +if (it is a new data unit) -> packet dropped +if( it is an old data unit) ->packet accepted +if (length =limit) ->packet dropped + + Parameters, settable by user: + ----------------------------- + + limit - bytes + threshold -bytes +*/ + +#define NET_XMIT_DROP 0 +#define NET_XMIT_SUCCESS 1 +struct epd_sched_data +{ +/* Parameters */ +unsigned limit;/* HARD maximal queue length */ +unsigned threshold;/* limit under witch, we drop a new +data unit*/ + +/* Variables */ +unsigned current_unit ;/* the last unit passed into +the queue */ +unsigned dropped_unit; /*the unit that must +be dropped because one packet of this unit was dropped +(it is the number of the last dropped +unit) */ +}; + + +static int +epd_enqueue(struct sk_buff *skb, struct Qdisc* sch) +{ +struct epd_sched_data *q = (struct epd_sched_data +*)sch->data; + unsigned unit=skb->nh.iph->tos; + /*verify if this packet belongs to data unit that is +marked dropped + then we have to drop this packet*/ + if (unit==q->dropped_unit) + goto drop; + if (sch->stats.backlog <= q->threshold) + { +/*if it is a new data unit we have to update the +current_unit value*/ + if (q->current_unit != unit) + q->current_unit=unit; + goto enqueue; + } + else + { + if (unit == q->current_unit) +/*if it is a segment of a data unit that is already +enqueued then we have to enqueue this packet*/ + goto enqueue; + else + { +/*if it is a new unit then apdate the dropped_unit +value*/ + q->dropped_unit=unit; + goto drop; + } + } +drop: + kfree_skb(skb); + sch->stats.drops++; + return NET_XMIT_DROP; + +enqueue: + __skb_queue_tail(&sch->q, skb); + sch->stats.backlog += skb->len; + sch->stats.bytes += skb->len; + sch->stats.packets++; + return NET_XMIT_SUCCESS; +} +static int +epd_requeue(struct sk_buff *skb, struct Qdisc* sch) +{ + __skb_queue_head(&sch->q, skb); + sch->stats.backlog += skb->len; + return 0; +} +static struct sk_buff * +epd_dequeue(struct Qdisc* sch) +{ + struct sk_buff *skb; + + skb = __skb_dequeue(&sch->q); + if (skb) + sch->stats.backlog -= skb->len; + return skb; +} +static int +epd_drop(struct Qdisc* sch) +{ + struct sk_buff *skb; + skb = __skb_dequeue_tail(&sch->q); + if (skb) { + sch->stats.backlog -= skb->len; + sch->stats.drops++; + kfree_skb(skb); + return 1; + } + return 0; +} +static void +epd_reset(struct Qdisc* sch) +{ + skb_queue_purge(&sch->q); + sch->stats.backlog = 0; +} +static int epd_change(struct Qdisc *sch, struct rtattr +*opt) +{ + return 0; +} +static void epd_destroy(struct Qdisc *sch) +{ + MOD_DEC_USE_COUNT; +} + +static int +epd_init(struct Qdisc *sch, struct rtattr *opt) +{ + struct epd_sched_data *q = (void*)sch->data; + if (opt == NULL) { +/* this is the first version ,no default attributes*/ + } + else + { + struct tc_epd_qopt *ctl = RTA_DATA(opt); + if (opt->rta_len < RTA_LENGTH(sizeof(*ctl))) + return -EINVAL; + q->limit = ctl->limit; + q->threshold= ctl->threshold; + q->current_unit=0; + q->dropped_unit=0; + } + return 0; +} + +#ifdef CONFIG_RTNETLINK +static int epd_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct epd_sched_data *q = (void*)sch->data; + unsigned char *b = skb->tail; + struct tc_epd_qopt opt; + + opt.limit = q->limit; + RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); + return skb->len; + +rtattr_failure: + skb_trim(skb, b - skb->data); + return -1; +} +#endif +struct Qdisc_ops epd_qdisc_ops +{ + NULL, + NULL, + "epd", + sizeof(struct epd_sched_data), + + epd_enqueue, + epd_dequeue, + epd_requeue, + epd_drop, + + epd_init, + epd_reset, + epd_destroy, + epd_change, + +#ifdef CONFIG_RTNETLINK + epd_dump, +#endif +}; + + + --- linux-2.4orig/include/linux/pkt_sched.h Mon Feb 28 03:45:10 2000 +++ linux-2.4/include/linux/pkt_sched.h Fri Dec 7 18:06:02 2001 @@ -248,6 +248,13 @@ struct tc_gred_sopt __u8 grio; }; +/* EPD section */ +struct tc_epd_qopt +{ + __u32 limit; + __u32 threshold; +}; + /* CBQ section */ #define TC_CBQ_MAXPRIO 8 --- linux-2.4orig/net/sched/sch_api.c Sun Jan 13 15:10:25 2002 +++ linux-2.4/net/sched/sch_api.c Sun Jan 13 14:54:48 2002 @@ -1205,6 +1205,9 @@ int __init pktsched_init(void) #ifdef CONFIG_NET_SCH_CBQ INIT_QDISC(cbq); #endif +#ifdef CONFIG_NET_SCH_EPD + INIT_QDISC(epd); +#endif #ifdef CONFIG_NET_SCH_CSZ INIT_QDISC(csz); #endif -----------------file epd_tc.diff------------------ --- iproute2/tc/q_epd.c Sun Oct 21 22:07:29 2001 +++ iproute2new/tc/q_epd.c Wed Dec 19 16:51:41 2001 @@ -0,0 +1,97 @@ +/* + * q_epd.c EPD. + * + *This program is free software; you can redistribute +it and/or + *modify as published by the Free Software Foundation; + * + * Authors: Alouini khalifa, +k.alouini@voila.fr;powerdr1@yahoo.fr + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <syslog.h> +#include <fcntl.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> + +#include "utils.h" +#include "tc_util.h" + +static void explain(void) +{ +fprintf(stderr, "Usage: ... epd [limit NUMBER] +[threshold NUMBER]\n"); +} +#define usage() return(-1) +static int epd_parse_opt(struct qdisc_util *qu, int +argc, char **argv, struct nlmsghdr *n) +{ + int ok=0; + struct tc_epd_qopt opt; + memset(&opt, 0, sizeof(opt)); + + while (argc > 0) { + if (strcmp(*argv, "limit") == 0) { + NEXT_ARG(); + if (get_size(&opt.limit, *argv)) { + fprintf(stderr, "Illegal \"limit\"\n"); + return -1; + } + ok++; + } else if (strcmp(*argv, "threshold") == 0) { + NEXT_ARG(); + if (get_size(&opt.threshold, *argv)) { + fprintf(stderr, "Illegal \"threshold\"\n"); + return -1; + } + ok++; + }else if (strcmp(*argv, "help") == 0) +{ + explain(); + return -1; + } else { +fprintf(stderr, "What is \"%s\"?\n", *argv); + explain(); + return -1; + } + argc--; argv++; + } + if (ok) +addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)); + return 0; +} +static int epd_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) +{ + struct tc_fifo_qopt *qopt; + + if (opt == NULL) + return 0; + + if (RTA_PAYLOAD(opt) < sizeof(*qopt)) + return -1; + qopt = RTA_DATA(opt); + SPRINT_BUF(b1); + SPRINT_BUF(b2); +fprintf(f, "limit %s: threshold %s", +sprint_size(qopt->limit,b1),sprint_size(qopt->threshol+d, b2)); + return 0; +} +static int epd_print_xstats(struct qdisc_util *qu, +FILE *f, struct rtattr *xstats) +{ + return 0; +} +struct qdisc_util epd_util = { + NULL, + "epd", + epd_parse_opt, + epd_print_opt, + epd_print_xstats, +}; + + + --- iproute2/tc/Makefile Tue Jul 6 18:13:07 1999 +++ iproute2new/tc/Makefile Sun Nov 19 16:04:00 2000 @@ -21,6 +21,7 @@ ifeq ($(TC_CONFIG_DIFFSERV),y) endif #TCMODULES += q_csz.o +TCMODULES += q_epd.o #TCMODULES += q_hpfq.o #TCMODULES += q_hfsc.o ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com