Ejemplo n.º 1
0
int
priq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
{
	struct priq_if *pif;
	struct priq_class *cl;
	struct priq_classstats stats;
	struct ifaltq *ifq;
	int error = 0;

	if (*nbytes < sizeof(stats))
		return (EINVAL);

	/* XXX not MP safe */
	if ((pif = altq_lookup(a->ifname, ALTQT_PRIQ)) == NULL)
		return (EBADF);
	ifq = pif->pif_ifq;

	PRIQ_LOCK(ifq);

	if ((cl = clh_to_clp(pif, a->qid)) == NULL) {
		PRIQ_UNLOCK(ifq);
		return (EINVAL);
	}

	get_class_stats(&stats, cl);

	PRIQ_UNLOCK(ifq);

	if ((error = copyout((caddr_t)&stats, ubuf, sizeof(stats))) != 0)
		return (error);
	*nbytes = sizeof(stats);
	return (0);
}
Ejemplo n.º 2
0
int
cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
{
	cbq_state_t	*cbqp;
	struct rm_class	*cl;
	class_stats_t	 stats;
	int		 error = 0;
	struct ifaltq 	*ifq;

	if (*nbytes < sizeof(stats))
		return (EINVAL);

	ifnet_lock();

	/* XXX not MP safe */
	if ((cbqp = altq_lookup(a->ifname, ALTQT_CBQ)) == NULL) {
		ifnet_unlock();
		return (EBADF);
	}
	ifq = cbqp->ifnp.ifq_;

	CBQ_LOCK(ifq);

	if ((cl = clh_to_clp(cbqp, a->qid)) == NULL) {
		CBQ_UNLOCK(ifq);
		ifnet_unlock();
		return (EINVAL);
	}

	get_class_stats(&stats, cl);

	CBQ_UNLOCK(ifq);

	ifnet_unlock();

	if ((error = copyout((caddr_t)&stats, ubuf, sizeof(stats))) != 0)
		return (error);
	*nbytes = sizeof(stats);
	return (0);
}
Ejemplo n.º 3
0
int
priq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
{
	struct priq_if *pif;
	struct priq_class *cl;
	struct priq_classstats stats;
	int error = 0;

	if ((pif = altq_lookup(a->ifname, ALTQT_PRIQ)) == NULL)
		return (EBADF);

	if ((cl = clh_to_clp(pif, a->qid)) == NULL)
		return (EINVAL);

	if (*nbytes < sizeof(stats))
		return (EINVAL);

	get_class_stats(&stats, cl);

	if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0)
		return (error);
	*nbytes = sizeof(stats);
	return (0);
}
Ejemplo n.º 4
0
int
cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
{
	cbq_state_t	*cbqp;
	struct rm_class	*cl;
	class_stats_t	 stats;
	int		 error = 0;

	if ((cbqp = altq_lookup(a->ifname, ALTQT_CBQ)) == NULL)
		return (EBADF);

	if ((cl = clh_to_clp(cbqp, a->qid)) == NULL)
		return (EINVAL);

	if (*nbytes < sizeof(stats))
		return (EINVAL);

	get_class_stats(&stats, cl);

	if ((error = copyout((caddr_t)&stats, ubuf, sizeof(stats))) != 0)
		return (error);
	*nbytes = sizeof(stats);
	return (0);
}
Ejemplo n.º 5
0
static int
cbq_getstats(struct cbq_getstats *gsp)
{
	char		*ifacename;
	int		i, n, nclasses;
	cbq_state_t	*cbqp;
	struct rm_class	*cl;
	class_stats_t	stats, *usp;
	int error = 0;

	ifacename = gsp->iface.cbq_ifacename;
	nclasses = gsp->nclasses;
	usp = gsp->stats;

	if ((cbqp = altq_lookup(ifacename, ALTQT_CBQ)) == NULL)
		return (EBADF);
	if (nclasses <= 0)
		return (EINVAL);

	for (n = 0, i = 0; n < nclasses && i < CBQ_MAX_CLASSES; n++, i++) {
		while ((cl = cbqp->cbq_class_tbl[i]) == NULL)
			if (++i >= CBQ_MAX_CLASSES)
				goto out;

		get_class_stats(&stats, cl);
		stats.handle = cl->stats_.handle;

		if ((error = copyout((void *)&stats, (void *)usp++,
		    sizeof(stats))) != 0)
			return (error);
	}

 out:
	gsp->nclasses = n;
	return (error);
}