1/* $OpenBSD: pfctl_altq.c,v 1.91 2006/11/28 00:08:50 henning Exp $ */ |
2 3/* 4 * Copyright (c) 2002 5 * Sony Computer Science Laboratories Inc. 6 * Copyright (c) 2002, 2003 Henning Brauer <henning@openbsd.org> 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21#include <sys/cdefs.h> |
22__FBSDID("$FreeBSD: head/contrib/pf/pfctl/pfctl_altq.c 171172 2007-07-03 12:30:03Z mlaier $"); |
23 24#include <sys/param.h> 25#include <sys/ioctl.h> 26#include <sys/socket.h> 27 28#include <net/if.h> 29#include <netinet/in.h> 30#include <net/pfvar.h> --- 64 unchanged lines hidden (view full) --- 95 struct pf_altq *altq; 96 97 if ((altq = malloc(sizeof(*altq))) == NULL) 98 err(1, "malloc"); 99 memcpy(altq, a, sizeof(struct pf_altq)); 100 TAILQ_INSERT_TAIL(&altqs, altq, entries); 101} 102 |
103struct pf_altq * 104pfaltq_lookup(const char *ifname) 105{ 106 struct pf_altq *altq; 107 108 TAILQ_FOREACH(altq, &altqs, entries) { 109 if (strncmp(ifname, altq->ifname, IFNAMSIZ) == 0 && 110 altq->qname[0] == 0) --- 33 unchanged lines hidden (view full) --- 144 return (0); 145} 146 147void 148print_altq(const struct pf_altq *a, unsigned level, struct node_queue_bw *bw, 149 struct node_queue_opt *qopts) 150{ 151 if (a->qname[0] != 0) { |
152 print_queue(a, level, bw, 1, qopts); |
153 return; 154 } 155 156 printf("altq on %s ", a->ifname); 157 158 switch (a->scheduler) { 159 case ALTQT_CBQ: 160 if (!print_cbq_opts(a)) --- 68 unchanged lines hidden (view full) --- 229 if (bw->bw_absolute > 0) 230 pa->ifbandwidth = bw->bw_absolute; 231 else 232#ifdef __FreeBSD__ 233 if ((rate = getifspeed(pf->dev, pa->ifname)) == 0) { 234#else 235 if ((rate = getifspeed(pa->ifname)) == 0) { 236#endif |
237 fprintf(stderr, "interface %s does not know its bandwidth, " 238 "please specify an absolute bandwidth\n", |
239 pa->ifname); 240 errors++; 241 } else if ((pa->ifbandwidth = eval_bwspec(bw, rate)) == 0) 242 pa->ifbandwidth = rate; 243 244 errors += eval_queue_opts(pa, opts, pa->ifbandwidth); 245 246 /* if tbrsize is not specified, use heuristics */ --- 234 unchanged lines hidden (view full) --- 481 gton = pow(g, (double)maxburst); 482 gtom = pow(g, (double)(minburst-1)); 483 maxidle = ((1.0 / f - 1.0) * ((1.0 - gton) / gton)); 484 maxidle_s = (1.0 - g); 485 if (maxidle > maxidle_s) 486 maxidle = ptime * maxidle; 487 else 488 maxidle = ptime * maxidle_s; |
489 offtime = cptime * (1.0 + 1.0/(1.0 - g) * (1.0 - gtom) / gtom); |
490 minidle = -((double)opts->maxpktsize * (double)nsPerByte); 491 492 /* scale parameters */ 493 maxidle = ((maxidle * 8.0) / nsPerByte) * 494 pow(2.0, (double)RM_FILTER_GAIN); 495 offtime = (offtime * 8.0) / nsPerByte * 496 pow(2.0, (double)RM_FILTER_GAIN); 497 minidle = ((minidle * 8.0) / nsPerByte) * --- 754 unchanged lines hidden --- |