Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/altq libaltq, cbq: add two options to interface



details:   https://anonhg.NetBSD.org/src/rev/5b9e5d054995
branches:  trunk
changeset: 984625:5b9e5d054995
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Jul 14 08:32:13 2021 +0000

description:
libaltq, cbq: add two options to interface

- no-control: don't create a control class automatically
- no-tbr: don't install TBR

diffstat:

 usr.sbin/altq/altqd/altq.conf.5 |  13 +++++++++++--
 usr.sbin/altq/libaltq/qop_cbq.c |  30 +++++++++++++++++++++---------
 usr.sbin/altq/libaltq/qop_cbq.h |   7 ++++---
 3 files changed, 36 insertions(+), 14 deletions(-)

diffs (167 lines):

diff -r 395e3574606c -r 5b9e5d054995 usr.sbin/altq/altqd/altq.conf.5
--- a/usr.sbin/altq/altqd/altq.conf.5   Wed Jul 14 08:31:15 2021 +0000
+++ b/usr.sbin/altq/altqd/altq.conf.5   Wed Jul 14 08:32:13 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: altq.conf.5,v 1.18 2019/04/09 19:10:21 sevan Exp $
+.\"    $NetBSD: altq.conf.5,v 1.19 2021/07/14 08:32:13 ozaki-r Exp $
 .\"    $KAME: altq.conf.5,v 1.15 2002/11/17 02:51:49 kjc Exp $
 .\"
 .\" Copyright (C) 2000
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 9, 2019
+.Dd July 14, 2021
 .Dt ALTQ.CONF 5
 .Os
 .\"
@@ -281,6 +281,8 @@
 .Op Cm tbrsize Ar bytes
 .Op Ar sched_type
 .Op Cm efficient
+.Op Cm no-control
+.Op Cm no-tbr
 .El
 .Bl -tag -width 8n -offset indent
 .It Ar if_name
@@ -310,6 +312,13 @@
 By adding the keyword
 .Cm efficient
 to the interface specification line, enables this mode.
+.It Cm no-control
+By default, the control class is automatically created when default class is
+created and one doesn't exist yet.
+This option suppresses the behavior on the interface.
+.It Cm no-tbr
+By default, a token bucket regulator is automatically created on each interface.
+This option suppresses the behavior on the interface.
 .El
 .Bl -tag -width class -offset indent
 .It Cm class
diff -r 395e3574606c -r 5b9e5d054995 usr.sbin/altq/libaltq/qop_cbq.c
--- a/usr.sbin/altq/libaltq/qop_cbq.c   Wed Jul 14 08:31:15 2021 +0000
+++ b/usr.sbin/altq/libaltq/qop_cbq.c   Wed Jul 14 08:32:13 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: qop_cbq.c,v 1.10 2013/10/19 17:16:37 christos Exp $    */
+/*     $NetBSD: qop_cbq.c,v 1.11 2021/07/14 08:32:13 ozaki-r Exp $     */
 /*     $KAME: qop_cbq.c,v 1.7 2002/05/31 06:03:35 kjc Exp $    */
 /*
  * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
@@ -112,6 +112,8 @@
        u_int   tbrsize = 0;
        u_int   is_efficient = 0;
        u_int   is_wrr = 1;     /* weighted round-robin is default */
+       bool    no_control = false;
+       bool    no_tbr = false;
 
        /*
         * process options
@@ -133,6 +135,10 @@
                        is_wrr = 1;
                } else if (EQUAL(*argv, "cbq-prr")) {
                        is_wrr = 0;
+               } else if (EQUAL(*argv, "no-tbr")) {
+                       no_tbr = true;
+               } else if (EQUAL(*argv, "no-control")) {
+                       no_control = true;
                } else {
                        LOG(LOG_ERR, 0, "Unknown keyword '%s'", *argv);
                        return (0);
@@ -140,12 +146,15 @@
                argc--; argv++;
        }
 
-       if (qcmd_tbr_register(ifname, bandwidth, tbrsize) != 0)
+       if (!no_tbr) {
+               if (qcmd_tbr_register(ifname, bandwidth, tbrsize) != 0)
+                       return (0);
+       }
+
+       if (qcmd_cbq_add_if(ifname, bandwidth,
+                           is_wrr, is_efficient, no_control) != 0)
                return (0);
 
-       if (qcmd_cbq_add_if(ifname, bandwidth,
-                           is_wrr, is_efficient) != 0)
-               return (0);
        return (1);
 }
 
@@ -296,11 +305,13 @@
  * qcmd api
  */
 int
-qcmd_cbq_add_if(const char *ifname, u_int bandwidth, int is_wrr, int efficient)
+qcmd_cbq_add_if(const char *ifname, u_int bandwidth, int is_wrr, int efficient,
+    bool no_control)
 {
        int error;
        
-       error = qop_cbq_add_if(NULL, ifname, bandwidth, is_wrr, efficient);
+       error = qop_cbq_add_if(NULL, ifname, bandwidth, is_wrr, efficient,
+           no_control);
        if (error != 0)
                LOG(LOG_ERR, errno, "%s: can't add cbq on interface '%s'",
                    qoperror(error), ifname);
@@ -333,7 +344,7 @@
            (borrow = clname2clinfo(ifinfo, borrow_name)) == NULL)
                error = QOPERR_BADCLASS;
 
-       if (flags & CBQCLF_DEFCLASS) {
+       if (flags & CBQCLF_DEFCLASS && !cbq_ifinfo->no_control) {
                /*
                 * if this is a default class and no ctl_class is defined,
                 * we will create a ctl_class.
@@ -464,7 +475,7 @@
  */
 int 
 qop_cbq_add_if(struct ifinfo **rp, const char *ifname,
-              u_int bandwidth, int is_wrr, int efficient)
+              u_int bandwidth, int is_wrr, int efficient, bool no_control)
 {
        struct ifinfo *ifinfo = NULL;
        struct cbq_ifinfo *cbq_ifinfo = NULL;
@@ -477,6 +488,7 @@
                (1.0 / (double)bandwidth) * NS_PER_SEC * 8;
        cbq_ifinfo->is_wrr = is_wrr;
        cbq_ifinfo->is_efficient = efficient;
+       cbq_ifinfo->no_control = no_control;
 
        error = qop_add_if(&ifinfo, ifname, bandwidth,
                           &cbq_qdisc, cbq_ifinfo);
diff -r 395e3574606c -r 5b9e5d054995 usr.sbin/altq/libaltq/qop_cbq.h
--- a/usr.sbin/altq/libaltq/qop_cbq.h   Wed Jul 14 08:31:15 2021 +0000
+++ b/usr.sbin/altq/libaltq/qop_cbq.h   Wed Jul 14 08:32:13 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: qop_cbq.h,v 1.2 2001/08/16 07:48:13 itojun Exp $       */
+/*     $NetBSD: qop_cbq.h,v 1.3 2021/07/14 08:32:13 ozaki-r Exp $      */
 /*     $KAME: qop_cbq.h,v 1.2 2000/10/18 09:15:18 kjc Exp $    */
 /*
  * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
@@ -53,6 +53,7 @@
        double  nsPerByte;              /* bandwidth in ns per sec */
        int     is_wrr;                 /* use weighted-round robin */
        int     is_efficient;           /* use work-conserving */
+       bool    no_control;             /* don't create a control class automatically */
 };
 
 /*
@@ -76,7 +77,7 @@
                     const char *parent_name, int argc, char **argv);
 
 int qcmd_cbq_add_if(const char *ifname, u_int bandwidth,
-                   int is_wrr, int efficient);
+                   int is_wrr, int efficient, bool no_control);
 int qcmd_cbq_add_class(const char *ifname, const char *class_name,
                       const char *parent_name, const char *borrow_name,
                       u_int pri, u_int bandwidth,
@@ -89,7 +90,7 @@
                          u_int av_pkt_size, u_int max_pkt_size, int flags);
 
 int qop_cbq_add_if(struct ifinfo **rp, const char *ifname,
-                  u_int bandwidth, int is_wrr, int efficient);
+                  u_int bandwidth, int is_wrr, int efficient, bool no_control);
 int qop_cbq_add_class(struct classinfo **rp, const char *class_name,
                      struct ifinfo *ifinfo, struct classinfo *parent, 
                      struct classinfo *borrow, u_int pri, u_int bandwidth,



Home | Main Index | Thread Index | Old Index