if ( table->initd && table->grio) { /* this looks ugly but it's not in the fast path */ for (i=0;i<table->DPs;i++) { if ((!table->tab[i]) || (i==q->DP) ) continue; if (table->tab[i]->prio == q->prio ){ /* WRED mode detected */ table->eqp=1; break; } } 
if (table->grio) { gred_disable_wred_mode(table); if (gred_wred_mode_check(sch)) gred_enable_wred_mode(table); 
static int gred_change(struct Qdisc *sch, struct rtattr *opt){	struct gred_sched *table = qdisc_priv(sch);	struct gred_sched_data *q;	struct tc_gred_qopt *ctl;	struct tc_gred_sopt *sopt;	struct rtattr *tb[TCA_GRED_STAB];	struct rtattr *tb2[TCA_GRED_DPS];	int i;	if (opt == NULL || rtattr_parse_nested(tb, TCA_GRED_STAB, opt))		return -EINVAL;	if (tb[TCA_GRED_PARMS-1] == 0 && tb[TCA_GRED_STAB-1] == 0) {		rtattr_parse_nested(tb2, TCA_GRED_DPS, opt);	    if (tb2[TCA_GRED_DPS-1] == 0) 			return -EINVAL;		sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]);		table->DPs=sopt->DPs;   		table->def=sopt->def_DP; 		table->grio=sopt->grio; 		table->initd=0;		/* probably need to clear all the table DP entries as well */		return 0;	    }	if (!table->DPs || tb[TCA_GRED_PARMS-1] == 0 || tb[TCA_GRED_STAB-1] == 0 ||		RTA_PAYLOAD(tb[TCA_GRED_PARMS-1]) < sizeof(*ctl) ||		RTA_PAYLOAD(tb[TCA_GRED_STAB-1]) < 256)			return -EINVAL;	ctl = RTA_DATA(tb[TCA_GRED_PARMS-1]);	if (ctl->DP > MAX_DPs-1 ) {		/* misbehaving is punished! Put in the default drop probability */		DPRINTK("\nGRED: DP %u not in  the proper range fixed. New DP "			"set to default at %d\n",ctl->DP,table->def);		ctl->DP=table->def;	}		if (table->tab[ctl->DP] == NULL) {		table->tab[ctl->DP]=kmalloc(sizeof(struct gred_sched_data),					    GFP_KERNEL);		if (NULL == table->tab[ctl->DP])			return -ENOMEM;		memset(table->tab[ctl->DP], 0, (sizeof(struct gred_sched_data)));	}	q= table->tab[ctl->DP]; 	if (table->grio) {		if (ctl->prio <=0) {			if (table->def && table->tab[table->def]) {				DPRINTK("\nGRED: DP %u does not have a prio"					"setting default to %d\n",ctl->DP,					table->tab[table->def]->prio);				q->prio=table->tab[table->def]->prio;			} else { 				DPRINTK("\nGRED: DP %u does not have a prio"					" setting default to 8\n",ctl->DP);				q->prio=8;			}		} else {			q->prio=ctl->prio;		}	} else {		q->prio=8;	}	q->DP=ctl->DP;	q->Wlog = ctl->Wlog;	q->Plog = ctl->Plog;	q->limit = ctl->limit;	q->Scell_log = ctl->Scell_log;	q->Rmask = ctl->Plog < 32 ? ((1<<ctl->Plog) - 1) : ~0UL;	q->Scell_max = (255<<q->Scell_log);	q->qth_min = ctl->qth_min<<ctl->Wlog;	q->qth_max = ctl->qth_max<<ctl->Wlog;	q->qave=0;	q->backlog=0;	q->qcount = -1;	q->other=0;	q->forced=0;	q->pdrop=0;	q->early=0;	PSCHED_SET_PASTPERFECT(q->qidlestart);	memcpy(q->Stab, RTA_DATA(tb[TCA_GRED_STAB-1]), 256);	if ( table->initd && table->grio) {	/* this looks ugly but it's not in the fast path */		for (i=0;i<table->DPs;i++) {			if ((!table->tab[i]) || (i==q->DP) )    				continue; 			if (table->tab[i]->prio == q->prio ){				/* WRED mode detected */				table->eqp=1;				break;			}		}	}	if (!table->initd) {		table->initd=1;		/*         	the first entry also goes into the default until        	over-written 		*/		if (table->tab[table->def] == NULL) {			table->tab[table->def]=				kmalloc(sizeof(struct gred_sched_data), GFP_KERNEL);			if (NULL == table->tab[table->def])				return -ENOMEM;			memset(table->tab[table->def], 0,			       (sizeof(struct gred_sched_data)));		}		q= table->tab[table->def]; 		q->DP=table->def;		q->Wlog = ctl->Wlog;		q->Plog = ctl->Plog;		q->limit = ctl->limit;		q->Scell_log = ctl->Scell_log;		q->Rmask = ctl->Plog < 32 ? ((1<<ctl->Plog) - 1) : ~0UL;		q->Scell_max = (255<<q->Scell_log);		q->qth_min = ctl->qth_min<<ctl->Wlog;		q->qth_max = ctl->qth_max<<ctl->Wlog;		if (table->grio)			q->prio=table->tab[ctl->DP]->prio;		else			q->prio=8;		q->qcount = -1;		PSCHED_SET_PASTPERFECT(q->qidlestart);		memcpy(q->Stab, RTA_DATA(tb[TCA_GRED_STAB-1]), 256);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/dea3f62852f98670b72ad355c67bd55c9af58530/sch_gred.c/buggy/net/sched/sch_gred.c