[PATCH 2/8] AP: use monotonic time for STA accounting

Jouni Malinen j at w1.fi
Sat Dec 7 21:21:02 EST 2013


On Mon, Nov 25, 2013 at 09:56:03PM +0100, Johannes Berg wrote:
> For type-safetype, make sta->acct_session_start a struct os_reltime

type-safety? ;-)

> diff --git a/src/ap/accounting.c b/src/ap/accounting.c
> @@ -244,7 +242,7 @@ static void accounting_sta_report(struct hostapd_data *hapd,
> -	struct os_time now;
> +	struct os_reltime now, diff;
> @@ -258,9 +256,10 @@ static void accounting_sta_report(struct hostapd_data *hapd,
> -	os_get_time(&now);
> +	os_get_reltime(&now);
> +	os_reltime_sub(&now, &sta->acct_session_start, &diff);
>  	if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_SESSION_TIME,
> -				       now.sec - sta->acct_session_start)) {
> +				       diff.sec)) {

While this part here looks fine, the following use of now in the same
function is problematic:

    if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
		       now.sec)) {

I'd expect that RADIUS Timestamp attribute to be in showing the real
timestamp of the current moment rather than the system-internal relative
timestamp.

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list