Module Name:    src
Committed By:   ozaki-r
Date:           Wed Jul 14 08:32:13 UTC 2021

Modified Files:
        src/usr.sbin/altq/altqd: altq.conf.5
        src/usr.sbin/altq/libaltq: qop_cbq.c qop_cbq.h

Log Message:
libaltq, cbq: add two options to interface

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


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/altq/altqd/altq.conf.5
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/altq/libaltq/qop_cbq.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/altq/libaltq/qop_cbq.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/altq/altqd/altq.conf.5
diff -u src/usr.sbin/altq/altqd/altq.conf.5:1.18 src/usr.sbin/altq/altqd/altq.conf.5:1.19
--- src/usr.sbin/altq/altqd/altq.conf.5:1.18	Tue Apr  9 19:10:21 2019
+++ src/usr.sbin/altq/altqd/altq.conf.5	Wed Jul 14 08:32:13 2021
@@ -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 @@ excess bandwidth is available.
 .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 default, this mode is turned off.
 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

Index: src/usr.sbin/altq/libaltq/qop_cbq.c
diff -u src/usr.sbin/altq/libaltq/qop_cbq.c:1.10 src/usr.sbin/altq/libaltq/qop_cbq.c:1.11
--- src/usr.sbin/altq/libaltq/qop_cbq.c:1.10	Sat Oct 19 17:16:37 2013
+++ src/usr.sbin/altq/libaltq/qop_cbq.c	Wed Jul 14 08:32:13 2021
@@ -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 @@ cbq_interface_parser(const char *ifname,
 	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 @@ cbq_interface_parser(const char *ifname,
 			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 @@ cbq_interface_parser(const char *ifname,
 		argc--; argv++;
 	}
 
-	if (qcmd_tbr_register(ifname, bandwidth, tbrsize) != 0)
-		return (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) != 0)
+			    is_wrr, is_efficient, no_control) != 0)
 		return (0);
+
 	return (1);
 }
 
@@ -296,11 +305,13 @@ cbq_class_parser(const char *ifname, con
  * 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 @@ qcmd_cbq_add_class(const char *ifname, c
 	    (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 @@ qcmd_cbq_add_ctl_filters(const char *ifn
  */
 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 @@ qop_cbq_add_if(struct ifinfo **rp, const
 		(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);

Index: src/usr.sbin/altq/libaltq/qop_cbq.h
diff -u src/usr.sbin/altq/libaltq/qop_cbq.h:1.2 src/usr.sbin/altq/libaltq/qop_cbq.h:1.3
--- src/usr.sbin/altq/libaltq/qop_cbq.h:1.2	Thu Aug 16 07:48:13 2001
+++ src/usr.sbin/altq/libaltq/qop_cbq.h	Wed Jul 14 08:32:13 2021
@@ -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 @@ struct cbq_ifinfo {
 	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 @@ int cbq_class_parser(const char *ifname,
 		     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 @@ int qcmd_cbq_modify_class(const char *if
 			  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,

Reply via email to