pfctl_altq.c (ab875b713d0afab5f0650f06d48a38777a7ae43e) pfctl_altq.c (0a70aaf8f5d93454d0940a09b94deecd7aa5fa0d)
1/* $OpenBSD: pfctl_altq.c,v 1.93 2007/10/15 02:16:35 deraadt 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

--- 26 unchanged lines hidden (view full) ---

35#include <math.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <unistd.h>
40
41#include <net/altq/altq.h>
42#include <net/altq/altq_cbq.h>
1/* $OpenBSD: pfctl_altq.c,v 1.93 2007/10/15 02:16:35 deraadt 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

--- 26 unchanged lines hidden (view full) ---

35#include <math.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <unistd.h>
40
41#include <net/altq/altq.h>
42#include <net/altq/altq_cbq.h>
43#include <net/altq/altq_codel.h>
43#include <net/altq/altq_priq.h>
44#include <net/altq/altq_hfsc.h>
45#include <net/altq/altq_fairq.h>
46
47#include "pfctl_parser.h"
48#include "pfctl.h"
49
50#define is_sc_null(sc) (((sc) == NULL) || ((sc)->m1 == 0 && (sc)->m2 == 0))

--- 4 unchanged lines hidden (view full) ---

55struct pf_altq *qname_to_pfaltq(const char *, const char *);
56u_int32_t qname_to_qid(const char *);
57
58static int eval_pfqueue_cbq(struct pfctl *, struct pf_altq *);
59static int cbq_compute_idletime(struct pfctl *, struct pf_altq *);
60static int check_commit_cbq(int, int, struct pf_altq *);
61static int print_cbq_opts(const struct pf_altq *);
62
44#include <net/altq/altq_priq.h>
45#include <net/altq/altq_hfsc.h>
46#include <net/altq/altq_fairq.h>
47
48#include "pfctl_parser.h"
49#include "pfctl.h"
50
51#define is_sc_null(sc) (((sc) == NULL) || ((sc)->m1 == 0 && (sc)->m2 == 0))

--- 4 unchanged lines hidden (view full) ---

56struct pf_altq *qname_to_pfaltq(const char *, const char *);
57u_int32_t qname_to_qid(const char *);
58
59static int eval_pfqueue_cbq(struct pfctl *, struct pf_altq *);
60static int cbq_compute_idletime(struct pfctl *, struct pf_altq *);
61static int check_commit_cbq(int, int, struct pf_altq *);
62static int print_cbq_opts(const struct pf_altq *);
63
64static int print_codel_opts(const struct pf_altq *,
65 const struct node_queue_opt *);
66
63static int eval_pfqueue_priq(struct pfctl *, struct pf_altq *);
64static int check_commit_priq(int, int, struct pf_altq *);
65static int print_priq_opts(const struct pf_altq *);
66
67static int eval_pfqueue_hfsc(struct pfctl *, struct pf_altq *);
68static int check_commit_hfsc(int, int, struct pf_altq *);
69static int print_hfsc_opts(const struct pf_altq *,
70 const struct node_queue_opt *);

--- 109 unchanged lines hidden (view full) ---

180 case ALTQT_HFSC:
181 if (!print_hfsc_opts(a, qopts))
182 printf("hfsc ");
183 break;
184 case ALTQT_FAIRQ:
185 if (!print_fairq_opts(a, qopts))
186 printf("fairq ");
187 break;
67static int eval_pfqueue_priq(struct pfctl *, struct pf_altq *);
68static int check_commit_priq(int, int, struct pf_altq *);
69static int print_priq_opts(const struct pf_altq *);
70
71static int eval_pfqueue_hfsc(struct pfctl *, struct pf_altq *);
72static int check_commit_hfsc(int, int, struct pf_altq *);
73static int print_hfsc_opts(const struct pf_altq *,
74 const struct node_queue_opt *);

--- 109 unchanged lines hidden (view full) ---

184 case ALTQT_HFSC:
185 if (!print_hfsc_opts(a, qopts))
186 printf("hfsc ");
187 break;
188 case ALTQT_FAIRQ:
189 if (!print_fairq_opts(a, qopts))
190 printf("fairq ");
191 break;
192 case ALTQT_CODEL:
193 if (!print_codel_opts(a, qopts))
194 printf("codel ");
195 break;
188 }
189
190 if (bw != NULL && bw->bw_percent > 0) {
191 if (bw->bw_percent < 100)
192 printf("bandwidth %u%% ", bw->bw_percent);
193 } else
194 printf("bandwidth %s ", rate2str((double)a->ifbandwidth));
195

--- 390 unchanged lines hidden (view full) ---

586 if (opts->flags) {
587 printf("cbq(");
588 if (opts->flags & CBQCLF_RED)
589 printf(" red");
590 if (opts->flags & CBQCLF_ECN)
591 printf(" ecn");
592 if (opts->flags & CBQCLF_RIO)
593 printf(" rio");
196 }
197
198 if (bw != NULL && bw->bw_percent > 0) {
199 if (bw->bw_percent < 100)
200 printf("bandwidth %u%% ", bw->bw_percent);
201 } else
202 printf("bandwidth %s ", rate2str((double)a->ifbandwidth));
203

--- 390 unchanged lines hidden (view full) ---

594 if (opts->flags) {
595 printf("cbq(");
596 if (opts->flags & CBQCLF_RED)
597 printf(" red");
598 if (opts->flags & CBQCLF_ECN)
599 printf(" ecn");
600 if (opts->flags & CBQCLF_RIO)
601 printf(" rio");
602 if (opts->flags & CBQCLF_CODEL)
603 printf(" codel");
594 if (opts->flags & CBQCLF_CLEARDSCP)
595 printf(" cleardscp");
596 if (opts->flags & CBQCLF_FLOWVALVE)
597 printf(" flowvalve");
598 if (opts->flags & CBQCLF_BORROW)
599 printf(" borrow");
600 if (opts->flags & CBQCLF_WRR)
601 printf(" wrr");

--- 71 unchanged lines hidden (view full) ---

673 if (opts->flags) {
674 printf("priq(");
675 if (opts->flags & PRCF_RED)
676 printf(" red");
677 if (opts->flags & PRCF_ECN)
678 printf(" ecn");
679 if (opts->flags & PRCF_RIO)
680 printf(" rio");
604 if (opts->flags & CBQCLF_CLEARDSCP)
605 printf(" cleardscp");
606 if (opts->flags & CBQCLF_FLOWVALVE)
607 printf(" flowvalve");
608 if (opts->flags & CBQCLF_BORROW)
609 printf(" borrow");
610 if (opts->flags & CBQCLF_WRR)
611 printf(" wrr");

--- 71 unchanged lines hidden (view full) ---

683 if (opts->flags) {
684 printf("priq(");
685 if (opts->flags & PRCF_RED)
686 printf(" red");
687 if (opts->flags & PRCF_ECN)
688 printf(" ecn");
689 if (opts->flags & PRCF_RIO)
690 printf(" rio");
691 if (opts->flags & PRCF_CODEL)
692 printf(" codel");
681 if (opts->flags & PRCF_CLEARDSCP)
682 printf(" cleardscp");
683 if (opts->flags & PRCF_DEFAULTCLASS)
684 printf(" default");
685 printf(" ) ");
686
687 return (1);
688 } else

--- 316 unchanged lines hidden (view full) ---

1005 opts->lssc_d != 0))) {
1006 printf("hfsc(");
1007 if (opts->flags & HFCF_RED)
1008 printf(" red");
1009 if (opts->flags & HFCF_ECN)
1010 printf(" ecn");
1011 if (opts->flags & HFCF_RIO)
1012 printf(" rio");
693 if (opts->flags & PRCF_CLEARDSCP)
694 printf(" cleardscp");
695 if (opts->flags & PRCF_DEFAULTCLASS)
696 printf(" default");
697 printf(" ) ");
698
699 return (1);
700 } else

--- 316 unchanged lines hidden (view full) ---

1017 opts->lssc_d != 0))) {
1018 printf("hfsc(");
1019 if (opts->flags & HFCF_RED)
1020 printf(" red");
1021 if (opts->flags & HFCF_ECN)
1022 printf(" ecn");
1023 if (opts->flags & HFCF_RIO)
1024 printf(" rio");
1025 if (opts->flags & HFCF_CODEL)
1026 printf(" codel");
1013 if (opts->flags & HFCF_CLEARDSCP)
1014 printf(" cleardscp");
1015 if (opts->flags & HFCF_DEFAULTCLASS)
1016 printf(" default");
1017 if (opts->rtsc_m2 != 0)
1018 print_hfsc_sc("realtime", opts->rtsc_m1, opts->rtsc_d,
1019 opts->rtsc_m2, rtsc);
1020 if (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth ||

--- 6 unchanged lines hidden (view full) ---

1027 printf(" ) ");
1028
1029 return (1);
1030 } else
1031 return (0);
1032}
1033
1034static int
1027 if (opts->flags & HFCF_CLEARDSCP)
1028 printf(" cleardscp");
1029 if (opts->flags & HFCF_DEFAULTCLASS)
1030 printf(" default");
1031 if (opts->rtsc_m2 != 0)
1032 print_hfsc_sc("realtime", opts->rtsc_m1, opts->rtsc_d,
1033 opts->rtsc_m2, rtsc);
1034 if (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth ||

--- 6 unchanged lines hidden (view full) ---

1041 printf(" ) ");
1042
1043 return (1);
1044 } else
1045 return (0);
1046}
1047
1048static int
1049print_codel_opts(const struct pf_altq *a, const struct node_queue_opt *qopts)
1050{
1051 const struct codel_opts *opts;
1052
1053 opts = &a->pq_u.codel_opts;
1054 if (opts->target || opts->interval || opts->ecn) {
1055 printf("codel(");
1056 if (opts->target)
1057 printf(" target %d", opts->target);
1058 if (opts->interval)
1059 printf(" interval %d", opts->interval);
1060 if (opts->ecn)
1061 printf("ecn");
1062 printf(" ) ");
1063
1064 return (1);
1065 }
1066
1067 return (0);
1068}
1069
1070static int
1035print_fairq_opts(const struct pf_altq *a, const struct node_queue_opt *qopts)
1036{
1037 const struct fairq_opts *opts;
1038 const struct node_fairq_sc *loc_lssc;
1039
1040 opts = &a->pq_u.fairq_opts;
1041 if (qopts == NULL)
1042 loc_lssc = NULL;

--- 5 unchanged lines hidden (view full) ---

1048 opts->lssc_d != 0))) {
1049 printf("fairq(");
1050 if (opts->flags & FARF_RED)
1051 printf(" red");
1052 if (opts->flags & FARF_ECN)
1053 printf(" ecn");
1054 if (opts->flags & FARF_RIO)
1055 printf(" rio");
1071print_fairq_opts(const struct pf_altq *a, const struct node_queue_opt *qopts)
1072{
1073 const struct fairq_opts *opts;
1074 const struct node_fairq_sc *loc_lssc;
1075
1076 opts = &a->pq_u.fairq_opts;
1077 if (qopts == NULL)
1078 loc_lssc = NULL;

--- 5 unchanged lines hidden (view full) ---

1084 opts->lssc_d != 0))) {
1085 printf("fairq(");
1086 if (opts->flags & FARF_RED)
1087 printf(" red");
1088 if (opts->flags & FARF_ECN)
1089 printf(" ecn");
1090 if (opts->flags & FARF_RIO)
1091 printf(" rio");
1092 if (opts->flags & FARF_CODEL)
1093 printf(" codel");
1056 if (opts->flags & FARF_CLEARDSCP)
1057 printf(" cleardscp");
1058 if (opts->flags & FARF_DEFAULTCLASS)
1059 printf(" default");
1060 if (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth ||
1061 opts->lssc_d != 0))
1062 print_fairq_sc("linkshare", opts->lssc_m1, opts->lssc_d,
1063 opts->lssc_m2, loc_lssc);

--- 335 unchanged lines hidden (view full) ---

1399 ref_bw);
1400 pa->pq_u.fairq_opts.lssc_m2 =
1401 eval_bwspec(&opts->data.fairq_opts.linkshare.m2,
1402 ref_bw);
1403 pa->pq_u.fairq_opts.lssc_d =
1404 opts->data.fairq_opts.linkshare.d;
1405 }
1406 break;
1094 if (opts->flags & FARF_CLEARDSCP)
1095 printf(" cleardscp");
1096 if (opts->flags & FARF_DEFAULTCLASS)
1097 printf(" default");
1098 if (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth ||
1099 opts->lssc_d != 0))
1100 print_fairq_sc("linkshare", opts->lssc_m1, opts->lssc_d,
1101 opts->lssc_m2, loc_lssc);

--- 335 unchanged lines hidden (view full) ---

1437 ref_bw);
1438 pa->pq_u.fairq_opts.lssc_m2 =
1439 eval_bwspec(&opts->data.fairq_opts.linkshare.m2,
1440 ref_bw);
1441 pa->pq_u.fairq_opts.lssc_d =
1442 opts->data.fairq_opts.linkshare.d;
1443 }
1444 break;
1445 case ALTQT_CODEL:
1446 pa->pq_u.codel_opts.target = opts->data.codel_opts.target;
1447 pa->pq_u.codel_opts.interval = opts->data.codel_opts.interval;
1448 pa->pq_u.codel_opts.ecn = opts->data.codel_opts.ecn;
1449 break;
1407 default:
1408 warnx("eval_queue_opts: unknown scheduler type %u",
1409 opts->qtype);
1410 errors++;
1411 break;
1412 }
1413
1414 return (errors);

--- 61 unchanged lines hidden ---
1450 default:
1451 warnx("eval_queue_opts: unknown scheduler type %u",
1452 opts->qtype);
1453 errors++;
1454 break;
1455 }
1456
1457 return (errors);

--- 61 unchanged lines hidden ---