- kill bzero/bcopy

- defopt stats and settings, removing their definitions from the files
- make code compile by eliminating multicharacter constants!?! and rearranging
  variable declarations so they are defined before used!?!
- help gcc with uninitialized variables
This commit is contained in:
christos 2003-11-09 22:11:12 +00:00
parent 19d60bc09e
commit 2cd9243922
15 changed files with 117 additions and 116 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_afmap.c,v 1.5 2001/11/15 06:37:15 lukem Exp $ */
/* $NetBSD: altq_afmap.c,v 1.6 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_afmap.c,v 1.7 2000/12/14 08:12:45 thorpej Exp $ */
/*
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_afmap.c,v 1.5 2001/11/15 06:37:15 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_afmap.c,v 1.6 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -90,7 +90,7 @@ afm_alloc(ifp)
M_DEVBUF, M_WAITOK);
if (head == NULL)
panic("afm_alloc: malloc failed!");
bzero(head, sizeof(struct afm_head));
(void)memset(head, 0, sizeof(struct afm_head));
/* initialize per interface afmap list */
LIST_INIT(&head->afh_head);
@ -169,11 +169,11 @@ int afm_add(ifp, flowmap)
M_DEVBUF, M_WAITOK);
if (afm == NULL)
return (ENOMEM);
bzero(afm, sizeof(struct afm));
(void)memset(afm, 0, sizeof(struct afm));
afm->afm_vci = flowmap->af_vci;
afm->afm_vpi = flowmap->af_vpi;
bcopy(&flowmap->af_flowinfo, &afm->afm_flowinfo,
(void)memcpy(&afm->afm_flowinfo, &flowmap->af_flowinfo,
flowmap->af_flowinfo.fi_len);
LIST_INSERT_HEAD(&head->afh_head, afm, afm_list);

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_blue.c,v 1.7 2003/10/07 21:22:11 mycroft Exp $ */
/* $NetBSD: altq_blue.c,v 1.8 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_blue.c,v 1.8 2002/01/07 11:25:40 kjc Exp $ */
/*
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_blue.c,v 1.7 2003/10/07 21:22:11 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_blue.c,v 1.8 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -107,7 +107,6 @@ __KERNEL_RCSID(0, "$NetBSD: altq_blue.c,v 1.7 2003/10/07 21:22:11 mycroft Exp $"
#define FP_SHIFT 12 /* fixed-point shift */
#define BLUE_LIMIT 200 /* default max queue lenght */
#define BLUE_STATS /* collect statistics */
/* blue_list keeps all blue_state_t's allocated. */
static blue_queue_t *blue_list = NULL;
@ -212,14 +211,14 @@ blueioctl(dev, cmd, addr, flag, p)
/* allocate and initialize blue_state_t */
MALLOC(rqp, blue_queue_t *, sizeof(blue_queue_t), M_DEVBUF, M_WAITOK);
bzero(rqp, sizeof(blue_queue_t));
(void)memset(rqp, 0, sizeof(blue_queue_t));
MALLOC(rqp->rq_q, class_queue_t *, sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
bzero(rqp->rq_q, sizeof(class_queue_t));
(void)memset(rqp->rq_q, 0, sizeof(class_queue_t));
MALLOC(rqp->rq_blue, blue_t *, sizeof(blue_t), M_DEVBUF, M_WAITOK);
bzero(rqp->rq_blue, sizeof(blue_t));
(void)memset(rqp->rq_blue, 0, sizeof(blue_t));
rqp->rq_ifq = &ifp->if_snd;
qtail(rqp->rq_q) = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_cbq.c,v 1.7 2003/08/20 23:32:25 itojun Exp $ */
/* $NetBSD: altq_cbq.c,v 1.8 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_cbq.c,v 1.11 2002/10/04 14:24:09 kjc Exp $ */
/*
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.7 2003/08/20 23:32:25 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.8 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -620,7 +620,7 @@ cbq_ifattach(ifacep)
MALLOC(new_cbqp, cbq_state_t *, sizeof(cbq_state_t), M_DEVBUF, M_WAITOK);
if (new_cbqp == NULL)
return (ENOMEM);
bzero(new_cbqp, sizeof(cbq_state_t));
(void)memset(new_cbqp, 0, sizeof(cbq_state_t));
CALLOUT_INIT(&new_cbqp->cbq_callout);
MALLOC(new_cbqp->cbq_class_tbl, struct rm_class **,
sizeof(struct rm_class *) * CBQ_MAX_CLASSES, M_DEVBUF, M_WAITOK);
@ -628,7 +628,8 @@ cbq_ifattach(ifacep)
FREE(new_cbqp, M_DEVBUF);
return (ENOMEM);
}
bzero(new_cbqp->cbq_class_tbl, sizeof(struct rm_class *) * CBQ_MAX_CLASSES);
(void)memset(new_cbqp->cbq_class_tbl, 0,
sizeof(struct rm_class *) * CBQ_MAX_CLASSES);
new_cbqp->cbq_qlen = 0;
new_cbqp->ifnp.ifq_ = &ifp->if_snd; /* keep the ifq */

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_cdnr.c,v 1.6 2003/10/07 21:22:11 mycroft Exp $ */
/* $NetBSD: altq_cdnr.c,v 1.7 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_cdnr.c,v 1.8 2000/12/14 08:12:45 thorpej Exp $ */
/*
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_cdnr.c,v 1.6 2003/10/07 21:22:11 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_cdnr.c,v 1.7 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -283,7 +283,7 @@ cdnr_cballoc(top, type, input_func)
MALLOC(cb, struct cdnr_block *, size, M_DEVBUF, M_WAITOK);
if (cb == NULL)
return (NULL);
bzero(cb, size);
(void)memset(cb, 0, size);
cb->cb_len = size;
cb->cb_type = type;
@ -1145,7 +1145,7 @@ cdnrcmd_get_stats(ap)
return (EBADF);
/* copy action stats */
bcopy(top->tc_cnts, ap->cnts, sizeof(ap->cnts));
(void)memcpy(ap->cnts, top->tc_cnts, sizeof(ap->cnts));
/* stats for each element */
nelements = ap->nelements;
@ -1161,7 +1161,7 @@ cdnrcmd_get_stats(ap)
continue;
}
bzero(&tce, sizeof(tce));
(void)memset(&tce, 0, sizeof(tce));
tce.tce_handle = cb->cb_handle;
tce.tce_type = cb->cb_type;
switch (cb->cb_type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_fifoq.c,v 1.4 2001/11/12 23:14:21 lukem Exp $ */
/* $NetBSD: altq_fifoq.c,v 1.5 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_fifoq.c,v 1.7 2000/12/14 08:12:45 thorpej Exp $ */
/*
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_fifoq.c,v 1.4 2001/11/12 23:14:21 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_fifoq.c,v 1.5 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -60,8 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: altq_fifoq.c,v 1.4 2001/11/12 23:14:21 lukem Exp $")
#include <altq/altq_conf.h>
#include <altq/altq_fifoq.h>
#define FIFOQ_STATS /* collect statistics */
/* fifoq_list keeps all fifoq_state_t's allocated. */
static fifoq_state_t *fifoq_list = NULL;
@ -181,7 +179,7 @@ fifoqioctl(dev, cmd, addr, flag, p)
error = ENOMEM;
break;
}
bzero(q, sizeof(fifoq_state_t));
(void)memset(q, 0, sizeof(fifoq_state_t));
q->q_ifq = &ifp->if_snd;
q->q_head = q->q_tail = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_hfsc.c,v 1.7 2003/01/06 03:44:23 christos Exp $ */
/* $NetBSD: altq_hfsc.c,v 1.8 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_hfsc.c,v 1.9 2001/10/26 04:56:11 kjc Exp $ */
/*
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.7 2003/01/06 03:44:23 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.8 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -169,7 +169,7 @@ hfsc_attach(ifq, bandwidth)
M_DEVBUF, M_WAITOK);
if (hif == NULL)
return (NULL);
bzero(hif, sizeof(struct hfsc_if));
(void)memset(hif, 0, sizeof(struct hfsc_if));
hif->hif_eligible = ellist_alloc();
if (hif->hif_eligible == NULL) {
@ -307,13 +307,13 @@ hfsc_class_create(hif, sc, parent, qlimit, flags)
M_DEVBUF, M_WAITOK);
if (cl == NULL)
return (NULL);
bzero(cl, sizeof(struct hfsc_class));
(void)memset(cl, 0, sizeof(struct hfsc_class));
MALLOC(cl->cl_q, class_queue_t *, sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
if (cl->cl_q == NULL)
goto err_ret;
bzero(cl->cl_q, sizeof(class_queue_t));
(void)memset(cl->cl_q, 0, sizeof(class_queue_t));
cl->cl_actc = actlist_alloc();
if (cl->cl_actc == NULL)
@ -363,7 +363,7 @@ hfsc_class_create(hif, sc, parent, qlimit, flags)
sizeof(struct internal_sc), M_DEVBUF, M_WAITOK);
if (cl->cl_rsc == NULL)
goto err_ret;
bzero(cl->cl_rsc, sizeof(struct internal_sc));
(void)memset(cl->cl_rsc, 0, sizeof(struct internal_sc));
sc2isc(sc, cl->cl_rsc);
rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0);
rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0);
@ -372,7 +372,7 @@ hfsc_class_create(hif, sc, parent, qlimit, flags)
sizeof(struct internal_sc), M_DEVBUF, M_WAITOK);
if (cl->cl_fsc == NULL)
goto err_ret;
bzero(cl->cl_fsc, sizeof(struct internal_sc));
(void)memset(cl->cl_fsc, 0, sizeof(struct internal_sc));
sc2isc(sc, cl->cl_fsc);
rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0);
}
@ -496,14 +496,18 @@ hfsc_class_modify(cl, rsc, fsc)
sizeof(struct internal_sc), M_DEVBUF, M_WAITOK);
if (rsc_tmp == NULL)
return (ENOMEM);
}
(void)memset(rsc_tmp, 0, sizeof(struct internal_sc));
} else
rsc_tmp = NULL;
if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0) &&
cl->cl_fsc == NULL) {
MALLOC(fsc_tmp, struct internal_sc *,
sizeof(struct internal_sc), M_DEVBUF, M_WAITOK);
if (fsc_tmp == NULL)
return (ENOMEM);
}
(void)memset(fsc_tmp, 0, sizeof(struct internal_sc));
} else
fsc_tmp = NULL;
s = splnet();
if (!qempty(cl->cl_q))
@ -518,7 +522,6 @@ hfsc_class_modify(cl, rsc, fsc)
} else {
if (cl->cl_rsc == NULL)
cl->cl_rsc = rsc_tmp;
bzero(cl->cl_rsc, sizeof(struct internal_sc));
sc2isc(rsc, cl->cl_rsc);
rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0);
rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0);
@ -534,7 +537,6 @@ hfsc_class_modify(cl, rsc, fsc)
} else {
if (cl->cl_fsc == NULL)
cl->cl_fsc = fsc_tmp;
bzero(cl->cl_fsc, sizeof(struct internal_sc));
sc2isc(fsc, cl->cl_fsc);
rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_priq.c,v 1.6 2003/01/06 03:44:24 christos Exp $ */
/* $NetBSD: altq_priq.c,v 1.7 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_priq.c,v 1.2 2001/10/26 04:56:11 kjc Exp $ */
/*
* Copyright (C) 2000
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.6 2003/01/06 03:44:24 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.7 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -112,7 +112,7 @@ priq_attach(ifq, bandwidth)
M_DEVBUF, M_WAITOK);
if (pif == NULL)
return (NULL);
bzero(pif, sizeof(struct priq_if));
(void)memset(pif, 0, sizeof(struct priq_if));
pif->pif_bandwidth = bandwidth;
pif->pif_maxpri = -1;
pif->pif_ifq = ifq;
@ -236,13 +236,13 @@ priq_class_create(pif, pri, qlimit, flags)
M_DEVBUF, M_WAITOK);
if (cl == NULL)
return (NULL);
bzero(cl, sizeof(struct priq_class));
(void)memset(cl, 0, sizeof(struct priq_class));
MALLOC(cl->cl_q, class_queue_t *, sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
if (cl->cl_q == NULL)
goto err_ret;
bzero(cl->cl_q, sizeof(class_queue_t));
(void)memset(cl->cl_q, 0, sizeof(class_queue_t));
}
pif->pif_classes[pri] = cl;
@ -798,7 +798,7 @@ priqcmd_class_stats(ap)
if (cl != NULL)
get_class_stats(&stats, cl);
else
bzero(&stats, sizeof(stats));
(void)memset(&stats, 0, sizeof(stats));
if ((error = copyout((caddr_t)&stats, (caddr_t)usp++,
sizeof(stats))) != 0)
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_red.c,v 1.8 2003/10/07 21:22:11 mycroft Exp $ */
/* $NetBSD: altq_red.c,v 1.9 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_red.c,v 1.9 2002/01/07 11:25:40 kjc Exp $ */
/*
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_red.c,v 1.8 2003/10/07 21:22:11 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_red.c,v 1.9 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -161,7 +161,6 @@ __KERNEL_RCSID(0, "$NetBSD: altq_red.c,v 1.8 2003/10/07 21:22:11 mycroft Exp $")
#define TH_MAX 15 /* max threshold */
#define RED_LIMIT 60 /* default max queue lenght */
#define RED_STATS /* collect statistics */
/*
* our default policy for forced-drop is drop-tail.
@ -310,7 +309,7 @@ redioctl(dev, cmd, addr, flag, p)
error = ENOMEM;
break;
}
bzero(rqp, sizeof(red_queue_t));
(void)memset(rqp, 0, sizeof(red_queue_t));
MALLOC(rqp->rq_q, class_queue_t *, sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
@ -319,7 +318,7 @@ redioctl(dev, cmd, addr, flag, p)
error = ENOMEM;
break;
}
bzero(rqp->rq_q, sizeof(class_queue_t));
(void)memset(rqp->rq_q, 0, sizeof(class_queue_t));
rqp->rq_red = red_alloc(0, 0, 0, 0, 0, 0);
if (rqp->rq_red == NULL) {
@ -522,7 +521,7 @@ red_alloc(weight, inv_pmax, th_min, th_max, flags, pkttime)
MALLOC(rp, red_t *, sizeof(red_t), M_DEVBUF, M_WAITOK);
if (rp == NULL)
return (NULL);
bzero(rp, sizeof(red_t));
(void)memset(rp, 0, sizeof(red_t));
rp->red_avg = 0;
rp->red_idle = 1;
@ -1006,7 +1005,7 @@ wtab_alloc(weight)
MALLOC(w, struct wtab *, sizeof(struct wtab), M_DEVBUF, M_WAITOK);
if (w == NULL)
panic("wtab_alloc: malloc failed!");
bzero(w, sizeof(struct wtab));
(void)memset(w, 0, sizeof(struct wtab));
w->w_weight = weight;
w->w_refcount = 1;
w->w_next = wtab_list;
@ -1090,8 +1089,6 @@ pow_w(w, n)
#define FV_TTHRESH 3 /* time threshold to delete fve */
#define FV_ALPHA 5 /* extra packet count */
#define FV_STATS
#if (__FreeBSD_version > 300000)
#define FV_TIMESTAMP(tp) getmicrotime(tp)
#else
@ -1274,7 +1271,7 @@ fv_alloc(rp)
M_DEVBUF, M_WAITOK);
if (fv == NULL)
return (NULL);
bzero(fv, sizeof(struct flowvalve));
(void)memset(fv, 0, sizeof(struct flowvalve));
MALLOC(fv->fv_fves, struct fve *, sizeof(struct fve) * num,
M_DEVBUF, M_WAITOK);
@ -1282,7 +1279,7 @@ fv_alloc(rp)
FREE(fv, M_DEVBUF);
return (NULL);
}
bzero(fv->fv_fves, sizeof(struct fve) * num);
(void)memset(fv->fv_fves, 0, sizeof(struct fve) * num);
fv->fv_flows = 0;
TAILQ_INIT(&fv->fv_flowlist);

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_rio.c,v 1.4 2001/11/12 23:14:22 lukem Exp $ */
/* $NetBSD: altq_rio.c,v 1.5 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_rio.c,v 1.8 2000/12/14 08:12:46 thorpej Exp $ */
/*
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.4 2001/11/12 23:14:22 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.5 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -150,7 +150,6 @@ __KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.4 2001/11/12 23:14:22 lukem Exp $");
#define TH_MAX 15 /* max threshold */
#define RIO_LIMIT 60 /* default max queue lenght */
#define RIO_STATS /* collect statistics */
#define TV_DELTA(a, b, delta) { \
register int xxs; \
@ -285,7 +284,7 @@ rioioctl(dev, cmd, addr, flag, p)
error = ENOMEM;
break;
}
bzero(rqp, sizeof(rio_queue_t));
(void)memset(rqp, 0, sizeof(rio_queue_t));
MALLOC(rqp->rq_q, class_queue_t *, sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
@ -294,7 +293,7 @@ rioioctl(dev, cmd, addr, flag, p)
error = ENOMEM;
break;
}
bzero(rqp->rq_q, sizeof(class_queue_t));
(void)memset(rqp->rq_q, 0, sizeof(class_queue_t));
rqp->rq_rio = rio_alloc(0, NULL, 0, 0);
if (rqp->rq_rio == NULL) {
@ -358,8 +357,8 @@ rioioctl(dev, cmd, addr, flag, p)
for (i = 0; i < RIO_NDROPPREC; i++) {
q_stats->q_len[i] = rp->rio_precstate[i].qlen;
bcopy(&rp->q_stats[i], &q_stats->q_stats[i],
sizeof(struct redstats));
(void)memcpy(&q_stats->q_stats[i],
&rp->q_stats[i], sizeof(struct redstats));
q_stats->q_stats[i].q_avg =
rp->rio_precstate[i].avg >> rp->rio_wshift;
@ -503,7 +502,7 @@ rio_alloc(weight, params, flags, pkttime)
MALLOC(rp, rio_t *, sizeof(rio_t), M_DEVBUF, M_WAITOK);
if (rp == NULL)
return (NULL);
bzero(rp, sizeof(rio_t));
(void)memset(rp, 0, sizeof(rio_t));
rp->rio_flags = flags;
if (pkttime == 0)
@ -599,7 +598,7 @@ rio_getstats(rp, sp)
int i;
for (i = 0; i < RIO_NDROPPREC; i++) {
bcopy(&rp->q_stats[i], sp, sizeof(struct redstats));
(void)memcpy(sp, &rp->q_stats[i], sizeof(struct redstats));
sp->q_avg = rp->rio_precstate[i].avg >> rp->rio_wshift;
sp++;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_rmclass.c,v 1.7 2003/10/07 21:22:11 mycroft Exp $ */
/* $NetBSD: altq_rmclass.c,v 1.8 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_rmclass.c,v 1.9 2000/12/14 08:12:46 thorpej Exp $ */
/*
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.7 2003/10/07 21:22:11 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.8 2003/11/09 22:11:12 christos Exp $");
#ident "@(#)rm_class.c 1.48 97/12/05 SMI"
@ -73,6 +73,12 @@ __KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.7 2003/10/07 21:22:11 mycroft Exp
#include <altq/altq_red.h>
#include <altq/altq_rio.h>
#ifdef CBQ_TRACE
struct cbqtrace cbqtrace_buffer[NCBQTRACE+1];
struct cbqtrace *cbqtrace_ptr = NULL;
int cbqtrace_count;
#endif
/*
* Local Macros
*/
@ -102,7 +108,6 @@ static void rmc_drop_action __P((struct rm_class *));
static void rmc_restart __P((struct rm_class *));
static void rmc_root_overlimit __P((struct rm_class *, struct rm_class *));
#define BORROW_OFFTIME
/*
* BORROW_OFFTIME (experimental):
* borrow the offtime of the class borrowing from.
@ -111,7 +116,6 @@ static void rmc_root_overlimit __P((struct rm_class *, struct rm_class *));
* but when the borrowed class is overloaded (advidle is close to minidle),
* use the borrowing class's offtime to avoid overload.
*/
#define ADJUST_CUTOFF
/*
* ADJUST_CUTOFF (experimental):
* if no underlimit class is found due to cutoff, increase cutoff and
@ -230,7 +234,7 @@ rmc_newclass(pri, ifd, nsecPerByte, action, maxq, parent, borrow,
M_DEVBUF, M_WAITOK);
if (cl == NULL)
return (NULL);
bzero(cl, sizeof(struct rm_class));
(void)memset(cl, 0, sizeof(struct rm_class));
CALLOUT_INIT(&cl->callout_);
MALLOC(cl->q_, class_queue_t *, sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
@ -238,7 +242,7 @@ rmc_newclass(pri, ifd, nsecPerByte, action, maxq, parent, borrow,
FREE(cl, M_DEVBUF);
return (NULL);
}
bzero(cl->q_, sizeof(class_queue_t));
(void)memset(cl->q_, 0, sizeof(class_queue_t));
/*
* Class initialization.
@ -697,7 +701,7 @@ rmc_init(ifq, ifd, nsecPerByte, restart, maxq, maxqueued, maxidle,
*/
CBQTRACEINIT();
bzero((char *)ifd, sizeof (*ifd));
(void)memset(ifd, 0, sizeof (*ifd));
mtu = ifq->altq_ifp->if_mtu;
ifd->ifq_ = ifq;
ifd->restart = restart;
@ -713,7 +717,7 @@ rmc_init(ifq, ifd, nsecPerByte, restart, maxq, maxqueued, maxidle,
#endif
reset_cutoff(ifd);
CBQTRACE(rmc_init, 'INIT', ifd->cutoff_);
CBQTRACE(rmc_init, "INIT", ifd->cutoff_);
/*
* Initialize the CBQ's WRR state.
@ -777,7 +781,7 @@ rmc_queue_packet(cl, m)
if (TV_LT(&cl->undertime_, &now)) {
if (ifd->cutoff_ > cl->depth_)
ifd->cutoff_ = cl->depth_;
CBQTRACE(rmc_queue_packet, 'ffoc', cl->depth_);
CBQTRACE(rmc_queue_packet, "ffoc", cl->depth_);
}
#if 1 /* ALTQ */
else {
@ -792,7 +796,7 @@ rmc_queue_packet(cl, m)
borrow->depth_ < ifd->cutoff_) {
if (TV_LT(&borrow->undertime_, &now)) {
ifd->cutoff_ = borrow->depth_;
CBQTRACE(rmc_queue_packet, 'ffob', ifd->cutoff_);
CBQTRACE(rmc_queue_packet, "ffob", ifd->cutoff_);
break;
}
borrow = borrow->borrow_;
@ -802,7 +806,7 @@ rmc_queue_packet(cl, m)
else if ((ifd->cutoff_ > 1) && cl->borrow_) {
if (TV_LT(&cl->borrow_->undertime_, &now)) {
ifd->cutoff_ = cl->borrow_->depth_;
CBQTRACE(rmc_queue_packet, 'ffob',
CBQTRACE(rmc_queue_packet, "ffob",
cl->borrow_->depth_);
}
}
@ -814,7 +818,7 @@ rmc_queue_packet(cl, m)
return (-1);
if (is_empty) {
CBQTRACE(rmc_queue_packet, 'ytpe', cl->stats_.handle);
CBQTRACE(rmc_queue_packet, "ytpe", cl->stats_.handle);
ifd->na_[cpri]++;
}
@ -942,7 +946,7 @@ rmc_under_limit(cl, now)
if (cl != NULL) {
/* cutoff is taking effect, use this class as top. */
top = cl;
CBQTRACE(rmc_under_limit, 'ffou', ifd->cutoff_);
CBQTRACE(rmc_under_limit, "ffou", ifd->cutoff_);
}
if (top != NULL && top->avgidle_ == top->minidle_)
top = NULL;
@ -1070,7 +1074,7 @@ _rmc_wrr_dequeue_next(ifd, op)
*/
if (first != NULL && ifd->cutoff_ < ifd->root_->depth_) {
ifd->cutoff_++;
CBQTRACE(_rmc_wrr_dequeue_next, 'ojda', ifd->cutoff_);
CBQTRACE(_rmc_wrr_dequeue_next, "ojda", ifd->cutoff_);
goto _again;
}
#endif /* ADJUST_CUTOFF */
@ -1080,7 +1084,7 @@ _rmc_wrr_dequeue_next(ifd, op)
* of the link-sharing structure are overlimit.
*/
reset_cutoff(ifd);
CBQTRACE(_rmc_wrr_dequeue_next, 'otsr', ifd->cutoff_);
CBQTRACE(_rmc_wrr_dequeue_next, "otsr", ifd->cutoff_);
if (!ifd->efficient_ || first == NULL)
return (NULL);
@ -1370,7 +1374,7 @@ rmc_update_class_util(ifd)
/* Are we overlimit ? */
if (avgidle <= 0) {
CBQTRACE(rmc_update_class_util, 'milo', cl->stats_.handle);
CBQTRACE(rmc_update_class_util, "milo", cl->stats_.handle);
#if 1 /* ALTQ */
/*
* need some lower bound for avgidle, otherwise
@ -1421,10 +1425,10 @@ rmc_update_class_util(ifd)
#if 1 /* ALTQ */
if ((qlen(cl->q_) <= 0) || TV_LT(nowp, &borrowed->undertime_)) {
rmc_tl_satisfied(ifd, nowp);
CBQTRACE(rmc_update_class_util, 'broe', ifd->cutoff_);
CBQTRACE(rmc_update_class_util, "broe", ifd->cutoff_);
} else {
ifd->cutoff_ = borrowed->depth_;
CBQTRACE(rmc_update_class_util, 'ffob', borrowed->depth_);
CBQTRACE(rmc_update_class_util, "ffob", borrowed->depth_);
}
#else /* !ALTQ */
if ((qlen(cl->q_) <= 1) || TV_LT(&now, &borrowed->undertime_)) {
@ -1432,10 +1436,10 @@ rmc_update_class_util(ifd)
#ifdef notdef
rmc_tl_satisfied(ifd, &now);
#endif
CBQTRACE(rmc_update_class_util, 'broe', ifd->cutoff_);
CBQTRACE(rmc_update_class_util, "broe", ifd->cutoff_);
} else {
ifd->cutoff_ = borrowed->depth_;
CBQTRACE(rmc_update_class_util, 'ffob', borrowed->depth_);
CBQTRACE(rmc_update_class_util, "ffob", borrowed->depth_);
}
#endif /* !ALTQ */
}
@ -1525,7 +1529,7 @@ rmc_delay_action(cl, borrow)
#endif
if (!cl->sleeping_) {
CBQTRACE(rmc_delay_action, 'yled', cl->stats_.handle);
CBQTRACE(rmc_delay_action, "yled", cl->stats_.handle);
#ifdef BORROW_OFFTIME
if (borrow != NULL)
extradelay = borrow->offtime_;
@ -1604,7 +1608,7 @@ rmc_restart(cl)
cl->undertime_.tv_sec = 0;
if (ifd->queued_ < ifd->maxqueued_ && ifd->restart != NULL) {
CBQTRACE(rmc_restart, 'trts', cl->stats_.handle);
CBQTRACE(rmc_restart, "trts", cl->stats_.handle);
(ifd->restart)(ifd->ifq_);
}
}
@ -1688,10 +1692,6 @@ _rmc_pollq(cl)
#ifdef CBQ_TRACE
struct cbqtrace cbqtrace_buffer[NCBQTRACE+1];
struct cbqtrace *cbqtrace_ptr = NULL;
int cbqtrace_count;
/*
* DDB hook to trace cbq events:
* the last 1024 events are held in a circular buffer.
@ -1703,16 +1703,15 @@ static char *rmc_funcname(void *);
static struct rmc_funcs {
void *func;
char *name;
} rmc_funcs[] =
{
rmc_init, "rmc_init",
rmc_queue_packet, "rmc_queue_packet",
rmc_under_limit, "rmc_under_limit",
rmc_update_class_util, "rmc_update_class_util",
rmc_delay_action, "rmc_delay_action",
rmc_restart, "rmc_restart",
_rmc_wrr_dequeue_next, "_rmc_wrr_dequeue_next",
NULL, NULL
} rmc_funcs[] = {
{ rmc_init, "rmc_init" },
{ rmc_queue_packet, "rmc_queue_packet" },
{ rmc_under_limit, "rmc_under_limit" },
{ rmc_update_class_util, "rmc_update_class_util" },
{ rmc_delay_action, "rmc_delay_action" },
{ rmc_restart, "rmc_restart" },
{ _rmc_wrr_dequeue_next, "_rmc_wrr_dequeue_next" },
{ NULL, NULL }
};
static char *rmc_funcname(func)

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_rmclass_debug.h,v 1.3 2001/04/13 23:29:56 thorpej Exp $ */
/* $NetBSD: altq_rmclass_debug.h,v 1.4 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_rmclass_debug.h,v 1.2 2000/02/22 14:00:35 itojun Exp $ */
/*
@ -77,7 +77,7 @@ extern int cbqtrace_count;
cbqtrace_ptr = cbqtrace_buffer; \
else { \
cbqtrace_ptr = cbqtrace_buffer; \
bzero((void *)cbqtrace_ptr, sizeof(cbqtrace_buffer)); \
(void)memset(cbqtrace_ptr, 0, sizeof(cbqtrace_buffer)); \
cbqtrace_count = 0; \
} \
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_subr.c,v 1.9 2002/10/09 07:28:57 jdolecek Exp $ */
/* $NetBSD: altq_subr.c,v 1.10 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_subr.c,v 1.11 2002/01/11 08:11:49 kjc Exp $ */
/*
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.9 2002/10/09 07:28:57 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.10 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -333,7 +333,7 @@ tbr_set(ifq, profile)
M_DEVBUF, M_WAITOK);
if (tbr == NULL)
return (ENOMEM);
bzero(tbr, sizeof(struct tb_regulator));
(void)memset(tbr, 0, sizeof(struct tb_regulator));
tbr->tbr_rate = TBR_SCALE(profile->rate / 8) / machclk_freq;
tbr->tbr_depth = TBR_SCALE(profile->depth);
@ -766,7 +766,7 @@ acc_add_filter(classifier, filter, class, phandle)
M_DEVBUF, M_WAITOK);
if (afp == NULL)
return (ENOMEM);
bzero(afp, sizeof(struct acc_filter));
(void)memset(afp, 0, sizeof(struct acc_filter));
afp->f_filter = *filter;
afp->f_class = class;

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_var.h,v 1.4 2002/11/02 07:17:31 perry Exp $ */
/* $NetBSD: altq_var.h,v 1.5 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_var.h,v 1.7 2000/12/14 08:12:46 thorpej Exp $ */
/*
@ -200,10 +200,12 @@ struct callout {
void *c_arg; /* function argument */
void (*c_func) __P((void *));/* functiuon to call */
};
#define CALLOUT_INIT(c) do { bzero((c), sizeof(*(c))); } while (/*CONSTCOND*/ 0)
#define CALLOUT_INIT(c) do { (void)memset((c), 0, sizeof(*(c))); \
} while (/*CONSTCOND*/ 0)
#define CALLOUT_RESET(c,t,f,a) do { (c)->c_arg = (a); \
(c)->c_func = (f); \
timeout((f),(a),(t)); } while (/*CONSTCOND*/ 0)
timeout((f),(a),(t)); \
} while (/*CONSTCOND*/ 0)
#define CALLOUT_STOP(c) untimeout((c)->c_func,(c)->c_arg)
#define CALLOUT_INITIALIZER { NULL, NULL }
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: altq_wfq.c,v 1.5 2001/11/15 06:37:15 lukem Exp $ */
/* $NetBSD: altq_wfq.c,v 1.6 2003/11/09 22:11:12 christos Exp $ */
/* $KAME: altq_wfq.c,v 1.7 2000/12/14 08:12:46 thorpej Exp $ */
/*
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.5 2001/11/15 06:37:15 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.6 2003/11/09 22:11:12 christos Exp $");
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include "opt_altq.h"
@ -140,14 +140,14 @@ wfq_ifattach(ifacep)
M_DEVBUF, M_WAITOK);
if (new_wfqp == NULL)
return (ENOMEM);
bzero(new_wfqp, sizeof(wfq_state_t));
(void)memset(new_wfqp, 0, sizeof(wfq_state_t));
MALLOC(queue, wfq *, sizeof(wfq) * DEFAULT_QSIZE,
M_DEVBUF, M_WAITOK);
if (queue == NULL) {
FREE(new_wfqp, M_DEVBUF);
return (ENOMEM);
}
bzero(queue, sizeof(wfq) * DEFAULT_QSIZE);
(void)memset(queue, 0, sizeof(wfq) * DEFAULT_QSIZE);
/* keep the ifq */
new_wfqp->ifq = &ifp->if_snd;
@ -586,7 +586,7 @@ wfq_config(cf)
M_DEVBUF, M_WAITOK);
if (queue == NULL)
return (ENOMEM);
bzero(queue, sizeof(wfq) * cf->nqueues);
(void)memset(queue, 0, sizeof(wfq) * cf->nqueues);
wfqp->nums = cf->nqueues;
wfqp->bytes = 0;

View File

@ -1,9 +1,13 @@
# $NetBSD: files.altq,v 1.1 2002/04/16 21:27:14 thorpej Exp $
# $NetBSD: files.altq,v 1.2 2003/11/09 22:11:12 christos Exp $
defflag opt_altq_enabled.h ALTQ
defflag opt_altq.h ALTQ_CBQ ALTQ_WFQ ALTQ_FIFOQ ALTQ_RED ALTQ_BLUE
ALTQ_FLOWVALVE ALTQ_RIO ALTQ_LOCALQ ALTQ_HFSC
ALTQ_CDNR ALTQ_PRIQ ALTQ_NOPCC ALTQ_DEBUG
defflag opt_altq.h ALTQ_AFMAP ALTQ_BLUE ALTQ_CBQ ALTQ_CDNR
ALTQ_DEBUG ALTQ_FIFOQ ALTQ_FLOWVALVE ALTQ_HFSC
ALTQ_IPSEC ALTQ_LOCALQ ALTQ_RED ALTQ_RIO
ALTQ_WFQ ADJUST_CUTOFF BLUE_STATS
BORROW_OFFTIME CBQ_TRACE
FIFOQ_STATS FV_STATS HFSC_PKTLOG
RED_RANDOM_LOOP RED_STATS RIO_STATS WFQ_DEBUG
file altq/altq_conf.c altq
file altq/altq_afmap.c altq