pfctl_altq.c (164775) | pfctl_altq.c (171172) |
---|---|
1/* $OpenBSD: pfctl_altq.c,v 1.86 2005/02/28 14:04:51 henning Exp $ */ 2/* add: $OpenBSD: pfctl_altq.c,v 1.91 2006/11/28 00:08:50 henning Exp $ */ | 1/* $OpenBSD: pfctl_altq.c,v 1.91 2006/11/28 00:08:50 henning Exp $ */ |
3 4/* 5 * Copyright (c) 2002 6 * Sony Computer Science Laboratories Inc. 7 * Copyright (c) 2002, 2003 Henning Brauer <henning@openbsd.org> 8 * 9 * Permission to use, copy, modify, and distribute this software for any 10 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22#include <sys/cdefs.h> | 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> |
23__FBSDID("$FreeBSD: head/contrib/pf/pfctl/pfctl_altq.c 164775 2006-11-30 18:55:36Z mlaier $"); | 22__FBSDID("$FreeBSD: head/contrib/pf/pfctl/pfctl_altq.c 171172 2007-07-03 12:30:03Z mlaier $"); |
24 25#include <sys/param.h> 26#include <sys/ioctl.h> 27#include <sys/socket.h> 28 29#include <net/if.h> 30#include <netinet/in.h> 31#include <net/pfvar.h> --- 64 unchanged lines hidden (view full) --- 96 struct pf_altq *altq; 97 98 if ((altq = malloc(sizeof(*altq))) == NULL) 99 err(1, "malloc"); 100 memcpy(altq, a, sizeof(struct pf_altq)); 101 TAILQ_INSERT_TAIL(&altqs, altq, entries); 102} 103 | 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 |
104void 105pfaltq_free(struct pf_altq *a) 106{ 107 struct pf_altq *altq; 108 109 TAILQ_FOREACH(altq, &altqs, entries) { 110 if (strncmp(a->ifname, altq->ifname, IFNAMSIZ) == 0 && 111 strncmp(a->qname, altq->qname, PF_QNAME_SIZE) == 0) { 112 TAILQ_REMOVE(&altqs, altq, entries); 113 free(altq); 114 return; 115 } 116 } 117} 118 | |
119struct pf_altq * 120pfaltq_lookup(const char *ifname) 121{ 122 struct pf_altq *altq; 123 124 TAILQ_FOREACH(altq, &altqs, entries) { 125 if (strncmp(ifname, altq->ifname, IFNAMSIZ) == 0 && 126 altq->qname[0] == 0) --- 33 unchanged lines hidden (view full) --- 160 return (0); 161} 162 163void 164print_altq(const struct pf_altq *a, unsigned level, struct node_queue_bw *bw, 165 struct node_queue_opt *qopts) 166{ 167 if (a->qname[0] != 0) { | 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) { |
168 print_queue(a, level, bw, 0, qopts); | 152 print_queue(a, level, bw, 1, qopts); |
169 return; 170 } 171 172 printf("altq on %s ", a->ifname); 173 174 switch (a->scheduler) { 175 case ALTQT_CBQ: 176 if (!print_cbq_opts(a)) --- 68 unchanged lines hidden (view full) --- 245 if (bw->bw_absolute > 0) 246 pa->ifbandwidth = bw->bw_absolute; 247 else 248#ifdef __FreeBSD__ 249 if ((rate = getifspeed(pf->dev, pa->ifname)) == 0) { 250#else 251 if ((rate = getifspeed(pa->ifname)) == 0) { 252#endif | 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 |
253 fprintf(stderr, "cannot determine interface bandwidth " 254 "for %s, specify an absolute bandwidth\n", | 237 fprintf(stderr, "interface %s does not know its bandwidth, " 238 "please specify an absolute bandwidth\n", |
255 pa->ifname); 256 errors++; 257 } else if ((pa->ifbandwidth = eval_bwspec(bw, rate)) == 0) 258 pa->ifbandwidth = rate; 259 260 errors += eval_queue_opts(pa, opts, pa->ifbandwidth); 261 262 /* if tbrsize is not specified, use heuristics */ --- 234 unchanged lines hidden (view full) --- 497 gton = pow(g, (double)maxburst); 498 gtom = pow(g, (double)(minburst-1)); 499 maxidle = ((1.0 / f - 1.0) * ((1.0 - gton) / gton)); 500 maxidle_s = (1.0 - g); 501 if (maxidle > maxidle_s) 502 maxidle = ptime * maxidle; 503 else 504 maxidle = ptime * maxidle_s; | 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; |
505 if (minburst) 506 offtime = cptime * (1.0 + 1.0/(1.0 - g) * (1.0 - gtom) / gtom); 507 else 508 offtime = cptime; | 489 offtime = cptime * (1.0 + 1.0/(1.0 - g) * (1.0 - gtom) / gtom); |
509 minidle = -((double)opts->maxpktsize * (double)nsPerByte); 510 511 /* scale parameters */ 512 maxidle = ((maxidle * 8.0) / nsPerByte) * 513 pow(2.0, (double)RM_FILTER_GAIN); 514 offtime = (offtime * 8.0) / nsPerByte * 515 pow(2.0, (double)RM_FILTER_GAIN); 516 minidle = ((minidle * 8.0) / nsPerByte) * --- 754 unchanged lines hidden --- | 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 --- |