Project

General

Profile

« Previous | Next » 

Revision 2df5d9ee

Added by Jim Pingle about 8 years ago

Add OpenVPN GUI option for "fast-io" to clients and servers. Ticket #7507
Only compatible with UDP modes, and also not compatible with "shaper".

View differences:

src/etc/inc/openvpn.inc
1180 1180
		}
1181 1181
	}
1182 1182

  
1183
	/* UDP Fast I/O. Only compatible with UDP and also not compatible with OpenVPN's "shaper" directive. */
1184
	if ($settings['udp_fast_io']
1185
	    && (strtolower(substr($settings['protocol'], 0, 3)) == "udp")
1186
	    && (empty($settings['use_shaper']))) {
1187
		$conf .= "fast-io\n";
1188
	}
1189

  
1183 1190
	openvpn_add_custom($settings, $conf);
1184 1191

  
1185 1192
	openvpn_create_dirs();
src/usr/local/www/vpn_openvpn_client.php
163 163
		$pconfig['use_shaper'] = $a_client[$id]['use_shaper'];
164 164
		$pconfig['compression'] = $a_client[$id]['compression'];
165 165
		$pconfig['passtos'] = $a_client[$id]['passtos'];
166
		$pconfig['udp_fast_io'] = $a_client[$id]['udp_fast_io'];
166 167
		$pconfig['topology'] = $a_client[$id]['topology'];
167 168

  
168 169
		// just in case the modes switch
......
342 343
		$input_errors[] = gettext("Password and confirmation must match.");
343 344
	}
344 345

  
346
	/* UDP Fast I/O is not compatible with TCP, so toss the option out when
347
	   submitted since it can't be set this way legitimately. This also avoids
348
	   having to perform any more trickery on the stored option to not preserve
349
	   the value when changing modes. */
350
	if ($pconfig['udp_fast_io'] && (strtolower(substr($pconfig['protocol'], 0, 3)) != "udp")) {
351
		unset($pconfig['udp_fast_io']);
352
	}
353

  
354
	if ($pconfig['udp_fast_io'] && (!empty($pconfig['use_shaper']))) {
355
		/* Only warn if the user is set to UDP, otherwise it isn't relevant (See above) */
356
		if (strtolower(substr($pconfig['protocol'], 0, 3)) == "udp") {
357
			$input_errors[] = gettext("Limit Outgoing Bandwidth is not compatible with UDP Fast I/O.");
358
		} else {
359
			unset($pconfig['udp_fast_io']);
360
		}
361
	}
362

  
345 363
	if (!$input_errors) {
346 364

  
347 365
		$client = array();
......
415 433
		$client['use_shaper'] = $pconfig['use_shaper'];
416 434
		$client['compression'] = $pconfig['compression'];
417 435
		$client['passtos'] = $pconfig['passtos'];
436
		$client['udp_fast_io'] = $pconfig['udp_fast_io'];
418 437

  
419 438
		$client['route_no_pull'] = $pconfig['route_no_pull'];
420 439
		$client['route_no_exec'] = $pconfig['route_no_exec'];
......
816 835
		'number',
817 836
		$pconfig['use_shaper'],
818 837
		['min' => 100, 'max' => 100000000, 'placeholder' => 'Between 100 and 100,000,000 bytes/sec']
819
	))->setHelp('Maximum outgoing bandwidth for this tunnel. Leave empty for no limit. The input value has to be something between 100 bytes/sec and 100 Mbytes/sec (entered as bytes per second).');
838
	))->setHelp('Maximum outgoing bandwidth for this tunnel. Leave empty for no limit. The input value has to be something between 100 bytes/sec and 100 Mbytes/sec (entered as bytes per second). ' .
839
				'Not compatible with UDP Fast I/O.');
820 840

  
821 841
	$section->addInput(new Form_Select(
822 842
		'compression',
......
864 884
		$pconfig['custom_options']
865 885
	))->setHelp('Enter any additional options to add to the OpenVPN client configuration here, separated by semicolon.');
866 886

  
887
	$section->addInput(new Form_Checkbox(
888
		'udp_fast_io',
889
		'UDP Fast I/O',
890
		'Use fast I/O operations with UDP writes to tun/tap. Experimental.',
891
		$pconfig['udp_fast_io']
892
	))->setHelp('Optimizes the packet write event loop, improving CPU efficiency by 5% to 10%. ' .
893
		'Not compatible with all platforms, and not compatible with OpenVPN bandwidth limiting.');
894

  
867 895
	$section->addInput(new Form_Select(
868 896
		'verbosity_level',
869 897
		'Verbosity level',
......
995 1023
		hideInput('topology',  ($('#dev_mode').val() == 'tap') || $('#mode').val() == "p2p_shared_key");
996 1024
	}
997 1025

  
1026
	function protocol_change() {
1027
		if ($('#protocol').val().substring(0, 3).toLowerCase() == 'udp') {
1028
			hideCheckbox('udp_fast_io', false);
1029
		} else {
1030
			hideCheckbox('udp_fast_io', true);
1031
		}
1032
	}
1033

  
998 1034
	// Process "Automatically generate a shared key" checkbox
999 1035
	function autokey_change() {
1000 1036
		hideInput('shared_key', $('#autokey_enable').prop('checked'));
......
1034 1070
		mode_change();
1035 1071
	});
1036 1072

  
1073
	// Protocol
1074
	$('#protocol').change(function () {
1075
		protocol_change();
1076
	});
1077

  
1037 1078
	 // Use proxy
1038 1079
	$('#proxy_authtype').change(function () {
1039 1080
		useproxy_changed();
......
1090 1131

  
1091 1132
	// ---------- Set initial page display state ----------------------------------------------------------------------
1092 1133
	mode_change();
1134
	protocol_change();
1093 1135
	autokey_change();
1094 1136
	tlsauth_change();
1095 1137
	useproxy_changed();
src/usr/local/www/vpn_openvpn_server.php
251 251
		}
252 252

  
253 253
		$pconfig['push_blockoutsidedns'] = $a_server[$id]['push_blockoutsidedns'];
254
		$pconfig['udp_fast_io'] = $a_server[$id]['udp_fast_io'];
254 255
		$pconfig['push_register_dns'] = $a_server[$id]['push_register_dns'];
255 256
	}
256 257
}
......
470 471
		}
471 472
	}
472 473

  
474
	/* UDP Fast I/O is not compatible with TCP, so toss the option out when
475
	   submitted since it can't be set this way legitimately. This also avoids
476
	   having to perform any more trickery on the stored option to not preserve
477
	   the value when changing modes. */
478
	if ($pconfig['udp_fast_io'] && (strtolower(substr($pconfig['protocol'], 0, 3)) != "udp")) {
479
		unset($pconfig['udp_fast_io']);
480
	}
481

  
473 482
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
474 483

  
475 484
	if (!$input_errors) {
......
566 575
		if ($pconfig['push_blockoutsidedns']) {
567 576
			$server['push_blockoutsidedns'] = $pconfig['push_blockoutsidedns'];
568 577
		}
578
		if ($pconfig['udp_fast_io']) {
579
			$server['udp_fast_io'] = $pconfig['udp_fast_io'];
580
		}
569 581
		if ($pconfig['push_register_dns']) {
570 582
			$server['push_register_dns'] = $pconfig['push_register_dns'];
571 583
		}
......
1300 1312
	))->setHelp('Enter any additional options to add to the OpenVPN server configuration here, separated by semicolon.%1$s' .
1301 1313
				'EXAMPLE: push "route 10.0.0.0 255.255.255.0"', '<br />');
1302 1314

  
1315
	$section->addInput(new Form_Checkbox(
1316
		'udp_fast_io',
1317
		'UDP Fast I/O',
1318
		'Use fast I/O operations with UDP writes to tun/tap. Experimental.',
1319
		$pconfig['udp_fast_io']
1320
	))->setHelp('Optimizes the packet write event loop, improving CPU efficiency by 5% to 10%. ' .
1321
		'Not compatible with all platforms, and not compatible with OpenVPN bandwidth limiting.');
1322

  
1303 1323
	$section->addInput(new Form_Select(
1304 1324
		'verbosity_level',
1305 1325
		'Verbosity level',
......
1532 1552
		autokey_change();
1533 1553
	}
1534 1554

  
1555
	function protocol_change() {
1556
		if ($('#protocol').val().substring(0, 3).toLowerCase() == 'udp') {
1557
			hideCheckbox('udp_fast_io', false);
1558
		} else {
1559
			hideCheckbox('udp_fast_io', true);
1560
		}
1561
	}
1562

  
1535 1563
	// Process "Enable authentication of TLS packets" checkbox
1536 1564
	function tlsauth_change() {
1537 1565
		autotls_change();
......
1754 1782
		tuntap_change();
1755 1783
	});
1756 1784

  
1785
	// Protocol
1786
	$('#protocol').change(function () {
1787
		protocol_change();
1788
	});
1789

  
1757 1790
	 // Tun/tap mode
1758 1791
	$('#dev_mode, #serverbridge_dhcp').change(function () {
1759 1792
		tuntap_change();
......
1811 1844

  
1812 1845
	// ---------- Set initial page display state ----------------------------------------------------------------------
1813 1846
	mode_change();
1847
	protocol_change();
1814 1848
	autokey_change();
1815 1849
	tlsauth_change();
1816 1850
	gwredir_change();

Also available in: Unified diff