Project

General

Profile

« Previous | Next » 

Revision 41799195

Added by Pi Ba almost 8 years ago

shaper, hfsc cannot use priority, as such don't show the field in the webgui.
Also for the other shapers 0 is a valid priority
While fairq causes a error loading rules with a priority above 7 so prevent that.

View differences:

src/etc/inc/shaper.inc
1214 1214
		}
1215 1215
		if ($this->CheckBandwidth($data['bandwidth'], $data['bandwidthtype']))
1216 1216
			$input_errors[] = "The sum of child bandwidth is higher than parent.";
1217
		if ($data['priority'] && (!is_numeric($data['priority']) ||
1218
		    ($data['priority'] < 1) || ($data['priority'] > 15))) {
1217
		
1218
		if (isset($data['priority']) && (!is_numeric($data['priority']) ||
1219
		    ($data['priority'] < 0) || ($data['priority'] > 15))) {
1219 1220
			$input_errors[] = gettext("The priority must be an integer between 1 and 15.");
1220 1221
		}
1221 1222
		if ($data['qlimit'] && (!is_numeric($data['qlimit']))) {
......
1256 1257
		} else {
1257 1258
			$this->SetQlimit(""); // Default
1258 1259
		}
1259
		if (!empty($q['priority'])) {
1260
		if (is_numeric($q['priority'])) {
1260 1261
			$this->SetQPriority($q['priority']);
1261 1262
		} else {
1262 1263
			$this->SetQpriority("");
......
1331 1332
			$pfq_rule .= " on ".get_real_interface($this->GetInterface());
1332 1333
		}
1333 1334
		$tmpvalue = $this->GetQpriority();
1334
		if (!empty($tmpvalue)) {
1335
		if (is_numeric($tmpvalue)) {
1335 1336
			$pfq_rule .= " priority ".$this->GetQpriority();
1336 1337
		}
1337 1338
		$tmpvalue = $this->GetQlimit();
......
1423 1424
			$this->GetQname()
1424 1425
		));
1425 1426

  
1426
		$section->addInput(new Form_Input(
1427
			'priority',
1428
			'Priority',
1429
			'number',
1430
			$this->GetQpriority(),
1431
			['min' => '0', 'max'=> '7']
1432
		))->setHelp('For hfsc, the range is 0 to 7. The default is 1. Hfsc queues with a higher priority are preferred in the case of overload.');
1427
		if (!is_a($this, "hfsc_queue")) {
1428
			$section->addInput(new Form_Input(
1429
				'priority',
1430
				'Priority',
1431
				'number',
1432
				$this->GetQpriority(),
1433
				['min' => '0', 'max'=> '']
1434
			))->setHelp('For cbq and fairq the range is 0 to 7. The default is 1. For priq the range is 0 to 15, queues with a higher priority are preferred in the case of overload.');
1435
		}
1433 1436

  
1434 1437
		$section->addInput(new Form_Input(
1435 1438
			'qlimit',
......
1589 1592
			unset($cflink['qlimit']);
1590 1593
		}
1591 1594
		$cflink['priority'] = trim($this->GetQpriority());
1592
		if (empty($cflink['priority'])) {
1595
		if (!is_numeric($cflink['priority'])) {
1593 1596
			unset($cflink['priority']);
1594 1597
		}
1595 1598
		$cflink['description'] = trim($this->GetDescription());
......
2410 2413
			unset($cflink['qlimit']);
2411 2414
		}
2412 2415
		$cflink['priority'] = $this->GetQpriority();
2413
		if (empty($cflink['priority'])) {
2416
		if (!is_numericint($cflink['priority'])) {
2414 2417
			unset($cflink['priority']);
2415 2418
		}
2416 2419
		$cflink['description'] = $this->GetDescription();
......
2562 2565
			unset($cflink['qlimit']);
2563 2566
		}
2564 2567
		$cflink['priority'] = trim($this->GetQpriority());
2565
		if (empty($cflink['priority'])) {
2568
		if (!is_numeric($cflink['priority'])) {
2566 2569
			unset($cflink['priority']);
2567 2570
		}
2568 2571
		$cflink['name'] = $this->GetQname();
......
2644 2647
		parent::validate_input($data, $input_errors);
2645 2648

  
2646 2649
		if ($data['priority'] > 7) {
2647
				$input_errors[] = gettext("Priority must be an integer between 1 and 7.");
2650
				$input_errors[] = gettext("Priority must be an integer between 0 and 7.");
2648 2651
		}
2649 2652
		$reqdfields[] = "bandwidth";
2650 2653
		$reqdfieldsn[] = gettext("Bandwidth");
......
2696 2699
			$pfq_rule .= " bandwidth ".trim($this->GetBandwidth()).$this->GetBwscale();
2697 2700
		}
2698 2701
		$tmpvalue = $this->GetQpriority();
2699
		if (!empty($tmpvalue)) {
2702
		if (is_numeric($tmpvalue)) {
2700 2703
			$pfq_rule .= " priority " . $this->GetQpriority();
2701 2704
		}
2702 2705
		$tmpvalue = trim($this->GetQlimit());
......
2826 2829
			unset($cflink['qlimit']);
2827 2830
		}
2828 2831
		$cflink['priority'] = $this->GetQpriority();
2829
		if (empty($cflink['priority'])) {
2832
		if (!is_numeric($cflink['priority'])) {
2830 2833
			unset($cflink['priority']);
2831 2834
		}
2832 2835
		$cflink['name'] = $this->GetQname();
......
2925 2928
	function validate_input($data, &$input_errors) {
2926 2929
		parent::validate_input($data, $input_errors);
2927 2930

  
2928
		if ($data['priority'] > 255) {
2929
				$input_errors[] = gettext("Priority must be an integer between 1 and 255.");
2931
		if ($data['priority'] > 7) {
2932
				$input_errors[] = gettext("Priority must be an integer between 0 and 7.");
2930 2933
		}
2931 2934
		$reqdfields[] = "bandwidth";
2932 2935
		$reqdfieldsn[] = gettext("Bandwidth");
......
2977 2980
			$pfq_rule .= " bandwidth ".trim($this->GetBandwidth()).$this->GetBwscale();
2978 2981
		}
2979 2982
		$tmpvalue = trim($this->GetQpriority());
2980
		if (!empty($tmpvalue)) {
2983
		if (is_numeric($tmpvalue)) {
2981 2984
			$pfq_rule .= " priority " . $this->GetQpriority();
2982 2985
		}
2983 2986
		$tmpvalue = trim($this->GetQlimit());
......
3105 3108
			unset($cflink['qlimit']);
3106 3109
		}
3107 3110
		$cflink['priority'] = trim($this->GetQpriority());
3108
		if (empty($cflink['priority'])) {
3111
		if (!is_numeric($cflink['priority'])) {
3109 3112
			unset($cflink['priority']);
3110 3113
		}
3111 3114
		$cflink['name'] = $this->GetQname();

Also available in: Unified diff