SOURCES (LINUX_2_6): esfq-kernel.patch - updated to version for 2....

zbyniu zbyniu at pld-linux.org
Mon Aug 13 02:18:39 CEST 2007


Author: zbyniu                       Date: Mon Aug 13 00:18:39 2007 GMT
Module: SOURCES                       Tag: LINUX_2_6
---- Log message:
- updated to version for 2.6.21.5

---- Files affected:
SOURCES:
   esfq-kernel.patch (1.1.2.5 -> 1.1.2.6) 

---- Diffs:

================================================================
Index: SOURCES/esfq-kernel.patch
diff -u SOURCES/esfq-kernel.patch:1.1.2.5 SOURCES/esfq-kernel.patch:1.1.2.6
--- SOURCES/esfq-kernel.patch:1.1.2.5	Mon Apr 30 12:11:31 2007
+++ SOURCES/esfq-kernel.patch	Mon Aug 13 02:18:34 2007
@@ -1,12 +1,12 @@
-diff -Naur linux-2.6.13.3.old/include/linux/pkt_sched.h linux-2.6.13.3/include/linux/pkt_sched.h
---- linux-2.6.13.3.old/include/linux/pkt_sched.h	2005-10-23 17:39:16.000000000 -0700
-+++ linux-2.6.13.3/include/linux/pkt_sched.h	2005-10-21 18:13:37.000000000 -0700
-@@ -145,8 +145,35 @@
+diff -Naur linux-2.6.21.5.orig/include/linux/pkt_sched.h linux-2.6.21.5/include/linux/pkt_sched.h
+--- linux-2.6.21.5.orig/include/linux/pkt_sched.h	2007-06-11 11:37:06.000000000 -0700
++++ linux-2.6.21.5/include/linux/pkt_sched.h	2007-06-22 22:53:46.000000000 -0700
+@@ -146,8 +146,37 @@
   *
   *	The only reason for this is efficiency, it is possible
   *	to change these parameters in compile time.
 + *	
-+ *	If you need to play with these values use esfq instead.
++ *	If you need to play with these values, use esfq instead.
   */
  
 +/* ESFQ section */
@@ -18,10 +18,12 @@
 +	TCA_SFQ_HASH_DST,
 +	TCA_SFQ_HASH_SRC,
 +	TCA_SFQ_HASH_FWMARK,
-+        /* direct */
-+	TCA_SFQ_HASH_DSTDIR,
-+	TCA_SFQ_HASH_SRCDIR,
-+	TCA_SFQ_HASH_FWMARKDIR,
++	/* conntrack */
++	TCA_SFQ_HASH_CTORIGDST,
++	TCA_SFQ_HASH_CTORIGSRC,
++	TCA_SFQ_HASH_CTREPLDST,
++	TCA_SFQ_HASH_CTREPLSRC,
++	TCA_SFQ_HASH_CTNATCHG,
 +};
 +
 +struct tc_esfq_qopt
@@ -37,41 +39,50 @@
  /* RED section */
  
  enum
-diff -Naur linux-2.6.13.3.old/net/sched/Kconfig linux-2.6.13.3/net/sched/Kconfig
---- linux-2.6.13.3.old/net/sched/Kconfig	2005-10-23 17:39:16.000000000 -0700
-+++ linux-2.6.13.3/net/sched/Kconfig	2005-10-09 16:56:27.000000000 -0700
-@@ -191,6 +191,28 @@
+diff -Naur linux-2.6.21.5.orig/net/sched/Kconfig linux-2.6.21.5/net/sched/Kconfig
+--- linux-2.6.21.5.orig/net/sched/Kconfig	2007-06-11 11:37:06.000000000 -0700
++++ linux-2.6.21.5/net/sched/Kconfig	2007-06-23 14:11:02.000000000 -0700
+@@ -189,6 +189,37 @@
  	  To compile this code as a module, choose M here: the
  	  module will be called sch_sfq.
  
 +config NET_SCH_ESFQ
-+	tristate "ESFQ queue"
-+	depends on NET_SCHED
++	tristate "Enhanced Stochastic Fairness Queueing (ESFQ)"
 +	---help---
 +	  Say Y here if you want to use the Enhanced Stochastic Fairness
 +	  Queueing (ESFQ) packet scheduling algorithm for some of your network
 +	  devices or as a leaf discipline for a classful qdisc such as HTB or
 +	  CBQ (see the top of <file:net/sched/sch_esfq.c> for details and
 +	  references to the SFQ algorithm).
-+	  
++
 +	  This is an enchanced SFQ version which allows you to control some
-+	  hardcoded values in the SFQ scheduler: queue depth, hash table size,
-+	  and queues limit.
-+	  
-+	  ESFQ also adds control to the hash function used to identify packet
-+	  flows. The original SFQ hashes by individual flow (TCP session or UDP
-+	  stream); ESFQ can hash by src or dst IP as well, which can be more
-+	  fair to users in some networking situations.
++	  hardcoded values in the SFQ scheduler.
++
++	  ESFQ also adds control of the hash function used to identify packet
++	  flows. The original SFQ discipline hashes by connection; ESFQ add
++	  several other hashing methods, such as by src IP or by dst IP, which
++	  can be more fair to users in some networking situations.
 +	  
 +	  To compile this code as a module, choose M here: the
 +	  module will be called sch_esfq.
 +
++config NET_SCH_ESFQ_NFCT
++	bool "Connection Tracking Hash Types"
++	depends on NET_SCH_ESFQ && NF_CONNTRACK
++	---help---
++	  Say Y here to enable support for hashing based on netfilter connection
++	  tracking information. This is useful for a router that is also using
++	  NAT to connect privately-addressed hosts to the Internet. If you want
++	  to provide fair distribution of upstream bandwidth, ESFQ must use
++	  connection tracking information, since all outgoing packets will share
++	  the same source address.
++
  config NET_SCH_TEQL
- 	tristate "TEQL queue"
- 	depends on NET_SCHED
-diff -Naur linux-2.6.13.3.old/net/sched/Makefile linux-2.6.13.3/net/sched/Makefile
---- linux-2.6.13.3.old/net/sched/Makefile	2005-10-23 17:39:16.000000000 -0700
-+++ linux-2.6.13.3/net/sched/Makefile	2005-10-09 16:56:27.000000000 -0700
+ 	tristate "True Link Equalizer (TEQL)"
+ 	---help---
+diff -Naur linux-2.6.21.5.orig/net/sched/Makefile linux-2.6.21.5/net/sched/Makefile
+--- linux-2.6.21.5.orig/net/sched/Makefile	2007-06-11 11:37:06.000000000 -0700
++++ linux-2.6.21.5/net/sched/Makefile	2007-06-22 22:53:46.000000000 -0700
 @@ -23,6 +23,7 @@
  obj-$(CONFIG_NET_SCH_INGRESS)	+= sch_ingress.o 
  obj-$(CONFIG_NET_SCH_DSMARK)	+= sch_dsmark.o
@@ -80,10 +91,10 @@
  obj-$(CONFIG_NET_SCH_TBF)	+= sch_tbf.o
  obj-$(CONFIG_NET_SCH_TEQL)	+= sch_teql.o
  obj-$(CONFIG_NET_SCH_PRIO)	+= sch_prio.o
-diff -Naur linux-2.6.13.3.old/net/sched/sch_esfq.c linux-2.6.13.3/net/sched/sch_esfq.c
---- linux-2.6.13.3.old/net/sched/sch_esfq.c	1969-12-31 16:00:00.000000000 -0800
-+++ linux-2.6.13.3/net/sched/sch_esfq.c	2005-10-23 17:32:19.000000000 -0700
-@@ -0,0 +1,639 @@
+diff -Naur linux-2.6.21.5.orig/net/sched/sch_esfq.c linux-2.6.21.5/net/sched/sch_esfq.c
+--- linux-2.6.21.5.orig/net/sched/sch_esfq.c	1969-12-31 16:00:00.000000000 -0800
++++ linux-2.6.21.5/net/sched/sch_esfq.c	2007-06-23 19:18:00.000000000 -0700
+@@ -0,0 +1,702 @@
 +/*
 + * net/sched/sch_esfq.c	Extended Stochastic Fairness Queueing discipline.
 + *
@@ -103,12 +114,12 @@
 + *
 + * 		Corey Hickey, <bugfood-c at fatooh.org>
 + *		Maintenance of the Linux 2.6 port.
-+ *		Added fwmark hash (thanks to Robert Kurjata)
-+ *		Added direct hashing for src, dst, and fwmark.
-+ *		
++ *		Added fwmark hash (thanks to Robert Kurjata).
++ *		Added usage of jhash.
++ *		Added conntrack support.
++ *		Added ctnatchg hash (thanks to Ben Pfountz).
 + */
 +
-+
 +#include <linux/module.h>
 +#include <asm/uaccess.h>
 +#include <asm/system.h>
@@ -135,25 +146,27 @@
 +#include <linux/skbuff.h>
 +#include <net/sock.h>
 +#include <net/pkt_sched.h>
-+
++#include <linux/jhash.h>
++#include <net/netfilter/nf_conntrack.h>
 +
 +/*	Stochastic Fairness Queuing algorithm.
 +	For more comments look at sch_sfq.c.
 +	The difference is that you can change limit, depth,
-+	hash table size and choose 7 hash types.
++	hash table size and choose alternate hash types.
 +	
 +	classic:	same as in sch_sfq.c
 +	dst:		destination IP address
 +	src:		source IP address
-+	fwmark:         netfilter mark value
-+	dst_direct:
-+	src_direct:
-+	fwmark_direct:  direct hashing of the above sources
++	fwmark:		netfilter mark value
++	ctorigdst:	original destination IP address
++	ctorigsrc:	original source IP address
++	ctrepldst:	reply destination IP address
++	ctreplsrc:	reply source IP 
 +	
-+	TODO: 
-+		make sfq_change work.
 +*/
 +
++#define ESFQ_HEAD 0
++#define ESFQ_TAIL 1
 +
 +/* This type should contain at least SFQ_DEPTH*2 values */
 +typedef unsigned int esfq_index;
@@ -185,118 +198,141 @@
 +	unsigned short	*hash;			/* Hash value indexed by slots */
 +	struct sk_buff_head	*qs;		/* Slot queue */
 +	struct esfq_head	*dep;		/* Linked list of slots, indexed by depth */
-+	unsigned	dyn_min;	/* For dynamic divisor adjustment; minimum value seen */
-+	unsigned	dyn_max;	/*                                 maximum value seen */
-+	unsigned	dyn_range;	/*	        		   saved range */
 +};
 +
-+static __inline__ unsigned esfq_hash_u32(struct esfq_sched_data *q,u32 h)
++/* This contains the info we will hash. */
++struct esfq_packet_info
 +{
-+	int pert = q->perturbation;
-+
-+	if (pert)
-+		h = (h<<pert) ^ (h>>(0x1F - pert));
++	u32	proto;		/* protocol or port */
++	u32	src;		/* source from packet header */
++	u32	dst;		/* destination from packet header */
++	u32	ctorigsrc;	/* original source from conntrack */
++	u32	ctorigdst;	/* original destination from conntrack */
++	u32	ctreplsrc;	/* reply source from conntrack */
++	u32	ctrepldst;	/* reply destination from conntrack */
++	u32	mark;		/* netfilter mark (fwmark) */
++};
 +
-+	h = ntohl(h) * 2654435761UL;
-+	return h & (q->hash_divisor-1);
++static __inline__ unsigned esfq_jhash_1word(struct esfq_sched_data *q,u32 a)
++{
++	return jhash_1word(a, q->perturbation) & (q->hash_divisor-1);
 +}
 +
-+/* Hash input values directly into the "nearest" slot, taking into account the
-+ * range of input values seen. This is most useful when the hash table is at
-+ * least as large as the range of possible values. */
-+static __inline__ unsigned esfq_hash_direct(struct esfq_sched_data *q, u32 h)
++static __inline__ unsigned esfq_jhash_2words(struct esfq_sched_data *q, u32 a, u32 b)
 +{
-+	/* adjust minimum and maximum */
-+	if (h < q->dyn_min || h > q->dyn_max) {
-+		q->dyn_min = h < q->dyn_min ? h : q->dyn_min;
-+		q->dyn_max = h > q->dyn_max ? h : q->dyn_max;
-+	
-+		/* find new range */
-+		if ((q->dyn_range = q->dyn_max - q->dyn_min) >= q->hash_divisor)
-+			printk(KERN_WARNING "ESFQ: (direct hash) Input range %u is larger than hash "
-+					"table. See ESFQ README for details.\n", q->dyn_range);
-+	}
-+	
-+	/* hash input values into slot numbers */
-+	if (q->dyn_min == q->dyn_max)
-+		return 0; /* only one value seen; avoid division by 0 */
-+	else
-+		return (h - q->dyn_min) * (q->hash_divisor - 1) / q->dyn_range;
++	return jhash_2words(a, b, q->perturbation) & (q->hash_divisor-1);
 +}
 +
-+static __inline__ unsigned esfq_fold_hash_classic(struct esfq_sched_data *q, u32 h, u32 h1)
++static __inline__ unsigned esfq_jhash_3words(struct esfq_sched_data *q, u32 a, u32 b, u32 c)
 +{
-+	int pert = q->perturbation;
-+
-+	/* Have we any rotation primitives? If not, WHY? */
-+	h ^= (h1<<pert) ^ (h1>>(0x1F - pert));
-+	h ^= h>>10;
-+	return h & (q->hash_divisor-1);
++	return jhash_3words(a, b, c, q->perturbation) & (q->hash_divisor-1);
 +}
 +
 +static unsigned esfq_hash(struct esfq_sched_data *q, struct sk_buff *skb)
 +{
-+	u32 h, h2;
-+	u32 hs;
-+	u32 nfm;
-+
++	struct esfq_packet_info info;
++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
++	enum ip_conntrack_info ctinfo;
++	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
++#endif
++	
 +	switch (skb->protocol) {
 +	case __constant_htons(ETH_P_IP):
 +	{
 +		struct iphdr *iph = skb->nh.iph;
-+		h = iph->daddr;
-+		hs = iph->saddr;
-+		nfm = skb->mark;
-+		h2 = hs^iph->protocol;
++		info.dst = iph->daddr;
++		info.src = iph->saddr;
 +		if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
 +		    (iph->protocol == IPPROTO_TCP ||
 +		     iph->protocol == IPPROTO_UDP ||
++		     iph->protocol == IPPROTO_SCTP ||
++		     iph->protocol == IPPROTO_DCCP ||
 +		     iph->protocol == IPPROTO_ESP))
-+			h2 ^= *(((u32*)iph) + iph->ihl);
++			info.proto = *(((u32*)iph) + iph->ihl);
++		else
++			info.proto = iph->protocol;
 +		break;
 +	}
 +	case __constant_htons(ETH_P_IPV6):
 +	{
 +		struct ipv6hdr *iph = skb->nh.ipv6h;
-+		h = iph->daddr.s6_addr32[3];
-+		hs = iph->saddr.s6_addr32[3];
-+		nfm = skb->mark;
-+		h2 = hs^iph->nexthdr;
++		/* Hash ipv6 addresses into a u32. This isn't ideal,
++		 * but the code is simple. */
++		info.dst = jhash2(iph->daddr.s6_addr32, 4, q->perturbation);
++		info.src = jhash2(iph->saddr.s6_addr32, 4, q->perturbation);
 +		if (iph->nexthdr == IPPROTO_TCP ||
 +		    iph->nexthdr == IPPROTO_UDP ||
++		    iph->nexthdr == IPPROTO_SCTP ||
++		    iph->nexthdr == IPPROTO_DCCP ||
 +		    iph->nexthdr == IPPROTO_ESP)
-+			h2 ^= *(u32*)&iph[1];
++			info.proto = *(u32*)&iph[1];
++		else
++			info.proto = iph->nexthdr;
 +		break;
 +	}
 +	default:
-+		h = (u32)(unsigned long)skb->dst;
-+		hs = (u32)(unsigned long)skb->sk;
-+		nfm = skb->mark;
-+		h2 = hs^skb->protocol;
++		info.dst   = (u32)(unsigned long)skb->dst;
++		info.src   = (u32)(unsigned long)skb->sk;
++		info.proto = skb->protocol;
++	}
++
++	info.mark = skb->mark;
++
++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
++	/* defaults if there is no conntrack info */
++	info.ctorigsrc = info.src;
++	info.ctorigdst = info.dst;
++	info.ctreplsrc = info.dst;
++	info.ctrepldst = info.src;
++	/* collect conntrack info */
++	if (ct && ct != &nf_conntrack_untracked) {
++		if (skb->protocol == __constant_htons(ETH_P_IP)) {
++			info.ctorigsrc = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++			info.ctorigdst = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
++			info.ctreplsrc = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
++			info.ctrepldst = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
++		}
++		else if (skb->protocol == __constant_htons(ETH_P_IPV6)) {
++			/* Again, hash ipv6 addresses into a single u32. */
++			info.ctorigsrc = jhash2(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip6, 4, q->perturbation);
++			info.ctorigdst = jhash2(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip6, 4, q->perturbation);
++			info.ctreplsrc = jhash2(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip6, 4, q->perturbation);
++			info.ctrepldst = jhash2(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip6, 4, q->perturbation);
++		}
++
 +	}
-+	switch(q->hash_kind)
-+	{
++#endif
++
++	switch(q->hash_kind) {
 +	case TCA_SFQ_HASH_CLASSIC:
-+		return esfq_fold_hash_classic(q, h, h2);
++		return esfq_jhash_3words(q, info.dst, info.src, info.proto);
 +	case TCA_SFQ_HASH_DST:
-+		return esfq_hash_u32(q,h);
-+	case TCA_SFQ_HASH_DSTDIR:
-+		return esfq_hash_direct(q, ntohl(h));
++		return esfq_jhash_1word(q, info.dst);
 +	case TCA_SFQ_HASH_SRC:
-+		return esfq_hash_u32(q,hs);
-+	case TCA_SFQ_HASH_SRCDIR:
-+		return esfq_hash_direct(q, ntohl(hs));
-+#ifdef CONFIG_NETFILTER
++		return esfq_jhash_1word(q, info.src);
 +	case TCA_SFQ_HASH_FWMARK:
-+		return esfq_hash_u32(q,nfm);
-+	case TCA_SFQ_HASH_FWMARKDIR:
-+		return esfq_hash_direct(q,nfm);
++		return esfq_jhash_1word(q, info.mark);
++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
++	case TCA_SFQ_HASH_CTORIGDST:
++		return esfq_jhash_1word(q, info.ctorigdst);
++	case TCA_SFQ_HASH_CTORIGSRC:
++		return esfq_jhash_1word(q, info.ctorigsrc);
++	case TCA_SFQ_HASH_CTREPLDST:
++		return esfq_jhash_1word(q, info.ctrepldst);
++	case TCA_SFQ_HASH_CTREPLSRC:
++		return esfq_jhash_1word(q, info.ctreplsrc);
++	case TCA_SFQ_HASH_CTNATCHG:
++	{
++		if (info.ctorigdst == info.ctreplsrc)
++			return esfq_jhash_1word(q, info.ctorigsrc);
++		return esfq_jhash_1word(q, info.ctreplsrc);
++	}
 +#endif
 +	default:
 +		if (net_ratelimit())
 +			printk(KERN_WARNING "ESFQ: Unknown hash method. Falling back to classic.\n");
 +	}
-+	return esfq_fold_hash_classic(q, h, h2);
++	return esfq_jhash_3words(q, info.dst, info.src, info.proto);
 +}
 +
 +static inline void esfq_link(struct esfq_sched_data *q, esfq_index x)
@@ -361,6 +397,7 @@
 +		esfq_dec(q, x);
 +		sch->q.qlen--;
 +		sch->qstats.drops++;
++		sch->qstats.backlog -= len;
 +		return len;
 +	}
 +
@@ -377,16 +414,15 @@
 +		sch->q.qlen--;
 +		q->ht[q->hash[d]] = q->depth;
 +		sch->qstats.drops++;
++		sch->qstats.backlog -= len;
 +		return len;
 +	}
 +
 +	return 0;
 +}
 +
-+static int
-+esfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
++static void esfq_q_enqueue(struct sk_buff *skb, struct esfq_sched_data *q, unsigned int end)
 +{
-+	struct esfq_sched_data *q = qdisc_priv(sch);
 +	unsigned hash = esfq_hash(q, skb);
 +	unsigned depth = q->depth;
 +	esfq_index x;
@@ -396,7 +432,12 @@
 +		q->ht[hash] = x = q->dep[depth].next;
 +		q->hash[x] = hash;
 +	}
-+	__skb_queue_tail(&q->qs[x], skb);
++
++	if (end == ESFQ_TAIL)
++		__skb_queue_tail(&q->qs[x], skb);
++	else
++		__skb_queue_head(&q->qs[x], skb);
++
 +	esfq_inc(q, x);
 +	if (q->qs[x].qlen == 1) {		/* The flow is new */
 +		if (q->tail == depth) {	/* It is the first flow */
@@ -409,42 +450,30 @@
 +			q->tail = x;
 +		}
 +	}
++}
++
++static int esfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
++{
++	struct esfq_sched_data *q = qdisc_priv(sch);
++	esfq_q_enqueue(skb, q, ESFQ_TAIL);
++	sch->qstats.backlog += skb->len;
 +	if (++sch->q.qlen < q->limit-1) {
 +		sch->bstats.bytes += skb->len;
 +		sch->bstats.packets++;
 +		return 0;
 +	}
 +
++	sch->qstats.drops++;
 +	esfq_drop(sch);
 +	return NET_XMIT_CN;
 +}
 +
-+static int
-+esfq_requeue(struct sk_buff *skb, struct Qdisc* sch)
++
++static int esfq_requeue(struct sk_buff *skb, struct Qdisc* sch)
 +{
 +	struct esfq_sched_data *q = qdisc_priv(sch);
-+	unsigned hash = esfq_hash(q, skb);
-+	unsigned depth = q->depth;
-+	esfq_index x;
-+
-+	x = q->ht[hash];
-+	if (x == depth) {
-+		q->ht[hash] = x = q->dep[depth].next;
-+		q->hash[x] = hash;
-+	}
-+	__skb_queue_head(&q->qs[x], skb);
-+	esfq_inc(q, x);
-+	if (q->qs[x].qlen == 1) {		/* The flow is new */
-+		if (q->tail == depth) {	/* It is the first flow */
-+			q->tail = x;
-+			q->next[x] = x;
-+			q->allot[x] = q->quantum;
-+		} else {
-+			q->next[x] = q->next[q->tail];
-+			q->next[q->tail] = x;
-+			q->tail = x;
-+		}
-+	}
++	esfq_q_enqueue(skb, q, ESFQ_HEAD);
++	sch->qstats.backlog += skb->len;
 +	if (++sch->q.qlen < q->limit - 1) {
 +		sch->qstats.requeues++;
 +		return 0;
@@ -455,13 +484,8 @@
 +	return NET_XMIT_CN;
 +}
 +
-+
-+
-+
-+static struct sk_buff *
-+esfq_dequeue(struct Qdisc* sch)
++static struct sk_buff *esfq_q_dequeue(struct esfq_sched_data *q)
 +{
-+	struct esfq_sched_data *q = qdisc_priv(sch);
 +	struct sk_buff *skb;
 +	unsigned depth = q->depth;
 +	esfq_index a, old_a;
@@ -475,7 +499,6 @@
 +	/* Grab packet */
 +	skb = __skb_dequeue(&q->qs[a]);
 +	esfq_dec(q, a);
-+	sch->q.qlen--;
 +	
 +	/* Is the slot empty? */
 +	if (q->qs[a].qlen == 0) {
@@ -496,8 +519,44 @@
 +	return skb;
 +}
 +
-+static void
-+esfq_reset(struct Qdisc* sch)
++static struct sk_buff *esfq_dequeue(struct Qdisc* sch)
++{
++	struct esfq_sched_data *q = qdisc_priv(sch);
++	struct sk_buff *skb;
++
++	skb = esfq_q_dequeue(q);
++	if (skb == NULL)
++		return NULL;
++	sch->q.qlen--;
++	sch->qstats.backlog -= skb->len;
++	return skb;
++}
++
++static void esfq_q_destroy(struct esfq_sched_data *q)
++{
++	del_timer(&q->perturb_timer);
++	if(q->ht)
++		kfree(q->ht);
++	if(q->dep)
++		kfree(q->dep);
++	if(q->next)
++		kfree(q->next);
++	if(q->allot)
++		kfree(q->allot);
++	if(q->hash)
++		kfree(q->hash);
++	if(q->qs)
++		kfree(q->qs);
++}
++
++static void esfq_destroy(struct Qdisc *sch)
++{
++	struct esfq_sched_data *q = qdisc_priv(sch);
++	esfq_q_destroy(q);
++}
++
++
++static void esfq_reset(struct Qdisc* sch)
 +{
 +	struct sk_buff *skb;
 +
@@ -518,73 +577,56 @@
 +	}
 +}
 +
-+static int esfq_change(struct Qdisc *sch, struct rtattr *opt)
++static unsigned int esfq_check_hash(unsigned int kind)
 +{
-+	struct esfq_sched_data *q = qdisc_priv(sch);
-+	struct tc_esfq_qopt *ctl = RTA_DATA(opt);
-+	int old_perturb = q->perturb_period;
-+	
-+	if (opt->rta_len < RTA_LENGTH(sizeof(*ctl)))
-+		return -EINVAL;
-+	
-+	sch_tree_lock(sch);
-+	q->quantum = ctl->quantum ? : psched_mtu(sch->dev);
-+	q->perturb_period = ctl->perturb_period*HZ;
-+//	q->hash_divisor = ctl->divisor;
-+//	q->tail = q->limit = q->depth = ctl->flows;
-+	
-+	if (ctl->limit)
-+		q->limit = min_t(u32, ctl->limit, q->depth);
-+	
-+	if (ctl->hash_kind) {
-+		q->hash_kind = ctl->hash_kind;
-+		if (q->hash_kind !=  TCA_SFQ_HASH_CLASSIC)
-+			q->perturb_period = 0;
-+	}
-+	
-+	// is sch_tree_lock enough to do this ?
-+	while (sch->q.qlen >= q->limit-1)
-+		esfq_drop(sch);
-+	
-+	if (old_perturb)
-+		del_timer(&q->perturb_timer);
-+	if (q->perturb_period) {
-+		q->perturb_timer.expires = jiffies + q->perturb_period;
-+		add_timer(&q->perturb_timer);
-+	} else {
-+		q->perturbation = 0;
++	switch (kind) {
++	case TCA_SFQ_HASH_CTORIGDST:
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/esfq-kernel.patch?r1=1.1.2.5&r2=1.1.2.6&f=u



More information about the pld-cvs-commit mailing list