diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-11-11 12:27:28 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-11-11 12:27:43 +0000 |
commit | 6ec23212f506545768f7838062d461af32596984 (patch) | |
tree | 37e8cc7989e01430809b74e999c1570e103841bb /etc | |
parent | 06231a7d95deb1d1dbdf5cd467de1e199c292ab4 (diff) | |
download | pfsense-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.inc | 18 |
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; } |