Browse Source

sqm-scripts: change default for qdisc target parameter

Alan Jenkins noted a bug in the smq luci GUI that effectively
erased several configuration paramters if two checkboxes were deselected.
This behaviour seems consistent in luci but certainly has the potential
to confuse users. While confusion can not really be avoided generally
it seems wise to change the default interpretation for empty or non-existent
itarget and etarget variables from the qdisc's default (5ms in the case of
one of the codels) to automatic determination of tghis variable dependent on
the configured bandwidth, as codels target variable should be large enough
to contain at least one full packet. With this change sqm-scripts will
do the right thing by default, but will yet allow the user to specify
over-ridding values (as long as the user does not un-check the
entry-field exposing check boxes). Survives light testing...
This change set also changes the sqm-scripts luci gui to note the user
of the change. For compatibility with existing setups sqm-scripts
will still honor "auto" as an alternative explicit way of requesting
automatic target selection. This might turn into a warning in the future
and might be phased out...

Signed-off-by: Sebastian Moeller <moeller0@gmx.de>
Sebastian Moeller 10 years ago
parent
commit
1561003a70
2 changed files with 37 additions and 9 deletions
  1. 4
    4
      net/luci-app-sqm/files/sqm-cbi.lua
  2. 33
    5
      net/sqm-scripts/files/usr/lib/sqm/functions.sh

+ 4
- 4
net/luci-app-sqm/files/sqm-cbi.lua View File

@@ -89,7 +89,7 @@ sc.default = "simple.qos"
89 89
 sc.rmempty = false
90 90
 sc.description = qos_desc
91 91
 
92
-ad = s:taboption("tab_qdisc", Flag, "qdisc_advanced", translate("Show Advanced Configuration"))
92
+ad = s:taboption("tab_qdisc", Flag, "qdisc_advanced", translate("Show and Use Advanced Configuration"))
93 93
 ad.default = false
94 94
 ad.rmempty = true
95 95
 
@@ -121,7 +121,7 @@ eecn.default = "NOECN"
121 121
 eecn.rmempty = true
122 122
 eecn:depends("qdisc_advanced", "1")
123 123
 
124
-ad2 = s:taboption("tab_qdisc", Flag, "qdisc_really_really_advanced", translate("Show Dangerous Configuration"))
124
+ad2 = s:taboption("tab_qdisc", Flag, "qdisc_really_really_advanced", translate("Show and Use Dangerous Configuration"))
125 125
 ad2.default = false
126 126
 ad2.rmempty = true
127 127
 ad2:depends("qdisc_advanced", "1")
@@ -140,12 +140,12 @@ elim.rmempty = true
140 140
 elim:depends("qdisc_really_really_advanced", "1")
141 141
 
142 142
 
143
-itarg = s:taboption("tab_qdisc", Value, "itarget", translate("Latency target for ingress, e.g 5ms [units: s, ms, or  us]; leave empty for default, or auto for automatic selection."))
143
+itarg = s:taboption("tab_qdisc", Value, "itarget", translate("Latency target for ingress, e.g 5ms [units: s, ms, or  us]; leave empty for automatic selection, put in the word default for the qdisc's default."))
144 144
 itarg.datatype = "string"
145 145
 itarg.rmempty = true
146 146
 itarg:depends("qdisc_really_really_advanced", "1")
147 147
 
148
-etarg = s:taboption("tab_qdisc", Value, "etarget", translate("Latency target for egress, e.g. 5ms [units: s, ms, or  us]; leave empty for default, or auto for automatic selection."))
148
+etarg = s:taboption("tab_qdisc", Value, "etarget", translate("Latency target for egress, e.g. 5ms [units: s, ms, or  us]; leave empty for automatic selection, put in the word default for the qdisc's default."))
149 149
 etarg.datatype = "string"
150 150
 etarg.rmempty = true
151 151
 etarg:depends("qdisc_really_really_advanced", "1")

+ 33
- 5
net/sqm-scripts/files/usr/lib/sqm/functions.sh View File

@@ -253,8 +253,8 @@ get_target() {
253 253
 	# either e.g. 100ms or auto
254 254
 	CUR_TARGET_VALUE=$( echo ${CUR_TARGET} | grep -o -e \^'[[:digit:]]\+' )
255 255
 	CUR_TARGET_UNIT=$( echo ${CUR_TARGET} | grep -o -e '[[:alpha:]]\+'\$ )
256
-#	[ ! -z "$CUR_TARGET" ] && sqm_logger "CUR_TARGET_VALUE: $CUR_TARGET_VALUE"
257
-#	[ ! -z "$CUR_TARGET" ] && sqm_logger "CUR_TARGET_UNIT: $CUR_TARGET_UNIT"
256
+	#[ ! -z "$CUR_TARGET" ] && sqm_logger "CUR_TARGET_VALUE: $CUR_TARGET_VALUE"
257
+	#[ ! -z "$CUR_TARGET" ] && sqm_logger "CUR_TARGET_UNIT: $CUR_TARGET_UNIT"
258 258
 	
259 259
 	AUTO_TARGET=
260 260
 	UNIT_VALID=
@@ -271,14 +271,42 @@ get_target() {
271 271
 					;;
272 272
 			    esac
273 273
 			fi
274
-			case ${CUR_TARGET_UNIT} in
275
-			    auto|Auto|AUTO) 
274
+			# empty field in GUI or undefined GUI variable now defaults to auto
275
+			if [ -z "${CUR_TARGET_VALUE}" -a -z "${CUR_TARGET_UNIT}" ];
276
+    			then			
276 277
 				if [ ! -z "${CUR_LINK_KBPS}" ];
277 278
 				then
278 279
 				    TMP_TARGET_US=$( adapt_target_to_slow_link $CUR_LINK_KBPS )
279 280
 				    TMP_INTERVAL_STRING=$( adapt_interval_to_slow_link $TMP_TARGET_US )
280 281
 				    CUR_TARGET_STRING="target ${TMP_TARGET_US}us ${TMP_INTERVAL_STRING}"
281 282
 				    AUTO_TARGET="1"
283
+				    sqm_logger "get_target defaulting to auto." 
284
+			    	else
285
+				    sqm_logger "required link bandwidth in kbps not passed to get_target()." 
286
+				fi
287
+			fi
288
+			# but still allow explicit use of the keyword auto for backward compatibility
289
+                        case ${CUR_TARGET_UNIT} in
290
+                            auto|Auto|AUTO)
291
+                                if [ ! -z "${CUR_LINK_KBPS}" ];
292
+                                then
293
+                                    TMP_TARGET_US=$( adapt_target_to_slow_link $CUR_LINK_KBPS )
294
+                                    TMP_INTERVAL_STRING=$( adapt_interval_to_slow_link $TMP_TARGET_US )
295
+                                    CUR_TARGET_STRING="target ${TMP_TARGET_US}us ${TMP_INTERVAL_STRING}"
296
+                                    AUTO_TARGET="1"
297
+                                else
298
+                                    sqm_logger "required link bandwidth in kbps not passed to get_target()."
299
+                                fi
300
+                            ;;
301
+                        esac
302
+			
303
+			case ${CUR_TARGET_UNIT} in
304
+			    default|Default|DEFAULT) 
305
+				if [ ! -z "${CUR_LINK_KBPS}" ];
306
+				then
307
+				    CUR_TARGET_STRING=""	# return nothing so the default target is not over-ridden...
308
+				    AUTO_TARGET="1"
309
+				    #sqm_logger "get_target using qdisc default, no explicit target string passed."
282 310
 			    	else
283 311
 			    	    sqm_logger "required link bandwidth in kbps not passed to get_target()." 
284 312
 			        fi
@@ -288,7 +316,7 @@ get_target() {
288 316
 			    then
289 317
 			    if [ -z "${CUR_TARGET_VALUE}" -o -z "${UNIT_VALID}" ];
290 318
 			    then 
291
-				[ -z "$AUTO_TARGET" ] && sqm_logger "${CUR_TARGET} is not a well formed tc target specifier; e.g.: 5ms (or s, us), or the string auto."
319
+				[ -z "$AUTO_TARGET" ] && sqm_logger "${CUR_TARGET} is not a well formed tc target specifier; e.g.: 5ms (or s, us), or one of the strings auto or default."
292 320
 			    fi
293 321
 			fi
294 322
 		    ;;