sqlcounter returning wrong value?

tnt at kalik.net tnt at kalik.net
Sat Oct 25 14:26:59 CEST 2008


OK. This where the "problem" comes from:

		/*
		 *	If we are near a reset then add the next
		 *	limit, so that the user will not need to
		 *	login again
		 */
		if (data->reset_time &&
		    (res >= (data->reset_time - request->timestamp))) {
			res = data->reset_time - request->timestamp;
			res += check_vp->vp_integer;
		}

(that's rlm_sqlcounter.c line about 710 in 2.0.5)

Sqlcounter was designed for time counters. When your allowance (limit -
time used) is greater than the time left in the period, time left in the
period is added to the limit and sent as reply.

This will create problems for data counters since limit values are much
greater than those for time counters. As a workaround I would suggest
that you comment this out if you are using data counters.

Perhaps there is a case for adding another configuration item to
sqlcounter that would determine what is counted time or data. Then for
data counters this can be skipped or replaced with something like:

if (data->reset_time && (trigger >= (data->reset_time -
request->timestamp))) {
     res += check_vp->vp_integer;
}

where trigger would be set to a minute for hourly counter and hour for
daily, weekly and monthly counters. I am sorry but I don't know how to
write a patch.

Ivan Kalik
Kalik Informatika ISP

Dana 24/10/2008, "liran tal" <liransgarage at gmail.com> piše:

>Hey Ivan
>
>2008/10/24 <tnt at kalik.net>
>
>> It (daily sqlcounter) does the same in 2.0.5:
>>
>> rlm_sqlcounter: Authorized user jagoda, check_item=10000000, counter=2635
>> rlm_sqlcounter: Sent Reply-Item for user jagoda, Type=Session-Timeout,
>> value=10027850
>>
>> Returns value that is greater than the limit. I am using noreset
>> sqlcounter and that one works fine.
>
>
>Thanks for confirming this on a more up to date version.
>Alan, this smells like a bug (unless we missed something along the way),
>should I open up a bug ticket?
>And what would be the chances it can be backported to 1.1.7?
>
>Thanks,
>Liran.




More information about the Freeradius-Users mailing list