Commit 618b3a85 authored by Robert Anderson's avatar Robert Anderson
Browse files

Use size values as kbyte instead of byte

Convert bytes to kbytes on a new request
Removed accounting bytes to kbytes conversion as the session value is used
Updated UPGRADING file with details on how to modify the database to accommodate the changes to policyd

NOTE: This commit will change the behaviour of message size counters used in policyd!

The following changes will need to be made to your database:

UPDATE quotas_limits, quotas_tracking
                SET quotas_limits.CounterLimit = ceil(quotas_limits.CounterLimit / 1024),
                quotas_tracking.Counter = ceil(quotas_tracking.Counter / 1024)
                WHERE quotas_tracking.QuotasLimitsID = quotas_limits.ID
                AND quotas_limits.Type = "MessageCumulativeSize";

UPDATE session_tracking SET Size = ceil(Size / 1024);
parent 31c5b94f
Updating database for f9855324c09e674daa276cff21d437080c1aee85
--------------------------------------------------------------
UPDATE quotas_limits, quotas_tracking
SET quotas_limits.CounterLimit = ceil(quotas_limits.CounterLimit / 1024),
quotas_tracking.Counter = ceil(quotas_tracking.Counter / 1024)
WHERE quotas_tracking.QuotasLimitsID = quotas_limits.ID
AND quotas_limits.Type = "MessageCumulativeSize";
UPDATE session_tracking SET Size = ceil(Size / 1024);
Upgrading from 2.0.x
--------------------
......
......@@ -450,9 +450,6 @@ POLICY: foreach my $priority (sort {$a <=> $b} keys %{$sessionData->{'_Recipie
next; # If not just carry on?
}
# Bump up counter
my $sessionDataSize = ceil($sessionData->{'Size'} / 1024);
# Update database
my $sth = DBDo('
UPDATE
......
......@@ -37,6 +37,7 @@ use awitpt::db::dblayer;
use awitpt::netip;
use cbp::logging;
use cbp::policies;
use POSIX qw( ceil);
use Data::Dumper;
......@@ -112,6 +113,12 @@ sub getSessionDataFromRequest
return -1;
}
# Change size to kbyte, we don't want to use bytes
my $requestSize;
if (defined($request->{'size'})) {
$requestSize = ceil($request->{'size'} / 1024);
}
my $sessionData;
# Check protocol
......@@ -178,7 +185,7 @@ sub getSessionDataFromRequest
$request->{'client_name'},$request->{'reverse_client_name'},$request->{'protocol_name'},
$request->{'encryption_protocol'},$request->{'encryption_cipher'},$request->{'encryption_keysize'},
$request->{'sasl_method'},$request->{'sasl_sender'},$request->{'sasl_username'},$request->{'helo_name'},
$request->{'sender'},$request->{'size'}
$request->{'sender'},$requestSize
);
if (!$sth) {
$server->log(LOG_ERR,"[TRACKING] Failed to record session tracking info: ".awitpt::db::dblayer::Error());
......@@ -213,7 +220,7 @@ sub getSessionDataFromRequest
$sessionData->{'SASLUsername'} = $request->{'sasl_username'};
$sessionData->{'Helo'} = $request->{'helo_name'};
$sessionData->{'Sender'} = $request->{'sender'};
$sessionData->{'Size'} = $request->{'size'};
$sessionData->{'Size'} = $requestSize;
$sessionData->{'RecipientData'} = "";
}
......@@ -258,7 +265,7 @@ sub getSessionDataFromRequest
$server->log(LOG_DEBUG,"[TRACKING] Decoded into: ".Dumper($sessionData->{'_Recipient_To_Policy'})) if ($log);
# This must be updated here ... we may of got actual size
$sessionData->{'Size'} = $request->{'size'};
$sessionData->{'Size'} = $requestSize;
# Only get a queue id once we have gotten the message
$sessionData->{'QueueID'} = $request->{'queue_id'};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment