summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-11-11 12:27:28 +0000
committerErmal Luçi <eri@pfsense.org>2009-11-11 12:27:43 +0000
commit6ec23212f506545768f7838062d461af32596984 (patch)
tree37e8cc7989e01430809b74e999c1570e103841bb /etc
parent06231a7d95deb1d1dbdf5cd467de1e199c292ab4 (diff)
downloadpfsense-6ec23212f506545768f7838062d461af32596984.zip
pfsense-6ec23212f506545768f7838062d461af32596984.tar.gz
Simplify divert port generation and make sure it is even to leave room to ipfw-classifyd to always open 2 divert sockets one for reading and one for writing.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/shaper.inc18
1 files changed, 4 insertions, 14 deletions
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc
index b56d806..cd34841 100644
--- a/etc/inc/shaper.inc
+++ b/etc/inc/shaper.inc
@@ -3316,20 +3316,10 @@ class layer7 {
//Generate a random port for the divert socket
function gen_divert_port() {
$dports = get_divert_ports(); //array of used ports
- $divert_port = rand(40000, 60000);
- while(true) {
- foreach($dports as $dport) {
- $dupe = false;
- if($dport == $divert_port) {
- $divert_port = rand(40000, 60000);
- $dupe = true;
- break;
- }
- }
- if(!$dupe) {
- break;
- }
- }
+ $divert_port = 1; // Initialize
+ while (($divert_port % 2) != 0 || in_array($divert_port, $dports)) {
+ $divert_port = rand(40000, 60000);
+ }
return $divert_port;
}
OpenPOWER on IntegriCloud